/* ================================================================= */
/* CORE BRANDING & VARIABLES                                         */
/* ================================================================= */
:root {
    --font-primary: 'Outfit', sans-serif;
    --font-serif: 'Playfair Display', serif;
    
    /* Sleek light mode palette */
    --bg-app: #f1f5f9;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    --primary: #0d9488;          /* Teal base matching school logo theme */
    --primary-hover: #0f766e;
    --primary-light: #ccfbf1;
    --accent: #f59e0b;           /* Gold accent */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-on-primary: #ffffff;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --success: #10b981;
    --danger: #ef4444;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================================================= */
/* BASE STYLES                                                       */
/* ================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

button {
    font-family: var(--font-primary);
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
}

input, select, textarea {
    font-family: var(--font-primary);
    outline: none;
}

/* ================================================================= */
/* SYSTEM LAYOUT                                                     */
/* ================================================================= */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid #1e293b;
}

.app-logo {
    background-color: var(--primary);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #ffffff;
}

.app-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    display: block;
    margin-top: -2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 32px;
    flex-grow: 1;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.95rem;
    text-align: left;
    transition: var(--transition);
}

.nav-btn:hover {
    color: #ffffff;
    background-color: #1e293b;
}

.nav-btn.active {
    color: #ffffff;
    background-color: var(--primary);
}

.sidebar-footer {
    border-top: 1px solid #1e293b;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.role-selector-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.role-selector-container label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 500;
}

.footer-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #475569;
}

/* Main Content Styling */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.view-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.academic-year-badge {
    background-color: var(--primary-light);
    color: var(--primary-hover);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 50px;
}

.user-badge {
    background-color: #f1f5f9;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: var(--success);
}

/* View Pane Container */
.view-wrapper {
    flex-grow: 1;
    padding: 32px;
    overflow-y: auto;
}

.view-pane {
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.view-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================================================================= */
/* CARDS & CONTAINERS                                                */
/* ================================================================= */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-body {
    padding: 24px;
}

.card-body.no-padding {
    padding: 0;
}

.card-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

.grid-layout {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
    align-items: start;
}

/* ================================================================= */
/* FORM CONTROLS                                                     */
/* ================================================================= */
.control-group {
    margin-bottom: 16px;
}

.control-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.text-input, .select-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    color: var(--text-main);
    transition: var(--transition);
}

.text-input:focus, .select-input:focus {
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--text-main);
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ================================================================= */
/* BUTTONS                                                           */
/* ================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-on-primary);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-primary:disabled {
    background-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-outline {
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--bg-app);
    border-color: var(--text-muted);
}

.btn-outline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-close {
    font-size: 1.5rem;
    color: var(--text-muted);
    padding: 0 8px;
}

.btn-close:hover {
    color: var(--danger);
}

.span-columns {
    grid-column: span 2;
}

/* ================================================================= */
/* AUTOCOMPLETE & STUDENT SEARCH                                     */
/* ================================================================= */
.search-form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.search-input-group {
    flex-grow: 1;
}

.search-box-wrapper {
    position: relative;
}

.autocomplete-items {
    position: absolute;
    border: 1px solid var(--border-color);
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #ffffff;
    border-bottom-left-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 250px;
    overflow-y: auto;
}

.autocomplete-items div {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    transition: var(--transition);
}

.autocomplete-items div:last-child {
    border-bottom: none;
}

.autocomplete-items div:hover {
    background-color: var(--primary-light);
    color: var(--primary-hover);
}

.autocomplete-items div span.autocomplete-adm {
    font-weight: 700;
    color: var(--primary);
}

.gender-prefix-selector {
    display: flex;
    gap: 16px;
    margin-top: 4px;
}

.gender-prefix-selector label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
}

.gender-prefix-selector input {
    accent-color: var(--primary);
}

