/* Yearbook Weekly Reboot Styles - Screen Glassmorphism & Pro Printing */
:root {
    --weekly-card-bg: rgba(255, 255, 255, 0.03);
    --weekly-card-border: 1px solid rgba(255, 255, 255, 0.08);
    --weekly-hover-bg: rgba(255, 255, 255, 0.07);
    --print-text: #000;
    --print-border: #333;
    /* [New] Eval Badge Color for Print */
    --print-eval-bg: #fffbeb;
    --print-eval-border: #fcd34d;
    --print-eval-text: #b45309;
}

/* 1. Screen Layout Improvements (Dark Mode / Glass) */
.weekly-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

body.weekly-focus-mode .weekly-container {
    max-width: none;
    padding: 12px 16px 16px;
}

body.weekly-focus-mode .weekly-scroll-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.weekly-scroll-area {
    position: relative;
    padding-bottom: var(--yearbook-scroll-end-buffer, 56px);
    scroll-padding-bottom: var(--yearbook-scroll-end-buffer, 56px);
}

body.weekly-focus-mode #print-theme-select {
    display: none !important;
}

.weekly-workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.weekly-workspace-leading,
.weekly-workspace-center,
.weekly-workspace-trailing {
    display: flex;
    align-items: center;
    gap: 12px;
}

.weekly-workspace-center {
    flex: 1;
    justify-content: center;
}

.weekly-workspace-trailing {
    justify-content: flex-end;
}

body.weekly-focus-mode .weekly-header {
    margin-bottom: 16px !important;
}

body.weekly-focus-mode .weekly-controls {
    gap: 12px !important;
    padding: 12px 18px !important;
    margin-bottom: 14px !important;
    flex-wrap: wrap;
}

body.weekly-focus-mode .weekly-controls > div:first-child {
    display: flex;
    align-items: center;
    gap: 12px !important;
    flex-wrap: wrap;
}

body.weekly-focus-mode .weekly-controls .export-group {
    margin-left: auto;
}

@media screen and (max-width: 1024px) {
    .weekly-workspace-center {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }

    .weekly-workspace-trailing {
        margin-left: auto;
    }
}

@media screen and (max-width: 768px) {
    body.weekly-focus-mode .weekly-container {
        padding: 10px;
    }

    body.weekly-focus-mode .weekly-controls .export-group {
        margin-left: 0;
    }
}

.weekly-header-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.weekly-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 8px;
    /* High-end gap between cards */
    table-layout: fixed;
}

