/* === A4 Page Layout === */

:root {
    --bleeding: 0.5cm;
    --margin: 1cm;
}

@page {
    size: A4 landscape;
    margin: 0;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0 auto;
    padding: 0;
    background: #1e1e2e;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* === Info Modal === */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    animation: modalFadeIn 0.2s ease;
}

.modal {
    width: 90%;
    max-width: 480px;
    padding: 2rem 2rem 1.5rem;
    background: #2a2a3d;
    border-radius: 14px;
    text-align: center;
    color: #cdd6f4;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.25s ease;
}

.modal h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 0.3rem;
}

.modal-subtitle {
    font-size: 0.9rem;
    color: #a6adc8;
    margin: 0 0 1.25rem;
}

.modal-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem 1.2rem;
    margin-bottom: 1.5rem;
}

.modal-feature {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: #bac2de;
}

.modal-feature svg {
    flex-shrink: 0;
    color: #89b4fa;
}

.modal-btn {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: #89b4fa;
    color: #1e1e2e;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
}

.modal-btn:hover {
    background: #a6c8ff;
    transform: scale(1.04);
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* === Info Button (top-left) === */

.info-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(42, 42, 61, 0.9);
    color: #89b4fa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: background 0.15s, transform 0.1s;
    z-index: 10002;
}

.info-btn:hover {
    background: rgba(42, 42, 61, 1);
    transform: scale(1.1);
}

/* Info button tooltip */
.info-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.info-btn[data-tooltip]:hover::after {
    opacity: 1;
}

/* === Certificate List === */

.certificate-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 6rem;
}

/* === Page === */

.page {
    display: inline-block;
    position: relative;
    height: 210mm;
    width: 297mm;
    font-size: 12pt;
    margin: 2em auto;
    padding: calc(var(--bleeding) + var(--margin));
    box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.5);
    background: white;
    background-image: url("../static/Zertifikat.png");
    background-repeat: no-repeat;
    background-size: contain;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
}

@media screen {
    .page::after {
        position: absolute;
        content: '';
        top: 0;
        left: 0;
        width: calc(100% - var(--bleeding) * 2);
        height: calc(100% - var(--bleeding) * 2);
        margin: var(--bleeding);
        outline: thin dashed black;
        pointer-events: none;
        z-index: 9999;
    }
}

@media print {
    .page {
        margin: 0;
        overflow: hidden;
    }
    .fab,
    .page-actions {
        display: none !important;
    }
}

/* === Page Actions (hover overlay) === */

.page-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10000;
}

.page:hover .page-actions {
    opacity: 1;
}

.page-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(30, 30, 46, 0.85);
    color: #cdd6f4;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.page-action:hover {
    background: rgba(30, 30, 46, 0.95);
    transform: scale(1.08);
}

