/* ==========================================================================
   Teacher Diary - Core Styles
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Poppins:wght@400;500;600&display=swap');

:root {
    --bg-app: #f8fafc;
    --text-main: #1e293b;
    --radius: 16px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.td-wrapper {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    max-width: 100%;
}

/* --- WEB HEADER --- */
.td-main-header {
    background: white; padding: 20px 5px; border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 30px; border-left: 6px solid #6366f1;
    position: relative; padding-right: 60px;
}
.td-page-title { font-family: 'Nunito', sans-serif; font-size: 1.6rem; font-weight: 800; color: #334155; margin: 0; }
.td-page-tagline { font-size: 0.95rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; margin-top: 5px; display: flex; gap: 10px; align-items: center; }

/* --- SETTINGS MENU --- */
.td-settings-container { position: absolute; top: 20px; right: 20px; z-index: 100; }
.td-settings-btn {
    width: 40px; height: 40px; background: #f1f5f9; border: none; border-radius: 50%;
    cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; transition: 0.2s; color: #475569;
}
.td-settings-btn:hover { background: #e2e8f0; transform: rotate(45deg); }
.td-settings-menu {
    position: absolute; top: 50px; right: 0; width: 220px; background: white; border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.15); border: 1px solid #e2e8f0; padding: 10px;
    display: none; z-index: 200;
}
.td-settings-menu.active { display: block; }
.td-menu-item, .td-menu-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: none; background: transparent;
    text-align: left; font-size: 0.9rem; font-weight: 600; color: #475569; border-radius: 8px; cursor: pointer;
}
.td-menu-item:hover { background: #f8fafc; color: #0f172a; }

/* --- CARDS & THEMES --- */
.td-card {
    --t-bg: #fff; --t-border: #e2e8f0; --t-head: #f8fafc; --t-prim: #64748b;
    background: var(--t-bg); border: 1px solid var(--t-border); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 30px; overflow: hidden; break-inside: avoid;
}
.td-card[data-theme="0"] { --t-bg: #eff6ff; --t-border: #bfdbfe; --t-head: #dbeafe; --t-prim: #2563eb; }
.td-card[data-theme="1"] { --t-bg: #f0fdf4; --t-border: #bbf7d0; --t-head: #dcfce7; --t-prim: #16a34a; }
.td-card[data-theme="2"] { --t-bg: #fffbeb; --t-border: #fde68a; --t-head: #fef3c7; --t-prim: #d97706; }
.td-card[data-theme="3"] { --t-bg: #faf5ff; --t-border: #e9d5ff; --t-head: #f3e8ff; --t-prim: #9333ea; }
.td-card[data-theme="4"] { --t-bg: #fff1f2; --t-border: #fecdd3; --t-head: #ffe4e6; --t-prim: #e11d48; }

.td-head { background: var(--t-head); padding: 15px 25px; border-bottom: 1px solid var(--t-border); }
.td-topic { font-family: 'Nunito', sans-serif; font-size: 1.35rem; font-weight: 800; color: var(--t-prim); }

/* --- GRID SYSTEM --- */
.td-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; padding: 20px 25px; }
.td-box { background: white; border: 1px solid rgba(0,0,0,0.05); padding: 15px; border-radius: 12px; }
.td-label { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; color: #94a3b8; margin-bottom: 6px; }
.td-val { font-size: 1rem; font-weight: 500; color: #334155; line-height: 1.4; }

/* Special Boxes */
.box-joy { background: #fff7ed; border: 2px solid #ffedd5; }
.box-joy .td-label { color: #ea580c; }
.box-tlm { background: #f0f9ff; border: 2px dashed #bae6fd; }
.box-tlm .td-label { color: #0284c7; }

/* --- CONTENT --- */
.td-content { padding: 5px 25px 25px; }
.td-h3 { font-family: 'Nunito', sans-serif; font-size: 1.15rem; font-weight: 800; color: var(--t-prim); margin: 20px 0 10px; border-left: 4px solid var(--t-prim); padding-left: 10px; }
.td-p { margin-bottom: 10px; line-height: 1.6; color: #475569; }
.td-list li { margin-bottom: 6px; list-style: none; position: relative; padding-left: 18px; }
.td-list li::before { content: '•'; color: var(--t-prim); font-weight: bold; position: absolute; left: 0; font-size: 1.2rem; }
.td-qa { background: white; padding: 12px; border-radius: 8px; margin-bottom: 10px; border-left: 3px solid var(--t-prim); }
.td-ans { display: none; color: #dc2626; font-weight: 700; background: #fee2e2; padding: 0 6px; border-radius: 4px; }
.show-answers .td-ans { display: inline; }

/* --- NOTES --- */
.td-notes { margin-top: 25px; border-top: 2px dashed var(--t-border); padding-top: 20px; }
.td-note-item { background: #fffbeb; padding: 12px; border-radius: 8px; margin-bottom: 8px; border: 1px solid #fcd34d; font-family: 'Nunito', sans-serif;}
.td-btn-add { width: 100%; padding: 12px; background: rgba(255,255,255,0.6); border: 2px dashed var(--t-prim); color: var(--t-prim); border-radius: 8px; font-weight: 700; cursor: pointer; }

/* ==========================================================================
   PRINT LAYOUT (Logic for Headers/Footers & Summary)
   ========================================================================== */

/* Hide Print Elements on Screen */
#td-print-summary, .print-header-fixed, .print-footer-fixed { display: none; }

@media print {
    /* 1. PAGE SETUP */
    @page { margin: 0; size: auto; } /* Remove browser defaults */
    
    body {
        margin: 0;
        padding-top: 70px !important;    /* Space for Header */
        padding-bottom: 50px !important; /* Space for Footer */
        padding-left: 15px !important;
        padding-right: 15px !important;
        background: white !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* 2. HIDE SCREEN ELEMENTS */
    .td-main-header, .td-settings-container, .td-dash-container, 
    .site-header, #masthead, footer, .site-footer, .td-btn-add, .td-del-note {
        display: none !important;
    }

    /* 3. REPEATING FIXED HEADER */
    .print-header-fixed {
        display: flex !important; justify-content: space-between; align-items: center;
        position: fixed; top: 0; left: 0; right: 0;
        height: 40px; padding: 0 20px;
        border-bottom: 2px solid #333; background: white; z-index: 9999;
        font-family: 'Nunito', sans-serif;
    }
    .ph-brand { font-size: 1.4rem; font-weight: 800; color: #ff9800; text-transform: uppercase; }
    .ph-meta { font-size: 0.9rem; font-weight: 600; color: #333; text-align: center; }
    .ph-date { font-size: 0.8rem; font-weight: 600; color: #666; }

    /* 4. REPEATING FIXED FOOTER */
    .print-footer-fixed {
        display: flex !important; justify-content: space-between; align-items: center;
        position: fixed; bottom: 0; left: 0; right: 0;
        height: 30px; padding: 0 20px;
        border-top: 1px solid #ccc; background: white; z-index: 9999;
        font-size: 0.8rem; color: #666; font-family: 'Poppins', sans-serif;
    }
    
    /* 5. SUMMARY TABLE (First Page) */
    #td-print-summary { display: block !important; margin-bottom: 25px; padding-top: 10px; }
    .td-print-table { width: 100%; border-collapse: collapse; font-family: 'Nunito', sans-serif; margin-top:10px; }
    .td-print-table th { background: #f1f5f9 !important; border: 1px solid #333; padding: 6px; font-size: 0.8rem; text-align: left; }
    .td-print-table td { border: 1px solid #333; padding: 6px; font-size: 0.85rem; vertical-align: top; }
    .print-summary-head { font-size: 1.1rem; font-weight: 800; text-align: center; text-transform: uppercase; color: #000; }

    /* 6. GRID & CONTENT ADJUSTMENTS */
    .td-wrapper { width: 100% !important; max-width: none !important; margin: 0 !important; }
    .td-grid { display: grid !important; grid-template-columns: repeat(3, 1fr) !important; gap: 10px !important; margin-bottom: 0 !important; padding: 0 !important;}
    .td-card { box-shadow: none !important; border: 1px solid #aaa !important; margin-bottom: 0 !important; background: white !important; padding-top: 40px;}
    .td-ans { display: inline !important; }
}