/* Toast notifications and confirmation modal (window.showToast / window.showConfirm in auth-client.js). */
#parinam-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.parinam-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
    max-width: 400px;
    padding: 14px 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    font-family: 'Noto Sans Gujarati', 'Nirmala UI', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #1a2332;
    border-left: 6px solid #4CAF50;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
}
.parinam-toast.show { opacity: 1; transform: translateX(0); }
.parinam-toast.error { border-left-color: #f44336; }
.parinam-toast.error span:first-child { color: #f44336; }
.parinam-toast.success { border-left-color: #4CAF50; }
.parinam-toast.success span:first-child { color: #4CAF50; }
.parinam-toast.info { border-left-color: #2196F3; }
.parinam-toast.info span:first-child { color: #2196F3; }
.parinam-toast.warning { border-left-color: #FF9800; }
.parinam-toast.warning span:first-child { color: #FF9800; }
@media (max-width: 600px) {
    #parinam-toast-container { top: 10px; right: 10px; left: 10px; }
    .parinam-toast { min-width: 0; max-width: 100%; justify-content: center; }
}

.parinam-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.2s;
}
.parinam-modal-overlay.show { opacity: 1; }
.parinam-modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.2s;
    text-align: center;
    font-family: 'Noto Sans Gujarati', 'Nirmala UI', system-ui, sans-serif;
}
.parinam-modal-overlay.show .parinam-modal { transform: scale(1); }
.parinam-modal-icon { font-size: 50px; margin-bottom: 15px; }
.parinam-modal h3 { margin: 0 0 10px 0; color: #193e61; font-size: 22px; font-weight: 800; }
.parinam-modal p { margin: 0 0 25px 0; color: #52677c; font-size: 16px; font-weight: 600; line-height: 1.5; }
.parinam-modal-actions { display: flex; gap: 12px; justify-content: center; }
.parinam-modal-actions button {
    flex: 1; padding: 12px; border: none; border-radius: 8px; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit; transition: 0.2s;
}
.btn-modal-cancel { background: #e2e8f0; color: #475569; }
.btn-modal-cancel:hover { background: #cbd5e1; }
.btn-modal-confirm { background: #dc2626; color: #fff; }
.btn-modal-confirm:hover { background: #b91c1c; }

/* WhatsApp sending overlay (whatsapp_result.js). Hidden when printing. */
.wa-skeleton-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.wa-skeleton-card {
    background: #fff;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 92vh;
    overflow-y: auto;
}
.wa-skeleton-header { height: 40px; background: #f1f5f9; border-radius: 8px; animation: wa-shimmer 1.5s infinite; }
.wa-skeleton-row { display: flex; gap: 10px; }
.wa-skeleton-box { height: 28px; background: #f1f5f9; border-radius: 6px; flex: 1; animation: wa-shimmer 1.5s infinite; }
.wa-skeleton-box.short { flex: 0.5; }
.wa-skeleton-table { display: flex; flex-direction: column; gap: 6px; }
.wa-skeleton-tr { height: 16px; background: #f1f5f9; border-radius: 4px; animation: wa-shimmer 1.5s infinite; }
.wa-skeleton-progress {
    text-align: center; font-family: 'Noto Sans Gujarati', 'Nirmala UI', system-ui, sans-serif; font-weight: 700; color: #245b8e; font-size: 16px; margin-top: 15px; white-space: pre-line; line-height: 1.5;
}
@keyframes wa-shimmer {
    0% { background-color: #f1f5f9; }
    50% { background-color: #e2e8f0; }
    100% { background-color: #f1f5f9; }
}
.wa-spinner {
    width: 36px; height: 36px; margin: 4px auto 0; border: 4px solid #cbd5e1; border-top-color: #245b8e; border-radius: 50%;
    animation: wa-spin 0.9s linear infinite;
}
@keyframes wa-spin { to { transform: rotate(360deg); } }
.wa-cancel-button {
    padding: 11px; border: 0; border-radius: 8px; background: #dc2626; color: #fff; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.wa-cancel-button:hover:not(:disabled) { background: #b91c1c; }
.wa-cancel-button:disabled { opacity: 0.6; cursor: wait; }
@media print { .wa-skeleton-overlay { display: none !important; } }

/* Breadcrumbs added by auth-client.js. Kept here so every page styles them the same way. */
.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-family: 'Noto Sans Gujarati', 'Nirmala UI', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: #52677c;
    padding: 10px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    width: 100%;
    box-sizing: border-box;
    position: sticky;
    top: var(--ssb-height, 40px);
    z-index: 9998;
}
.breadcrumbs a { color: #245b8e; text-decoration: none; transition: 0.2s; }
.breadcrumbs a:hover { color: #147477; text-decoration: underline; }
.breadcrumbs .separator { color: #94a3b8; font-size: 12px; }
.breadcrumbs .current { color: #193e61; font-weight: 700; }

/* Shared loading skeleton and empty state. Screen only, so print layouts stay unchanged. */
@media screen {
    .skeleton-page {
        width: 210mm;
        min-height: 297mm;
        background: #fff;
        margin: 0 auto;
        padding: 20mm;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        display: flex;
        flex-direction: column;
        gap: 15px;
        box-sizing: border-box;
        max-width: 100%;
    }
    .skeleton-line { height: 20px; background: #e0e0e0; border-radius: 4px; animation: skeleton-shimmer 1.5s infinite linear; }
    .skeleton-line.title { height: 40px; width: 60%; margin: 0 auto 20px auto; }
    .skeleton-line.short { width: 40%; }
    .skeleton-table { width: 100%; height: 300px; background: #f0f0f0; border-radius: 8px; animation: skeleton-shimmer 1.5s infinite linear; margin-top: 20px; }
    @keyframes skeleton-shimmer {
        0% { background-color: #e0e0e0; }
        50% { background-color: #f5f5f5; }
        100% { background-color: #e0e0e0; }
    }

    .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 50px 20px;
        text-align: center;
        background: #fff;
        border: 2px dashed #c7d3e0;
        border-radius: 16px;
        margin: 30px auto;
        max-width: 600px;
    }
    .empty-state .icon { font-size: 60px; margin-bottom: 20px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); }
    .empty-state h3 { color: #193e61; font-size: 24px; font-weight: 800; margin: 0 0 10px; }
    .empty-state p { color: #52677c; font-size: 16px; margin: 0 0 25px; }
    .empty-state .btn {
        display: inline-block; background: linear-gradient(180deg, #245b8e, #12375c); color: #fff; padding: 12px 30px; border-radius: 8px; font-weight: 700; text-decoration: none; font-size: 16px; transition: 0.2s; box-shadow: 0 4px 10px rgba(18,55,92,0.3);
    }
    .empty-state .btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(18,55,92,0.4); }
}

/* Shared mobile layout rules. Screen only, so print layouts stay unchanged. */
@media screen and (max-width: 900px) {
    html, body { max-width: 100%; }
    img, video { max-width: 100%; }

    /* Pages with a side control panel (marksheet, patrak F, school info). */
    body:has(> .main-container > .control-panel),
    body:has(> .main-container > .sidebar) {
        display: block !important;
        padding: 8px !important;
    }
    body:has(.marksheet-area) .main-container,
    body:has(.pages-area) .main-container,
    body:has(.form-container) .main-container {
        flex-direction: column !important;
        max-width: 100% !important;
        gap: 12px !important;
    }
    .main-container > .control-panel,
    .main-container > .sidebar {
        order: -1;
        width: 100% !important;
        position: static !important;
        max-height: none !important;
    }
    body:has(.marksheet-area) .control-panel,
    body:has(.pages-area) .control-panel {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    body:has(.marksheet-area) .control-panel > :not(.btn):not(.small-btn),
    body:has(.pages-area) .control-panel > :not(.btn):not(.small-btn),
    body:has(.marksheet-area) .control-panel > .home-return,
    body:has(.pages-area) .control-panel > .home-return {
        grid-column: 1 / -1;
    }

    /* A4 previews keep their real size and scroll sideways instead of being cut. */
    body:has(.marksheet-area) .main-container,
    .pages-area {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .pages-area { align-items: flex-start !important; width: 100%; }
    body:has(> .page), body:has(> .control-bar) {
        align-items: flex-start !important;
        overflow-x: auto;
        padding: 8px !important;
    }
    .top-bar, .control-bar { max-width: 100% !important; }

    .form-table, .form-table input, .form-table select { font-size: 15px !important; }
    .form-table td { padding: 8px !important; }
    .title-row, .title-row input { font-size: 20px !important; }

    .top-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .top-row-2 .btn { white-space: normal !important; }
    .title-badge { white-space: normal !important; }
    .paper-header { white-space: normal !important; }
    .table-wrapper, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media screen and (max-width: 600px) {
    .form-table td.label-col, .form-table td.value-col {
        display: block;
        width: 100% !important;
        text-align: left;
    }
    .form-table td.label-col { border-bottom: 0; }
    body:has(.marksheet-area) .control-panel,
    body:has(.pages-area) .control-panel { grid-template-columns: 1fr 1fr; }
    .btn { min-height: 40px; }
}
