/* =====================================================================
   mylessonplans v2 — stylesheet
   Mobile-first, hand-rolled. Breakpoint: 700px.
   ===================================================================== */

/* ----- Custom properties -------------------------------------------- */
:root {
    --color-nav:          #2f3947;
    --color-nav-text:     #c1c4c8;
    --color-nav-active:   #eaebed;
    --color-accent:       #3274d6;
    --color-accent-dark:  #2868c7;
    --color-bg:           #f3f4f7;
    --color-card:         #ffffff;
    --color-text:         #333333;
    --color-text-muted:   #777777;
    --color-border:       #e0e2e7;
    --color-success:      #4caf50;
    --color-warning:      #f59e0b;
    --color-danger:       #e53e3e;
    --color-danger-dark:  #c53030;
    --color-period-empty: #f8f9fa;
    --radius:             6px;
    --shadow:             0 1px 4px rgba(0,0,0,0.10);
    --nav-height:         56px;
}

/* ----- Reset --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
                 Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.35rem; color: #4a536e; }
h3 { font-size: 1.1rem; color: #4a536e; }

p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }

/* ----- Nav ----------------------------------------------------------- */
.navtop {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-nav);
    height: var(--nav-height);
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.nav-inner {
    display: flex;
    align-items: center;
    height: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    gap: 8px;
}

.nav-brand {
    flex: 0 0 auto;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-nav-active);
    text-decoration: none;
    margin-right: 12px;
}
.nav-brand:hover { color: #fff; text-decoration: none; }

.nav-links {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2px;
    flex: 1;
}

.nav-links li a {
    display: block;
    padding: 6px 12px;
    color: var(--color-nav-text);
    font-size: .9rem;
    font-weight: 500;
    border-radius: var(--radius);
    text-decoration: none;
    white-space: nowrap;
}
.nav-links li a:hover     { color: var(--color-nav-active); background: rgba(255,255,255,.07); }
.nav-links li a.active    { color: var(--color-nav-active); background: rgba(255,255,255,.12); }

/* Year picker in nav */
.nav-year { margin-left: auto; }
.nav-year select {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: var(--color-nav-active);
    border-radius: var(--radius);
    padding: 4px 8px;
    font-size: .85rem;
    cursor: pointer;
}
.nav-year select:focus { outline: 2px solid var(--color-accent); }
.nav-year select option { background: var(--color-nav); }

/* Hamburger burger button — hidden on desktop */
.nav-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: auto;
}
.nav-burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-nav-text);
    border-radius: 2px;
    transition: background .2s;
}
.nav-burger:hover span { background: var(--color-nav-active); }

/* ----- Content area -------------------------------------------------- */
.content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