.weekly-table th {
    padding: 12px;
    font-family: var(--font-display);
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

@media screen {
    .weekly-row-header th.weekly-left-axis-header {
        position: relative;
        padding-top: 30px;
        text-align: left;
        vertical-align: top;
    }

    .weekly-row-header th.weekly-left-axis-header::before {
        content: attr(data-month-label);
        position: absolute;
        top: 10px;
        left: 12px;
        color: var(--accent-neon, #67e8f9);
        font-size: 0.72rem;
        font-weight: 800;
        letter-spacing: 0.2px;
        line-height: 1;
        text-transform: none;
    }
}

.weekly-table td {
    padding: 0;
    /* Let .cell-card handle padding */
    vertical-align: top;
    background: transparent !important;
    /* Override standard table styles */
    border: none !important;
}

.weekly-cell-off {
    background: rgba(148, 163, 184, 0.05) !important;
    border: 1px dashed rgba(148, 163, 184, 0.2) !important;
}

.cell-empty-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 78px;
    border-radius: 10px;
    border: 1px dashed rgba(148, 163, 184, 0.25);
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.cell-empty-placeholder.muted {
    min-height: 48px;
    border-style: dotted;
    opacity: 0.55;
}

#weekly-events-list {
    white-space: pre-line;
    line-height: 1.35;
}

/* The Card inside a cell */
.cell-card {
    background: var(--weekly-card-bg);
    border: var(--weekly-card-border);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 12px;
    height: 100%;
    min-height: 100px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cell-card:hover {
    transform: translateY(-4px);
    background: var(--weekly-hover-bg);
    border-color: var(--accent-neon);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.weekly-table td.drag-over .cell-card {
    background: rgba(129, 140, 248, 0.2);
    border: 2px dashed var(--accent-neon);
    transform: scale(1.02);
}

.weekly-table td.dragging {
    opacity: 0.4;
}

/* Content Elements */
.cell-sub-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.cell-subject-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
}

.cell-period-text {
    font-size: 0.65rem;
    font-weight: 600;
    color: #64748b;
}

.cell-unit {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent-neon);
    opacity: 0.8;
}

.cell-topic {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    color: #f1f5f9;
}

.cell-location {
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.25;
    color: #93c5fd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-pages {
    margin-top: auto;
    font-size: 0.7rem;
    color: #10b981;
    /* Success Green for pages */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cell-pages::before {
    content: '📖';
    font-size: 0.8rem;
}

/* Jeondam Stripe */
.jeondam-card {
    border-left: 4px solid var(--accent-neon);
}

/* Event/Fixed Badge */
.lock-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.7rem;
    opacity: 0.6;
}

/* Remarks & Supplies Section Styling (Screen) */
.weekly-remark-card,
.weekly-supplies-card {
    margin-top: 24px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
}

.weekly-supplies-card {
    margin-top: 16px;
    background: rgba(129, 140, 248, 0.05);
    border-color: rgba(129, 140, 248, 0.2);
}

.weekly-remark-label,
.weekly-supplies-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.weekly-supplies-label {
    color: var(--accent);
}

/* Print Only Header */
#print-only-container {
    display: none;
}

/* =========================================
   A4 PRINTING STYLES (Portrait)
   ========================================= */