/* ================================================================= */
/* PROFILE CONTAINER                                                 */
/* ================================================================= */
.student-profile-details {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-student-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.no-student-placeholder p {
    font-size: 0.88rem;
    margin-top: 8px;
    font-weight: 500;
}

.profile-layout {
    display: flex;
    gap: 24px;
    width: 100%;
    align-items: flex-start;
}

.profile-photo-container {
    width: 120px;
    height: 140px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background-color: var(--input-bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.student-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info-grid {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 2px;
}

.text-highlight {
    color: var(--primary);
    font-weight: 700;
}

.hidden {
    display: none !important;
}

/* ================================================================= */
/* CONTROLS & ACTIONS LAYOUT                                         */
/* ================================================================= */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ================================================================= */
/* DATA TABLES (HISTORY)                                             */
/* ================================================================= */
.history-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-search-group {
    width: 300px;
}

.search-small {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.table-container {
    max-height: 500px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.data-table th {
    background-color: var(--input-bg);
    color: var(--text-muted);
    font-weight: 700;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-weight: 500;
}

.data-table tbody tr:hover {
    background-color: var(--input-bg);
}

.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-badge.active {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.cancelled {
    background-color: #fee2e2;
    color: #991b1b;
}

.empty-table-state {
    padding: 48px;
    text-align: center;
    color: var(--text-muted);
}

.empty-table-state p {
    margin-top: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.table-action-row {
    display: flex;
    gap: 8px;
}

.btn-table {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: 600;
}

.btn-table-cancel {
    background-color: #fee2e2;
    color: #b91c1c;
}
.btn-table-cancel:hover {
    background-color: #fca5a5;
}

.btn-table-delete {
    background-color: #f3f4f6;
    color: #4b5563;
}
.btn-table-delete:hover {
    background-color: #e5e7eb;
}

/* ================================================================= */
/* SETTINGS LAYOUT                                                   */
/* ================================================================= */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

.assets-preview-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-top: 6px;
}

.asset-preview-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.asset-preview-item span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.img-preview-box {
    height: 60px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 4px;
}

.img-preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.dummy-seal {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px dashed #b91c1c;
    color: #b91c1c;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
}

.preview-err {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ================================================================= */
/* PRINT PREVIEW MODAL (MS WORD VIEWPORT)                            */
/* ================================================================= */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-out;
}

.preview-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.preview-modal-header {
    height: 60px;
    background-color: #0f172a;
    color: #ffffff;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.preview-modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-modal-body {
    flex-grow: 1;
    overflow: auto;
    padding: 32px;
    display: flex;
    justify-content: center;
    background-color: #475569; /* Slate grey background exactly like Word */
}

.word-pages-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
    transform-origin: top center;
    transition: transform 0.25s ease-out;
}

/* ================================================================= */
/* CERTIFICATE LAYOUT TEMPLATE (FOR PREVIEW AND PRINT)               */
/* ================================================================= */
.print-page {
    background-color: #ffffff;
    box-shadow: 0 0 16px rgba(0,0,0,0.3);
    box-sizing: border-box;
    position: relative;
    color: #000000;
}

/* A5 Landscape layout inside container */
.word-pages-container .print-page {
    width: 210mm;
    height: 148mm;
    padding: 10mm;
}

/* A4 Portrait layout inside container (stacked) */
.word-pages-container.format-a4-preview .print-page {
    width: 200mm;
    height: 132mm;
    box-shadow: none;
    margin-bottom: 8mm;
    border: 2px solid #000000;
}

.word-pages-container.format-a4-preview {
    background-color: #ffffff;
    padding: 15mm 5mm;
    box-shadow: 0 0 16px rgba(0,0,0,0.3);
    width: 210mm;
    min-height: 297mm;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Double Border */
.cert-border {
    border: 5px double #000000;
    padding: 6mm;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

/* Watermark */
.cert-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 65mm;
    height: 65mm;
    opacity: 0.12; /* Light translucent logo watermark */
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    z-index: 0;
}

/* School Header */
.cert-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #000000;
    padding-bottom: 2mm;
    margin-bottom: 3mm;
}

.cert-logo-box {
    width: 18mm;
    height: 18mm;
    flex-shrink: 0;
}

.cert-logo-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cert-title-box {
    flex-grow: 1;
    text-align: center;
    padding: 0 3mm;
}

.cert-school-name {
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 800;
    color: #000000;
    letter-spacing: 0.2px;
}

.cert-school-meta {
    font-size: 0.62rem;
    font-weight: 700;
    color: #000000;
    margin-top: 1px;
}

.cert-school-motto {
    font-size: 0.65rem;
    font-weight: 700;
    font-style: italic;
    color: #000000;
    margin-top: 2px;
}

.cert-contact-box {
    text-align: right;
    font-size: 0.58rem;
    font-weight: 600;
    color: #000000;
    line-height: 1.4;
    max-width: 50mm;
}

/* Certificate Body Header */
.cert-body-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2mm;
    font-size: 0.72rem;
    font-weight: 700;
}

.cert-meta-item {
    display: flex;
    flex-direction: column;
}

.cert-num-lbl {
    font-weight: 700;
}

.cert-num-val {
    font-weight: 800;
}

.cert-type-title {
    text-align: center;
    margin: 1mm 0 3mm 0;
}

.cert-type-title h2 {
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 800;
    text-decoration: underline;
    letter-spacing: 1px;
    display: inline-block;
}

/* Layout with photo and body text */
.cert-content-layout {
    display: flex;
    gap: 4mm;
    align-items: flex-start;
    flex-grow: 1;
}

.cert-body-text {
    flex-grow: 1;
    font-family: var(--font-primary);
    font-size: 0.75rem;
    line-height: 1.6;
    text-align: justify;
    color: #000000;
    font-weight: 500;
}

.cert-body-text span.var {
    font-weight: 800;
    text-decoration: underline;
}

.cert-photo-box {
    width: 25mm;
    height: 30mm;
    border: 1px solid #000000;
    flex-shrink: 0;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cert-photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Signatures & Seal section */
.cert-footer-layout {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 3mm;
}

.cert-seal-area {
    width: 22mm;
    height: 22mm;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cert-seal-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.65;
}

.cert-sign-area {
    text-align: center;
    width: 50mm;
    position: relative;
}

.cert-signature-img {
    height: 12mm;
    object-fit: contain;
    margin-bottom: -2mm;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.cert-sign-lbl {
    font-size: 0.65rem;
    font-weight: 700;
    border-top: 1px solid #000000;
    padding-top: 1mm;
    text-transform: uppercase;
}

.cert-sign-title {
    font-size: 0.55rem;
    font-weight: 600;
    color: #000000;
}

.cert-qr-area {
    width: 18mm;
    height: 18mm;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cert-qr-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Copy Type footer line */
.cert-copy-banner {
    position: absolute;
    bottom: 1.5mm;
    left: 6mm;
    right: 6mm;
    display: flex;
    justify-content: space-between;
    font-size: 0.52rem;
    font-weight: 700;
    border-top: 1px dashed #cccccc;
    padding-top: 0.8mm;
    color: #64748b;
    z-index: 10;
}

.cert-copy-type {
    text-transform: uppercase;
    color: #000000;
    font-weight: 800;
}

/* ================================================================= */
/* QR CODE VERIFICATION BOX STYLES                                   */
/* ================================================================= */
.verification-pane {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f1f5f9;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.verification-box {
    background-color: #ffffff;
    max-width: 450px;
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.verification-logo-wrapper {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px auto;
}

.verification-logo-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.verification-status {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.verification-status.success {
    color: var(--success);
}

.verification-status svg {
    background-color: #d1fae5;
    padding: 8px;
    border-radius: 50%;
}

.verification-status h3 {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.verify-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.verification-details {
    text-align: left;
    margin-bottom: 24px;
}

.verify-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f8fafc;
}

.verify-row:last-child {
    border-bottom: none;
}

.verify-lbl {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.verify-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
}

.verify-close-btn {
    width: 100%;
}

/* ================================================================= */
/* PRINT CONTAINER AND MEDIA QUERY                                   */
/* ================================================================= */
.print-container {
    display: none;
}

@media print {
    /* Hide everything else on page */
    body * {
        visibility: hidden !important;
    }
    
    .print-container, .print-container * {
        visibility: visible !important;
    }
    
    .print-container {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    /* Layout: A5 Landscape Mode (Prints as individual A5 pages) */
    .print-container.format-a5 {
        width: 210mm;
    }
    
    .print-container.format-a5 .print-page {
        width: 210mm;
        height: 148mm;
        page-break-after: always;
        box-sizing: border-box;
        padding: 10mm;
        position: relative;
        overflow: hidden;
        border: none;
        box-shadow: none;
        display: block;
    }
    
    /* Layout: A4 Portrait Mode (Two A5 certificates stacked vertically on one A4 sheet) */
    .print-container.format-a4 {
        width: 210mm;
        height: 297mm;
        box-sizing: border-box;
        padding: 6mm 5mm;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        gap: 8mm;
    }
    
    .print-container.format-a4 .print-page {
        width: 200mm;
        height: 134mm;
        box-sizing: border-box;
        padding: 6mm;
        position: relative;
        overflow: hidden;
        border: 1px solid #000000;
        box-shadow: none;
        display: block;
        page-break-inside: avoid;
    }
    
    /* Clear A4 page breaks */
    .print-container.format-a4 .print-page:nth-child(2n) {
        page-break-after: always;
    }

    /* Print-specific layout tuning */
    .cert-border {
        border: 4px double #000000 !important;
        padding: 4mm !important;
    }
    
    .cert-photo-box {
        border: 1px solid #000000 !important;
    }

    .cert-watermark {
        opacity: 0.12 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Enable background printing */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    @page {
        margin: 0;
    }
}

.cert-text-watermark {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-20deg);
    font-size: 28pt;
    font-weight: 900;
    color: #b91c1c;
    opacity: 0.06;
    z-index: 1;
    pointer-events: none;
    white-space: nowrap;
    text-transform: uppercase;
    border: 3px double #b91c1c;
    padding: 8px 20px;
    border-radius: 4px;
}

.cert-seal-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    mix-blend-mode: multiply;
}

/* Login Overlay styles */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-app);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.login-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 400px;
    padding: 32px;
    animation: fadeIn 0.3s ease-out;
}
.login-header {
    text-align: center;
    margin-bottom: 24px;
}
.login-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 12px;
}
.login-error {
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 8px;
    text-align: center;
}