body.guest {
    background: var(--color-nav);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
body.guest .content { display: none; } /* guest pages handle their own layout */

/* ----- Flash messages ------------------------------------------------ */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
}
.flash-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.flash-error   { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.flash-warning { background: #fff8e1; color: #e65100; border: 1px solid #ffe082; }

/* ----- Cards --------------------------------------------------------- */
.card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.card--flush  { padding: 0; overflow: hidden; }
.card--urgent { border-left: 4px solid var(--color-warning); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--color-border); }
.card-header h3 { margin: 0; }

/* ----- Buttons ------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-card);
    color: var(--color-text);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #f0f1f4; text-decoration: none; }

.btn-primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}
.btn-primary:hover { background: var(--color-accent-dark); border-color: var(--color-accent-dark); color: #fff; }

.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}
.btn-danger:hover { background: var(--color-danger-dark); border-color: var(--color-danger-dark); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn-today-active { background: rgba(50,116,214,.12); border-color: var(--color-accent); color: var(--color-accent); }

/* ----- Page header --------------------------------------------------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-header h2 { margin: 0; }
.page-header h3 { margin: 4px 0 0; font-size: 1rem; font-weight: 400; color: var(--color-text-muted); }

/* ----- Date navigation ---------------------------------------------- */
.date-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ----- Timetable — desktop table ------------------------------------ */
.timetable-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}
.timetable-table th,
.timetable-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    text-align: left;
}
.timetable-table th {
    background: #f5f6f9;
    font-size: .82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-text-muted);
}
.timetable-table tbody tr:last-child td { border-bottom: none; }
.timetable-table tbody tr:hover td { background: #fafbfc; }

.col-period { width: 80px; text-align: center; font-weight: 600; color: var(--color-text-muted); }
.col-class  { width: 110px; }
.col-title  { }

.col-empty {
    background: #f0f1f4;
    padding: 8px 14px;
    text-align: center;
}

.schedule-link {
    color: #b8bcc6;
    font-size: .9rem;
    text-decoration: none;
    transition: color .15s;
}
.schedule-link:hover { color: var(--color-accent); text-decoration: none; }

/* ----- Timetable — mobile cards ------------------------------------ */
.timetable-cards { display: none; list-style: none; margin: 0; padding: 0; }

.period-card {
    display: flex;
    align-items: center;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 8px;
    overflow: hidden;
    min-height: 56px;
}

.period-label {
    flex: 0 0 64px;
    text-align: center;
    font-weight: 700;
    font-size: .85rem;
    color: var(--color-text-muted);
    background: #f5f6f9;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--color-border);
}

.period-card-inner {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    text-decoration: none;
    color: var(--color-text);
}
.period-card-inner:hover { background: #fafbfc; text-decoration: none; }

.period-title { font-size: .95rem; }

.period-card--empty .period-card-inner { color: var(--color-text-muted); font-size: .875rem; opacity: .7; }

/* ----- Class chip --------------------------------------------------- */
.class-chip {
    display: inline-block;
    background: var(--color-accent);
    color: #fff;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
}
.class-chip:hover { background: var(--color-accent-dark); color: #fff; text-decoration: none; }
.class-chip--activity { background: #7c5cbf; }
.class-chip--activity:hover { background: #6a4daa; }

/* ----- Lesson editor ------------------------------------------------ */
.save-banner {
    position: sticky;
    top: var(--nav-height);
    z-index: 90;
    background: var(--color-success);
    color: #fff;
    text-align: center;
    padding: 8px;
    font-size: .9rem;
    font-weight: 500;
}
.save-banner--err { background: var(--color-danger); }

.lesson-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.nav-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.lesson-editor { padding: 0; }

.lesson-title-input {
    display: block;
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-bottom: 1px solid var(--color-border);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-text);
    background: transparent;
    outline: none;
}
.lesson-title-input:focus { border-bottom-color: var(--color-accent); }

.lesson-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.class-links {
    padding: 12px 18px;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: .9rem;
    color: var(--color-text-muted);
}
.class-links strong { color: var(--color-text); }

/* ----- Forms -------------------------------------------------------- */
.form-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}
.form-row label {
    font-size: .85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row input[type="url"],
.form-row select,
.form-row textarea {
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .95rem;
    color: var(--color-text);
    background: #fff;
    transition: border-color .15s;
    width: 100%;
    max-width: 480px;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(50,116,214,.15);
}
.form-row.readonly { flex-direction: row; align-items: baseline; gap: 12px; }
.form-row.readonly label { min-width: 140px; margin: 0; }
.form-row.readonly span  { color: var(--color-text-muted); }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.form-section-label {
    font-size: .85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    margin-top: 4px;
}

.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
    align-items: center;
}
.inline-form input {
    padding: 7px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .9rem;
    flex: 1;
    min-width: 160px;
}
.inline-form input:focus { outline: none; border-color: var(--color-accent); }

.field-hint {
    font-size: .8rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.form-msg {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .9rem;
}
.form-msg-error   { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.form-msg-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }

/* ----- Auth pages --------------------------------------------------- */
.auth-wrap {
    width: 100%;
    max-width: 440px;
    padding: 16px;
}
.auth-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,.2);
    padding: 32px;
}
.auth-box h1 {
    text-align: center;
    font-size: 1.6rem;
    color: var(--color-nav);
    margin-bottom: 20px;
}
.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 24px;
}
.auth-tabs a {
    flex: 1;
    text-align: center;
    padding: 8px;
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.auth-tabs a.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}
.auth-tabs a:hover { color: var(--color-accent); text-decoration: none; }

.field-group {
    display: flex;
    margin-bottom: 14px;
}
.field-group label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    background: var(--color-accent);
    color: #fff;
    border-radius: var(--radius) 0 0 var(--radius);
    flex-shrink: 0;
}
.field-group input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: .95rem;
}
.field-group input:focus { outline: none; border-color: var(--color-accent); }

.auth-box select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .95rem;
    margin-bottom: 14px;
    background: #fff;
}
.auth-box select:focus { outline: none; border-color: var(--color-accent); }

.remember-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .875rem;
    color: var(--color-text-muted);
    margin-bottom: 16px;
    cursor: pointer;
}
.auth-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: .85rem;
    color: var(--color-text-muted);
}
.auth-link:hover { color: var(--color-accent); }

/* ----- Data tables -------------------------------------------------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th,
.data-table td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: .9rem;
}
.data-table th {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    background: #f5f6f9;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #fafbfc; }

.row-actions {
    text-align: right;
    white-space: nowrap;
    width: 1px;
}
.nowrap  { white-space: nowrap; }
.muted   { color: var(--color-text-muted); }
.preview-text { color: var(--color-text-muted); font-size: .85rem; }

/* ----- Badges ------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-accent  { background: #e3f0ff; color: var(--color-accent); }
.badge-warning { background: #fff3cd; color: #92400e; }
.badge-muted   { background: #f0f1f4; color: var(--color-text-muted); }

/* Info card (no-action state) */
.info-card { display: flex; align-items: center; gap: 10px; color: var(--color-text-muted); }
.info-card__icon { font-size: 1.2rem; color: var(--color-success); }