/* Tooltip */
.page-action[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.page-action[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(0);
}

.page-action input[type="file"] {
    display: none;
}

/* === Fonts === */

.pixelify-sans {
    font-family: "Pixelify Sans", sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
}

.standard-font {
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
}

/* === Content Wrapper === */

.content-wrapper {
    width: 80%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* === Predicat (heading) === */

.predicat {
    text-align: center;
    margin-top: -10px;
    padding-bottom: 5rem;
}

.predicat-field {
    font-size: 4.5rem;
    width: 100%;
    text-align: center;
    font-family: "Pixelify Sans", sans-serif;
}

/* === Editable Fields (contenteditable) === */

.editable {
    outline: none;
    border: none;
    background: transparent;
    cursor: text;
    border-radius: 4px;
    transition: box-shadow 0.15s;
}

.editable:hover {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.editable:focus {
    box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.5);
}

.editable:empty::before {
    content: attr(data-placeholder);
    color: rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* Meta and date placeholders: white-based */
.meta .editable:empty::before,
.date-area .editable:empty::before {
    color: rgba(255, 255, 255, 0.4);
}

/* === Field Sizes === */

.field-title {
    font-size: 3rem;
    width: 100%;
    text-align: center;
}

.name-field-wrapper {
    position: relative;
}

.field-name {
    font-size: 2.25rem;
    width: 100%;
    text-align: center;
}

.field-scratch {
    font-size: 1rem;
    width: 100%;
    text-align: center;
    background: transparent;
    border: none;
    outline: none;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
    padding: 0.5rem;
}

/* === CSV Hint (tooltip under name field) === */

.csv-hint {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    margin-top: 0.5rem;
    background: #1e1e2e;
    color: #cdd6f4;
    font-size: 0.8rem;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    z-index: 10001;
    animation: csvHintIn 0.2s ease;
}

.csv-hint::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #1e1e2e;
}

.csv-hint-link {
    color: #89b4fa;
    text-decoration: underline;
    cursor: pointer;
    margin-left: 0.4rem;
}

.csv-hint-link:hover {
    color: #a6c8ff;
}

@keyframes csvHintIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* === QR Code === */

.qr-wrapper {
    margin-top: 2.5rem;
    display: flex;
    justify-content: center;
    cursor: pointer;
}

#qr-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-placeholder {
    margin-top: 2.5rem;
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.95rem;
    cursor: pointer;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-placeholder:empty::before {
    content: attr(data-placeholder);
    color: rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.qr-input-wrapper {
    margin-top: 2.5rem;
    text-align: center;
}

.qr-input-wrapper input {
    padding: 0.5rem 1rem;
    border: 1px dashed rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    width: 300px;
}

.qr-input-wrapper input:focus {
    border-color: rgba(137, 180, 250, 0.5);
    outline: none;
}

/* === Meta Info === */

.meta {
    position: absolute;
    bottom: 9rem;
    left: 0;
    right: 0;
    width: 30%;
    margin: 0 auto;
    color: white;
}

.meta-field {
    font-size: 1.125rem;
    width: 100%;
    text-align: center;
    min-height: 80px;
    line-height: 1.4;
}

/* === Date === */

.date-area {
    position: absolute;
    bottom: 2.8rem;
    right: 5.1rem;
}

.date-field {
    font-size: 1.25rem;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
    color: white;
    text-align: right;
    min-width: 150px;
}

/* === FAB (Floating Action Button) === */

.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: #89b4fa;
    color: #1e1e2e;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.15s, transform 0.1s, width 0.25s, border-radius 0.25s;
    z-index: 10002;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
    white-space: nowrap;
    padding: 0;
}

.fab:hover {
    background: #a6c8ff;
    transform: scale(1.06);
}

.fab:active {
    transform: scale(0.98);
}

/* FAB Tooltip */
.fab[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: "Helvetica Neue", "Helvetica", Arial, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.fab[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateY(0);
}

.fab.has-batch[data-tooltip]::before {
    display: none;
}

.fab-icon {
    flex-shrink: 0;
}

.fab-label {
    display: none;
}

.fab.has-batch {
    width: auto;
    border-radius: 28px;
    padding: 0 1.25rem;
}

.fab.has-batch .fab-label {
    display: inline;
}

.fab.exporting {
    pointer-events: none;
    opacity: 0.85;
}

/* === Generated (non-template) certificates === */

.page.generated {
    cursor: default;
}

.page.generated .editable {
    cursor: default;
}

.page.generated .editable:hover {
    box-shadow: none;
}

.page.generated .qr-placeholder {
    display: none;
}

/* === Export cleanup: hide edit cues in cloned DOM === */

.exporting .editable:hover,
.exporting .editable:focus {
    box-shadow: none;
}

.exporting .editable:empty::before {
    content: none;
}

.exporting .qr-placeholder {
    display: none;
}

.exporting .qr-input-wrapper {
    display: none;
}

.exporting .page::after {
    display: none;
}

.exporting .page-actions {
    display: none;
}

.exporting .csv-hint {
    display: none;
}
