/* ==========================================================================
   Work Timetable Generator
   Design concept: a drafting table / graph-paper planner. The app chrome
   stays quiet and structural (hairline rules, no card shadows, restrained
   accent) so the colour-coded activities the user creates are the thing
   that stands out on the page - not the interface around them.
   ========================================================================== */

:root,
body[data-theme="light"] {
    --bg: #f7f6f2;
    --bg-raised: #ffffff;
    --ink: #21252b;
    --ink-soft: #5b6169;
    --rule: #dedad2;
    --rule-strong: #c8c3b8;
    --accent: #2b3a55;
    --accent-ink: #ffffff;
    --accent-soft: #e7eaf1;
    --danger: #a3402f;
    --danger-soft: #f6e6e2;
    --success: #33654a;
    --success-soft: #e4efe8;
    --grid-line: #e7e4dc;
    --header-bg: var(--accent);
    --header-ink: #ffffff;
}

body[data-theme="dark"] {
    --bg: #14171c;
    --bg-raised: #1b1f26;
    --ink: #e8e6e1;
    --ink-soft: #9aa0aa;
    --rule: #2b303a;
    --rule-strong: #3a404c;
    --accent: #8fa5d8;
    --accent-ink: #14171c;
    --accent-soft: #232a3a;
    --danger: #e0897a;
    --danger-soft: #3a2521;
    --success: #82c3a1;
    --success-soft: #1f2f27;
    --grid-line: #262b33;
    --header-bg: #0e1116;
    --header-ink: #e8e6e1;
}

body[data-theme="colorful"] {
    --bg: #fbf6ef;
    --bg-raised: #ffffff;
    --ink: #26232a;
    --ink-soft: #6a6270;
    --rule: #ecdfd0;
    --rule-strong: #ddc9ae;
    --accent: #e0603f;
    --accent-ink: #ffffff;
    --accent-soft: #fbe4da;
    --danger: #a3402f;
    --danger-soft: #f6e6e2;
    --success: #2f7a5c;
    --success-soft: #e1f0e7;
    --grid-line: #f0e3d3;
    --header-bg: linear-gradient(120deg, #2b3a55 0%, #5a3f6b 55%, #e0603f 100%);
    --header-ink: #ffffff;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 .5rem;
}

h1 { font-size: 1.3rem; }
h2 { font-size: 1.02rem; padding-bottom: .5rem; border-bottom: 1px solid var(--rule); margin-bottom: .9rem; }

a { color: var(--accent); }

code {
    background: var(--accent-soft);
    padding: .1rem .35rem;
    border-radius: 3px;
    font-size: .85em;
}

/* ---------------------------------- Header ---------------------------------- */

.app-header {
    background: var(--header-bg);
    color: var(--header-ink);
    padding: 1.1rem 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.app-header__title h1 { color: var(--header-ink); margin: 0; }
.app-header__subtitle { margin: .15rem 0 0; font-size: .8rem; opacity: .75; }

.timetable-switcher {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: rgba(255,255,255,.12);
    padding: .4rem .6rem;
    border-radius: 6px;
}
.timetable-switcher label { font-size: .78rem; opacity: .85; }
.timetable-switcher select {
    background: var(--bg-raised);
    color: var(--ink);
    border: none;
    border-radius: 4px;
    padding: .35rem .5rem;
}

.session-info {
    font-size: .8rem;
    opacity: .9;
    display: flex;
    align-items: center;
    gap: .6rem;
}
.session-info a {
    color: var(--header-ink);
    opacity: .85;
    text-decoration: underline;
}

/* ---------------------------------- Flash ---------------------------------- */

.flash {
    margin: 1rem 1.75rem 0;
    padding: .6rem 1rem;
    border-radius: 4px;
    font-size: .9rem;
    border: 1px solid var(--rule);
}
.flash--success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.flash--error   { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* ---------------------------------- Layout ---------------------------------- */

.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.25rem;
    padding: 1.25rem 1.75rem 3rem;
    align-items: start;
}

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
}

.sidebar { display: flex; flex-direction: column; gap: 1.25rem; }
.content { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }

.card {
    background: var(--bg-raised);
    border: 1px solid var(--rule);
    border-top: 3px solid var(--accent);
    padding: 1.1rem 1.2rem 1.3rem;
}

.card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--rule);
    margin-bottom: .9rem;
    padding-bottom: .5rem;
}
.card__header h2 { border: none; margin: 0; padding: 0; }