/* ----- Empty state -------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-muted);
}
.empty-state p    { font-size: 1.05rem; margin-bottom: 16px; }
.empty-state .btn { margin: 0 auto; }

/* ----- Weekly timetable editor -------------------------------------- */
.tt-week {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 20px;
}

.tt-week-title {
    margin: 0 0 12px;
    font-size: 1rem;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
}

.tt-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    background: var(--color-border);
    border-radius: var(--radius);
    table-layout: fixed;
    overflow: hidden;
}

.tt-table th,
.tt-table td {
    background: var(--color-card);
    padding: 4px;
    text-align: center;
    vertical-align: middle;
    font-size: .8rem;
    height: 42px;
}

.tt-table thead th {
    background: #f5f6f9;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: .75rem;
    letter-spacing: .04em;
    font-weight: 700;
    height: 27px;
}

.tt-table th.tt-corner {
    background: #f5f6f9;
    width: 45px;
}

.tt-table th.tt-period {
    background: #f5f6f9;
    color: var(--color-text-muted);
    font-weight: 700;
    width: 45px;
    font-size: .8rem;
    text-transform: none;
}

.tt-table td.tt-empty {
    background: #f8f9fb;
    transition: background .15s;
    padding: 0;
}
.tt-table td.tt-empty:hover { background: #eaf1fb; }

.tt-add-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 33px;
    color: #c0c4ce;
    font-size: .85rem;
    text-decoration: none;
    transition: color .15s, background .15s;
}
.tt-add-link:hover { color: var(--color-accent); text-decoration: none; }

.tt-table td.tt-filled { padding: 3px; }

.tt-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    height: 100%;
    min-height: 36px;
    padding: 4px 3px;
    border-radius: 4px;
    background: linear-gradient(135deg, #e3f0ff 0%, #c8e0ff 100%);
    border: 1px solid #b6d4ff;
    text-decoration: none;
    color: var(--color-text);
    transition: filter .15s;
    box-sizing: border-box;
}
.tt-entry:hover { filter: brightness(0.96); text-decoration: none; }

.tt-entry .class-chip { background: var(--color-accent); }

.tt-dur {
    font-size: .7rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

.delete-form { margin-top: 12px; }

/* Mobile per-day cards — hidden on desktop */
.tt-mobile { display: none; }
.tt-day-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
}
.tt-day-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f5f6f9;
    border-bottom: 1px solid var(--color-border);
}
.tt-day-card__empty {
    padding: 12px 14px;
    font-size: .9rem;
    text-align: center;
}
.tt-day-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.tt-day-list li {
    border-bottom: 1px solid var(--color-border);
}
.tt-day-list li:last-child { border-bottom: none; }
.tt-day-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--color-text);
}
.tt-day-list a:hover { background: #fafbfc; text-decoration: none; }
.tt-day-list__period {
    font-weight: 700;
    color: var(--color-text-muted);
    font-size: .85rem;
    min-width: 56px;
}

/* ----- TinyMCE container -------------------------------------------- */
.lesson-editor .tox-tinymce {
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ----- Mobile (≤700px) ---------------------------------------------- */
@media (max-width: 700px) {
    /* Nav: show burger, collapse links */
    .nav-burger {
        display: flex;
        margin-left: auto;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--color-nav);
        flex-direction: column;
        align-items: stretch;
        padding: 8px 0 16px;
        box-shadow: 0 4px 12px rgba(0,0,0,.25);
        gap: 0;
    }
    .nav-links.open { display: flex; }
    .nav-links li a { border-radius: 0; padding: 10px 20px; }
    .nav-year { margin-left: 0; padding: 10px 20px; }
    .nav-year select { width: 100%; }

    /* Timetable: hide table, show cards */
    .timetable-table { display: none; }
    .timetable-cards { display: block; }

    /* Weekly timetable editor: hide grid, show per-day cards */
    .tt-week   { display: none; }
    .tt-mobile { display: block; }

    /* Lesson editor nav */
    .lesson-nav  { flex-direction: column; gap: 8px; }
    .lesson-actions { gap: 4px; }

    /* Content */
    .content { padding: 16px 12px 32px; }

    /* Page header: stack */
    .page-header { flex-direction: column; align-items: flex-start; }

    /* Forms: full width inputs */
    .form-row input,
    .form-row select,
    .form-row textarea { max-width: 100%; }

    .form-row.readonly { flex-direction: column; gap: 2px; }

    /* Inline form: stack */
    .inline-form { flex-direction: column; }
    .inline-form input { min-width: 0; }

    /* Cards */
    .card { padding: 16px; }

    /* Auth box */
    .auth-box { padding: 24px 20px; }
}

/* ----- Print --------------------------------------------------------- */
@media print {
    .navtop, .date-nav, .lesson-nav, .lesson-actions,
    .btn, .schedule-link, .save-banner { display: none !important; }
    .content { max-width: 100%; padding: 0; }
    .timetable-table, .timetable-cards { display: table !important; }
    .timetable-cards { display: none !important; }
}