@media print {
    @page {
        size: A4 portrait;
        margin: 7mm;
    }

    body {
        margin: 0;
        padding: 0;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        background: white;
        width: 100%;
        height: 100%;
    }

    /* Surgical Hide: Only UI elements, preserve theme containers */
    .top-nav,
    .left-sidebar,
    .stats-sidebar,
    .floating-actions,
    .nav-tabs,
    .weekly-header-actions,
    .weekly-nav-header,
    .weekly-nav,
    /* Hide Arrows (< >) and date range in header */
    .weekly-controls,
    .footer-stats,
    .modal,
    .btn-floating,
    .fab-container,
    .ai-chat-btn,
    .theme-switcher-float,
    #theme-switch-container,
    #toast-container,
    #loading-overlay,
    .modal-backdrop,
    .modal-overlay,
    #modal-overlay,
    #yearbook-backup-modal-backdrop,
    /* Hide AI Chat and Floating UI */
    #current-week-title {
        display: none !important;
    }

    /* Print isolation: render only weekly printable block to avoid hidden overlays/z-index collisions */
    body.print-isolation-weekly .app-container * {
        visibility: hidden !important;
    }

    body.print-isolation-weekly .weekly-printable-area,
    body.print-isolation-weekly .weekly-printable-area * {
        visibility: visible !important;
    }

    /* Layout Reset: Kill all parent containers backgrounds/borders/shadows */
    .app-container,
    .main-content,
    #weekly-view-container,
    .weekly-container {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: none !important;
        background-color: transparent !important;
        box-shadow: none !important;
        border: none !important;
        display: block !important;
        overflow: visible !important;
    }

    .weekly-scroll-area {
        overflow: visible !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .weekly-printable-area {
        width: 100% !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box;
        background: #ffffff !important;
    }

    /* Baseline print palette (standard/fancy): force high contrast */
    html,
    body {
        background: #ffffff !important;
        color: #111827 !important;
    }

    body[class*="print-theme-"] .weekly-printable-area {
        color: #111827 !important;
    }

    body[class*="print-theme-"] .weekly-printable-area * {
        color: inherit !important;
        -webkit-text-fill-color: currentColor !important;
        opacity: 1 !important;
        text-shadow: none !important;
    }

    #print-only-title {
        color: #111827 !important;
        text-shadow: none !important;
        background: #ffffff !important;
    }

    .weekly-table {
        background: #ffffff !important;
        border: 1.5px solid #111827 !important;
        border-collapse: collapse !important;
        border-spacing: 0 !important;
    }

    .weekly-table th {
        background: #f8fafc !important;
        color: #111827 !important;
        border: 1px solid #cbd5e1 !important;
    }

    .weekly-table td {
        background: #ffffff !important;
        color: #111827 !important;
        border: 1px solid #cbd5e1 !important;
    }

    .weekly-row-event th,
    .weekly-row-header th,
    .weekly-row-footer th {
        background: #f1f5f9 !important;
        color: #111827 !important;
    }

    .cell-card {
        background: #ffffff !important;
        border: 1px solid #dbe3ef !important;
        box-shadow: none !important;
        color: #111827 !important;
    }

    .weekly-remark-card,
    .weekly-supplies-card {
        background: #ffffff !important;
        border: 1px solid #dbe3ef !important;
    }

    .cell-subject-badge {
        background: #f8fafc !important;
        border: 1px solid #cbd5e1 !important;
        color: #0f172a !important;
    }

    .cell-topic,
    .cell-unit,
    .cell-location,
    .cell-pages,
    .weekly-materials,
    #weekly-events-list,
    #weekly-remark-text,
    #weekly-supplies-text {
        color: #111827 !important;
        -webkit-text-fill-color: #111827 !important;
        opacity: 1 !important;
    }

    .cell-empty-placeholder {
        min-height: 52px;
        color: #64748b !important;
        border-color: #cbd5e1 !important;
        background: #f8fafc !important;
    }

    .weekly-cell-off .cell-empty-placeholder {
        min-height: 34px;
        opacity: 0.7;
    }

    /* Print Header */
    #print-only-container {
        display: block !important;
        text-align: center;
        margin-bottom: 25px;
    }

    /* Common Cell/Badge Resets */
    .cell-period-text,
    .lock-badge,
    .cell-tags {
        display: none !important;
    }

    .eval-inline-badge {
        background: #fffbeb !important;
        border: 1.5px solid #fcd34d !important;
        color: #b45309 !important;
        border-radius: 6px !important;
        padding: 2px 8px !important;
        font-size: 8.5pt !important;
        font-weight: 900 !important;
        display: inline-flex !important;
        align-items: center;
        gap: 3px;
        box-shadow: none !important;
    }

    body.print-theme-nature-forest .weekly-printable-area,
    body.print-theme-nature .weekly-printable-area {
        background: linear-gradient(180deg, #dcfce7 0%, #f0fdf4 25%, #ffffff 80%, #dcfce7 100%) !important;
    }

    body.print-theme-nature-ocean .weekly-printable-area {
        background: linear-gradient(180deg, #dbeafe 0%, #eff6ff 25%, #ffffff 80%, #dbeafe 100%) !important;
    }

    body.print-theme-nature-sunset .weekly-printable-area {
        background: linear-gradient(180deg, #ffedd5 0%, #fff7ed 25%, #ffffff 80%, #ffedd5 100%) !important;
    }

    body.print-theme-nature-lavender .weekly-printable-area {
        background: linear-gradient(180deg, #f5f3ff 0%, #faf5ff 25%, #ffffff 80%, #f5f3ff 100%) !important;
    }

    body.print-theme-nature-clay .weekly-printable-area {
        background: linear-gradient(180deg, #fef3c7 0%, #fffbeb 25%, #ffffff 80%, #fef3c7 100%) !important;
    }

    body.print-theme-nature-forest #print-only-title,
    body.print-theme-nature #print-only-title {
        background: white !important;
        border-radius: 50px !important;
        padding: 8px 30px !important;
        display: inline-block !important;
        box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2) !important;
        color: #059669 !important;
        font-family: 'Nanum Pen Script', 'Jua', cursive !important;
        border: 3px solid #d1fae5 !important;
        font-size: 24pt !important;
        font-weight: bold !important;
        white-space: nowrap !important;
        max-width: 95% !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.print-theme-nature-ocean #print-only-title {
        box-shadow: 0 4px 15px rgba(14, 165, 233, 0.2) !important;
        color: #0284c7 !important;
        border: 3px solid #e0f2fe !important;
    }

    body.print-theme-nature-sunset #print-only-title {
        box-shadow: 0 4px 15px rgba(249, 115, 22, 0.2) !important;
        color: #ea580c !important;
        border: 3px solid #ffedd5 !important;
    }

    body.print-theme-nature-lavender #print-only-title {
        box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2) !important;
        color: #7c3aed !important;
        border: 3px solid #f3e8ff !important;
    }

    body.print-theme-nature-clay #print-only-title {
        box-shadow: 0 4px 15px rgba(217, 119, 6, 0.2) !important;
        color: #d97706 !important;
        border: 3px solid #fef3c7 !important;
    }

    body.print-theme-nature .weekly-table {
        border-collapse: separate !important;
        border-spacing: 6px !important;
        width: 100% !important;
    }

    body.print-theme-nature .weekly-table th {
        background: #0ea5e9 !important;
        color: white !important;
        border: none !important;
        font-family: 'Jua', sans-serif !important;
        font-size: 14pt !important;
        padding: 12px !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 0 #0284c7 !important;
    }

    body.print-theme-nature .weekly-table th:first-child {
        border-radius: 12px 0 0 0;
    }

    body.print-theme-nature .weekly-table th:last-child {
        border-radius: 0 12px 0 0;
    }

    body.print-theme-nature .weekly-table td {
        background: rgba(255, 255, 255, 0.8) !important;
        border-radius: 10px !important;
        padding: 8px !important;
        border-bottom: 2px dotted #bae6fd !important;
        vertical-align: middle;
    }

    body.print-theme-nature .cell-card {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column;
        gap: 4px;
        min-height: auto !important;
    }

    body.print-theme-nature-forest .cell-subject-badge,
    body.print-theme-nature .cell-subject-badge {
        background: #f0fdf4 !important;
        color: #15803d !important;
        font-family: 'Nanum Pen Script', cursive !important;
        font-size: 13pt !important;
        padding: 2px 10px !important;
        border-radius: 8px !important;
        font-weight: bold;
    }

    body.print-theme-nature-ocean .cell-subject-badge {
        background: #f0f9ff !important;
        color: #0369a1 !important;
    }

    body.print-theme-nature-sunset .cell-subject-badge {
        background: #fff7ed !important;
        color: #c2410c !important;
    }

    body.print-theme-nature-lavender .cell-subject-badge {
        background: #f5f3ff !important;
        color: #6d28d9 !important;
    }

    body.print-theme-nature-clay .cell-subject-badge {
        background: #fffbeb !important;
        color: #b45309 !important;
    }

    body.print-theme-nature .cell-topic {
        font-size: 10.5pt !important;
        color: #000 !important;
        font-weight: 800 !important;
        line-height: 1.35;
    }

    body.print-theme-nature .cell-unit {
        font-size: 8.5pt !important;
        color: #475569 !important;
        font-weight: 700;
    }

    body.print-theme-nature .cell-location {
        font-size: 8.5pt !important;
        color: #1d4ed8 !important;
        font-weight: 700;
        line-height: 1.25;
    }

    body.print-theme-nature .cell-pages {
        font-size: 9pt !important;
        color: #166534 !important;
        font-weight: 600;
        margin-top: 2px;
    }

    /* Nature Footer Sign Restoration */
    [class*="print-theme-nature"] .footer-news-card {
        margin-top: 15px !important;
        background: rgba(255, 255, 255, 0.8) !important;
        border: 2.5px solid currentColor !important;
        border-radius: 14px !important;
        box-shadow: 0 4px 0 rgba(0, 0, 0, 0.05) !important;
        display: flex;
        overflow: hidden;
    }

    body.print-theme-nature-forest .footer-news-card,
    body.print-theme-nature .footer-news-card {
        color: #166534 !important;
        border-color: #86efac !important;
    }

    body.print-theme-nature-ocean .footer-news-card {
        color: #075985 !important;
        border-color: #7dd3fc !important;
    }

    body.print-theme-nature-sunset .footer-news-card {
        color: #9a3412 !important;
        border-color: #fdba74 !important;
    }

    body.print-theme-nature-lavender .footer-news-card {
        color: #5b21b6 !important;
        border-color: #c4b5fd !important;
    }

    body.print-theme-nature-clay .footer-news-card {
        color: #78350f !important;
        border-color: #fcd34d !important;
    }

    [class*="print-theme-nature"] .footer-news-card .label-section {
        background: currentColor !important;
        color: white !important;
        width: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        font-weight: 900;
        padding: 8px;
        border-right: 2px dashed rgba(255, 255, 255, 0.3);
        font-size: 11pt;
        letter-spacing: 1px;
    }

    [class*="print-theme-nature"] .footer-news-card .content-section {
        padding: 12px;
        flex: 1;
        color: #000 !important;
        font-family: 'Nanum Pen Script', 'Inter', cursive;
        font-size: 14pt;
        font-weight: 800;
        line-height: 1.4;
    }

    /* Nature Supplies Card Styling - Horizontal Label */
    [class*="print-theme-nature"] .weekly-supplies-card {
        margin-top: 10px !important;
        background: rgba(255, 255, 255, 0.8) !important;
        border: 2.5px solid currentColor !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 0 rgba(0, 0, 0, 0.05) !important;
        display: flex !important;
        align-items: stretch;
        overflow: hidden;
    }

    body.print-theme-nature-forest .weekly-supplies-card,
    body.print-theme-nature .weekly-supplies-card {
        color: #15803d !important;
        border-color: #86efac !important;
    }

    body.print-theme-nature-ocean .weekly-supplies-card {
        color: #1d4ed8 !important;
        border-color: #93c5fd !important;
    }

    body.print-theme-nature-sunset .weekly-supplies-card {
        color: #c2410c !important;
        border-color: #fdba74 !important;
    }

    body.print-theme-nature-lavender .weekly-supplies-card {
        color: #6d28d9 !important;
        border-color: #c4b5fd !important;
    }

    body.print-theme-nature-clay .weekly-supplies-card {
        color: #92400e !important;
        border-color: #fcd34d !important;
    }

    [class*="print-theme-nature"] .weekly-supplies-label {
        background: currentColor !important;
        color: white !important;
        min-width: 80px;
        width: 80px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        font-weight: 900;
        padding: 5px;
        border-right: 2px dashed rgba(255, 255, 255, 0.3);
        font-size: 11pt;
        letter-spacing: 0.5px;
        margin-bottom: 0 !important;
        writing-mode: horizontal-tb;
    }

    [class*="print-theme-nature"] .weekly-supplies-text {
        padding: 10px 15px;
        flex: 1;
        color: #000 !important;
        font-family: 'Nanum Pen Script', 'Inter', cursive;
        font-size: 14pt;
        font-weight: 800;
        line-height: 1.3;
    }

    /* Strict A4 Optimization */
    body.print-compact-a4 .weekly-table td {
        padding: 4px 8px !important;
    }

    body.print-compact-a4 .cell-topic {
        font-size: 10pt !important;
        line-height: 1.2 !important;
    }

    body.print-compact-a4 .cell-location {
        font-size: 8pt !important;
        line-height: 1.15 !important;
    }

    body.print-compact-a4 .cell-card {
        min-height: 72px !important;
    }

    body.print-compact-a4 .footer-news-card,
    body.print-compact-a4 .weekly-supplies-card {
        margin-top: 8px !important;
    }
}