/* ---------------------------------- Forms ---------------------------------- */

.stack { display: flex; flex-direction: column; gap: .7rem; }
.row { display: flex; gap: .7rem; }
.row > label { flex: 1; }

label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    font-size: .82rem;
    color: var(--ink-soft);
}

input[type="text"],
input[type="time"],
select {
    font-family: inherit;
    font-size: .92rem;
    padding: .45rem .55rem;
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    background: var(--bg);
    color: var(--ink);
}

input[type="color"] {
    width: 100%;
    height: 2.2rem;
    padding: 2px;
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    background: var(--bg);
}

fieldset.day-picker {
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    padding: .6rem .6rem .5rem;
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .6rem;
}
fieldset.day-picker legend {
    font-size: .78rem;
    color: var(--ink-soft);
    padding: 0 .3rem;
}
.day-chip {
    flex-direction: row;
    align-items: center;
    gap: .3rem;
    font-size: .82rem;
    color: var(--ink);
}
.day-chip input { margin: 0; }

/* ---------------------------------- Buttons ---------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    padding: .5rem .9rem;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--secondary { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--small { padding: .3rem .6rem; font-size: .78rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.link-btn {
    background: none; border: none; padding: 0;
    color: var(--danger); font-size: .82rem; cursor: pointer; text-decoration: underline;
    font-family: inherit;
}

.export-buttons { display: flex; gap: .5rem; }

/* ---------------------------------- Activity table ---------------------------------- */

.activity-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.activity-table th {
    text-align: left;
    font-size: .74rem;
    text-transform: none;
    color: var(--ink-soft);
    padding: .4rem .5rem;
    border-bottom: 1px solid var(--rule-strong);
}
.activity-table td {
    padding: .5rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}
.activity-table__actions { display: flex; gap: .6rem; white-space: nowrap; }

.swatch {
    display: inline-block;
    width: .8rem; height: .8rem;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,.15);
}

.empty-state { color: var(--ink-soft); font-size: .9rem; padding: 1rem 0; }

/* ---------------------------------- Weekly grid ---------------------------------- */

.grid-scroll { overflow-x: auto; }

.timetable-grid {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    table-layout: fixed;
}

.timetable-grid th {
    background: var(--accent-soft);
    color: var(--ink);
    font-size: .78rem;
    padding: .5rem .4rem;
    border: 1px solid var(--grid-line);
}

.timetable-grid__time-col { width: 76px; font-variant-numeric: tabular-nums; }

.timetable-grid td.timetable-grid__cell {
    border: 1px solid var(--grid-line);
    padding: 3px;
    height: 46px;
    vertical-align: top;
}

.timetable-grid th.timetable-grid__time-col,
.timetable-grid tbody th {
    background: var(--bg);
    font-weight: 600;
    text-align: right;
    padding-right: .5rem;
    color: var(--ink-soft);
    font-size: .76rem;
}

.activity-block {
    border-radius: 3px;
    padding: .25rem .4rem;
    margin-bottom: 2px;
    font-size: .74rem;
    line-height: 1.25;
    color: #1c1c1c;
    overflow: hidden;
}
.activity-block strong { display: block; font-size: .76rem; }
.activity-block span { display: block; font-size: .68rem; opacity: .75; }

/* ---------------------------------- Footer ---------------------------------- */

.app-footer {
    text-align: center;
    color: var(--ink-soft);
    font-size: .78rem;
    padding: 1.5rem;
}

/* ---------------------------------- Login page ---------------------------------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-card {
    width: 100%;
    max-width: 360px;
}

/* ---------------------------------- User management page ---------------------------------- */

.user-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.user-table th {
    text-align: left;
    font-size: .74rem;
    color: var(--ink-soft);
    padding: .4rem .5rem;
    border-bottom: 1px solid var(--rule-strong);
}
.user-table td {
    padding: .5rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}
.role-badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 3px;
    background: var(--accent-soft);
    color: var(--accent);
}
.you-badge {
    font-size: .72rem;
    color: var(--ink-soft);
    margin-left: .3rem;
}
