/* --- CSS VARIABLES FOR THEME --- */
:root {
    /* Original Dark Mode Hex Codes - Blended with Scedu theme */
    --bg-main: #002e47;
    /* NEW MAIN BG */
    --bg-container: #003f72;
    /* NEW INNER BG */
    --bg-panel: #1a1a1a;
    /* Kept for modals/popups */
    --bg-element: #181818;
    /* Lessons */
    --bg-element-hover: #1f1f1f;
    --bg-break: #151515;
    --bg-close: #2a2a2a;
    --bg-empty: #0f0f0f;

    --text-primary: #ececec;
    --text-secondary: #999999;

    --border-color: #2a2a2a;
    --table-border: #222;

    --accent-color: #0066cc;
    --accent-hover: #0052a3;

    --edit-pool-bg: #1c2b42;
    --edit-pool-border: #004c99;

    --break-text: #ccc;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --modal-overlay: rgba(0, 0, 0, 0.85);
}

/* --- LIGHT MODE OVERRIDES --- */
body.light-mode {
    --bg-main: #f0f2f5;
    --bg-container: #ffffff;
    --bg-panel: #ffffff;
    --bg-element: #f7f9fa;
    --bg-element-hover: #eef2f5;
    --bg-break: #f0f2f5;
    --bg-empty: #fafafa;
    --bg-close: #e0e0e0;
    --text-primary: #1a1a1a;
    --text-secondary: #5f6368;
    --border-color: #dadce0;
    --table-border: #dadce0;
    --accent-color: #1a73e8;
    --accent-hover: #1765cc;
    --edit-pool-bg: #e8f0fe;
    --edit-pool-border: #1a73e8;
    --break-text: #5f6368;
    --shadow-color: rgba(0, 0, 0, 0.15);
    --modal-overlay: rgba(255, 255, 255, 0.9);
}

/* --- GLOBAL & BODY STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    user-select: none;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
    display: flex;
    margin: 0;
    height: 100vh;
}

/* --- NEW SCEDU SIDEBAR STYLES --- */
#sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background-color: var(--bg-main);
    box-sizing: border-box;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

#sidebar.closed {
    width: 0px;
}

#logo {
    color: white;
    font-size: 40px;
    user-select: none;
    margin: 10px;
    white-space: nowrap;
    transition: opacity 0.15s ease;
    font-family: "Old Standard TT";
}

#sidebar.closed #logo {
    opacity: 0;
}

#mini_calender {
    margin-left: 10px;
    width: calc(100% - 10px);
    background-color: var(--bg-container);
    height: 200px;
    border-radius: 15px;
    flex-shrink: 0;
    margin-bottom: 20px;
}

#sidebar_toggle {
    position: fixed;
    top: 10px;
    left: 210px;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-container);
    border: none;
    border-radius: 15px;
    height: 40px;
    width: 40px;
    cursor: pointer;
    padding: 0;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.1s ease;
}

#sidebar_toggle:hover {
    background-color: #00457d;
}

#sidebar_toggle.closed {
    left: 10px;
}

#sidebar_toggle svg {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar_toggle.closed svg {
    transform: scaleX(-1);
}

#main_area {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-container);
    flex: 1;
    margin: 10px;
    border-radius: 15px;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

/* --- SIDEBAR TOPBAR ITEMS (Moved from old .header) --- */
.sidebar-topbar-items {
    display: flex;
    flex-direction: column;
    padding: 0 15px;
    gap: 20px;
    opacity: 1;
    transition: opacity 0.15s ease;
    white-space: nowrap;
}

#sidebar.closed .sidebar-topbar-items {
    opacity: 0;
    pointer-events: none;
}

#acount_card {
    background-color: #003f72;
    padding: 7px;
    border-radius: 15px;
    margin: 0px
}

.header-title h1 {
    font-size: 0.9em;
    font-weight: 400;
    margin: 0;
    line-height: 1.2;
    color: var(--text-secondary)
}

.header-title h2 {
    font-size: 1.05em;
    color: var(--text-primary);
    font-weight: 400;
    margin: 0;
}

.info-bar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.compact-toggle {
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.compact-toggle .material-symbols-outlined {
    font-size: 24px;
}

.compact-toggle:hover {
    background: var(--bg-element-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.compact-toggle.active {
    background: var(--bg-element);
    color: var(--accent-color);
    border: 1px solid var(--border-color);
}

.unsaved-btn {
    display: none;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.unsaved-btn.save {
    color: #4caf50;
}

.unsaved-btn.save:hover {
    background: rgba(76, 175, 80, 0.15);
}

.unsaved-btn.revert {
    color: #f44336;
}

.unsaved-btn.revert:hover {
    background: rgba(244, 67, 54, 0.15);
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.lesson-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-radius: 8px;
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    height: 50px;
    transition: background 0.2s ease;
}

.lesson-box:hover {
    background: var(--bg-element-hover);
    border-color: var(--accent-color);
}

.lesson-name {
    font-size: 0.9em;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.lesson-countdown {
    font-size: 0.9em;
    color: var(--accent-color);
    margin-top: 1px;
    font-family: monospace;
    font-weight: 600;
}


/* --- DUAL TIMETABLE LAYOUT --- */
.dual-timetable-container {
    display: flex;
    flex-direction: row;
    padding: 20px;
    gap: 20px;
    flex: 1;
    overflow-x: auto;
    padding-top: 10px;
}

.week-column {
    flex: 1;
    min-width: 600px;
    display: flex;
    flex-direction: column;
}

.week-title {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 1.2em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.3s ease;
    padding: 5px 24px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: transparent;
}

.week-title.active-week {
    color: var(--accent-color);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 102, 204, 0.2);
    background: var(--bg-element);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(0, 102, 204, 0.15);
}

.week-content {
    flex: 1;
    display: block !important;
}

/* --- TABLE STYLES --- */
.timetable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    border-radius: 6px;
    overflow: visible;
    table-layout: fixed;
    height: 100%;
}

.timetable th,
.timetable td {
    padding: 12px 8px;
    text-align: center;
    border: 1px solid var(--table-border);
    border-top-width: 0;
    border-left-width: 0;
    vertical-align: middle;
    transition: background-color 0.15s ease;
}

.timetable th:first-child,
.timetable td:first-child {
    border-left-width: 1px;
}

.timetable tr:first-child th {
    border-top-width: 1px;
}

.timetable th {
    background: var(--bg-panel);
    color: var(--text-primary);
    padding: 14px 8px;
    font-weight: 500;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timetable thead tr:first-child th:first-child {
    border-top-left-radius: 6px;
}

.timetable thead tr:first-child th:last-child {
    border-top-right-radius: 6px;
}

.period-time .period-label-mobile {
    display: none;
}

.period-time .period-label-desktop {
    display: inline;
}

.timetable tbody tr:last-child td:first-child {
    border-bottom-left-radius: 6px;
}

.timetable tbody tr:last-child td:last-child {
    border-bottom-right-radius: 6px;
}

.timetable th.day-header {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.timetable th.day-header:hover {
    background: var(--border-color);
}

.period-time {
    background: var(--bg-panel);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.8em;
    width: 80px;
}

.subject {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9em;
}

.lesson {
    background: var(--bg-element);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.lesson:hover {
    background: var(--bg-element-hover);
}

.break {
    background: var(--bg-break);
    color: var(--break-text);
    font-weight: 500;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.break:hover {
    background: var(--bg-element-hover);
}

/* --- EDIT MODE OPACITY & TRANSITIONS --- */
.timetable td {
    transition: background-color 0.2s ease, opacity 0.3s ease, filter 0.3s ease;
}

body.edit-mode .break {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
    background: #000;
}

body.light-mode.edit-mode .break {
    background: #ddd;
}

.empty {
    background: var(--bg-empty);
    color: #444;
    font-style: italic;
}

body.light-mode .empty {
    color: #ccc;
}

.highlight-current {
    outline: 2px solid #0a8f08;
    outline-offset: -2px;
    background: #111f11;
}

.highlight-next {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
    background: #101924;
}

/* --- POPUP TRANSITIONS --- */
.lesson-popup {
    position: fixed;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 10px 40px var(--shadow-color);
    z-index: 10000;
    width: 320px;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
        top 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), left 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lesson-popup.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

@media (max-width: 768px) {
    .lesson-popup {
        width: calc(100vw - 40px);
        max-width: 360px;
        transition: opacity 0.2s ease;
        transform: translate(-50%, -50%);
        box-shadow: 0 10px 40px var(--shadow-color), 0 0 0 100vmax rgba(0, 0, 0, 0.5);
    }

    .lesson-popup.show {
        transform: translate(-50%, -50%);
    }
}

.lesson-popup-inner {
    transition: opacity 0.2s ease;
    opacity: 1;
}

.lesson-popup-inner.fading {
    opacity: 0;
}

.lesson-popup-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-close);
    color: var(--text-primary);
}

.lesson-popup-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.lesson-popup-title {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.lesson-popup-time {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.lesson-popup-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.lesson-popup-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.lesson-popup-label {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.lesson-popup-value {
    font-size: 0.95em;
    color: var(--text-primary);
    font-weight: 500;
}

.lesson-popup-actions {
    display: flex;
    gap: 10px;
}

.lesson-popup-btn:hover {
    background: #2f2f2f;
}

.lesson-popup-btn.edit {
    background: var(--accent-color);
    color: #fff;
}

.lesson-popup-btn.edit:hover {
    background: var(--accent-hover);
}

.lesson-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.lesson-popup-close:hover {
    background: var(--bg-close);
    color: var(--text-primary);
}

.popup-book-list-ul {
    list-style: none;
    padding: 0;
    margin: 5px 0 0 0;
}

.popup-book-list-ul li {
    font-size: 0.9em;
    margin-bottom: 6px;
    color: var(--text-primary);
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}

.popup-book-list-ul li:last-child {
    margin-bottom: 0;
}

/* --- MODAL STYLES --- */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-panel);
    padding: 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 500px;
    color: var(--text-primary);
    position: relative;
    text-align: center;
    box-shadow: 0 20px 60px var(--shadow-color);
    overflow: visible;
    max-height: none;
    margin: 40px auto;
}

.modal-content.wide-modal {
    width: 800px;
}

.modal-content h3 {
    margin-bottom: 24px;
    font-size: 1.6em;
    color: var(--text-primary);
    font-weight: 600;
}

.close-button {
    color: var(--text-secondary);
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 28px;
    font-weight: normal;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.close-button:hover {
    color: var(--text-primary);
    background: var(--bg-element);
}

/* --- BOOKS DISPLAY STYLES --- */
.books-dual-container {
    display: flex;
    justify-content: space-between;
    text-align: left;
    gap: 20px;
}

.books-dual-container.single-view .books-column-divider,
.books-dual-container.single-view .books-column.hidden-week {
    display: none;
}

.books-dual-container.single-view {
    justify-content: center;
}

.books-dual-container.single-view .books-column {
    flex: 0 0 100%;
}

.books-column {
    flex: 1;
    transition: all 0.3s ease;
}

.books-column h4 {
    margin-bottom: 15px;
    color: var(--accent-color);
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.books-column-divider {
    width: 1px;
    background: var(--border-color);
}

.books-list-display {
    list-style-type: none;
    padding: 0;
}

.books-list-display li {
    background: var(--bg-element);
    margin-bottom: 8px;
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 0.95em;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.books-list-display li:hover {
    background: var(--bg-element-hover);
    border-color: var(--border-color);
}

.no-books-msg {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-top: 10px;
}

/* --- BOOK EDITOR STYLES --- */
.large-content {
    width: 600px;
    text-align: left;
}

.editor-section {
    margin-bottom: 24px;
}

.editor-section>label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9em;
}

.styled-select, .styled-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 1em;
    outline: none;
    transition: border 0.2s;
    font-family: inherit;
}

.styled-select:focus, .styled-input:focus {
    border-color: var(--accent-color);
    background: var(--bg-element-hover);
}

.editor-book-list {
    list-style: none;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-element);
}

.editor-book-list li {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
}

.editor-book-list li:last-child {
    border-bottom: none;
}

.remove-book-btn {
    background: none;
    border: none;
    color: #cc5555;
    font-size: 18px;
    cursor: pointer;
    padding: 0 8px;
}

.remove-book-btn:hover {
    color: #ff5555;
}

.add-box {
    background: var(--bg-element-hover);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.color-picker-label {
    margin-top: 12px;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.color-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-element);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-circle:hover {
    background: var(--bg-element-hover);
    transform: scale(1.1);
}

.color-circle.selected {
    border-color: var(--accent-color);
    background: var(--bg-element-hover);
}

.add-btn {
    background: var(--accent-color);
    color: #fff;
    margin-top: 8px;
}

.add-btn:hover {
    background: var(--accent-hover);
}

/* --- DROPDOWN & SELECTION --- */
.dropdown-wrapper label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 500;
}

.custom-dropdown {
    position: relative;
    width: 100%;
}

#dropdownSearch, #bookSubjectSearch {
    width: 100%;
    padding: 12px 14px;
    border-radius: 6px;
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1em;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

#dropdownSearch:focus, #bookSubjectSearch:focus {
    background: var(--bg-element-hover);
    border-color: var(--accent-color);
}

.dropdown-options {
    position: absolute;
    top: 110%;
    left: 0;
    width: 100%;
    max-height: 350px;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    z-index: 2000;
    display: none;
    box-shadow: 0 15px 40px var(--shadow-color);
    overscroll-behavior: contain;
}

.dropdown-options.show {
    display: block;
}

.dropdown-options::-webkit-scrollbar {
    width: 8px;
}

.dropdown-options::-webkit-scrollbar-track {
    background: var(--bg-element);
}

.dropdown-options::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.15s ease;
    color: var(--text-primary);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--bg-element-hover);
    color: var(--text-primary);
}

.dropdown-item.active-item {
    background: var(--bg-element-hover);
    color: var(--text-primary);
    border-left: 3px solid var(--accent-color);
    padding-left: 13px;
}

.separator {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85em;
    margin: 8px 0;
    text-align: center;
}

/* Buttons & Switches */
.week-selection-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 5px;
}

.week-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px;
    font-size: 1em;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.week-btn:hover {
    color: var(--text-primary);
    background: var(--bg-element);
    border-radius: 4px 4px 0 0;
}

.week-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-color);
    font-weight: 600;
}

.modal-btn {
    padding: 12px 20px;
    border-radius: 6px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95em;
    width: 100%;
}

.modal-btn:hover {
    transform: translateY(-1px);
}

.custom-btn {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.custom-btn:hover {
    background: var(--bg-panel);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.delete-btn {
    background: #1a0a0a;
    border: 1px solid #3a1a1a;
    color: #cc5555;
}

.delete-btn:hover {
    background: #2a1515;
    border-color: #4a2020;
    color: #dd6666;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-element);
    border: 1px solid var(--border-color);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: #fff;
}

/* --- EDIT MODE VISUALS --- */
body.edit-mode .timetable .lesson {
    cursor: pointer;
    position: relative;
    background: var(--bg-element);
    box-shadow: inset 0 0 0 1px var(--border-color);
}

body.edit-mode .timetable .lesson.pool-hover {
    background: var(--edit-pool-bg) !important;
    box-shadow: inset 0 0 0 1px var(--edit-pool-border);
}

body.edit-mode .timetable .lesson:hover {
    background: var(--accent-color) !important;
    box-shadow: inset 0 0 0 2px #fff;
    z-index: 2;
    color: #fff;
}

body.edit-mode td[data-pool="pool_gemoro"], body.edit-mode td[data-pool="pool_english"], body.edit-mode td[data-pool="pool_maths"] {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
    box-shadow: none !important;
    background: #000 !important;
}

body.light-mode.edit-mode td[data-pool="pool_gemoro"], body.light-mode.edit-mode td[data-pool="pool_english"], body.light-mode.edit-mode td[data-pool="pool_maths"] {
    background: #ddd !important;
}

body.edit-mode .timetable .lesson::after {
    content: '\e3c9';
    font-family: 'Material Symbols Outlined';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 16px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s ease;
    font-weight: normal;
}

body.edit-mode .timetable .lesson:hover::after {
    opacity: 1;
    color: #fff;
}

body.edit-mode td[data-pool="pool_gemoro"]::after, body.edit-mode td[data-pool="pool_english"]::after, body.edit-mode td[data-pool="pool_maths"]::after {
    display: none;
}

#editToggle.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

body.edit-mode td[data-locked="true"] {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
    background: #000 !important;
    box-shadow: none !important;
}

body.light-mode.edit-mode td[data-locked="true"] {
    background: #ddd !important;
}

body.edit-mode td[data-locked="true"]::after {
    display: none;
}

/* --- RESPONSIVE FOR MAIN TIMETABLE LAYOUT --- */
@media (max-width: 1250px) {
    .dual-timetable-container {
        flex-direction: column;
        overflow-x: hidden;
    }

    .week-column {
        min-width: 100%;
        margin-bottom: 30px;
    }
}

@media (max-width: 768px) {
    .timetable {
        font-size: 0.85em;
    }

    .timetable th, .timetable td {
        padding: 10px 4px;
    }

    .period-time {
        width: 50px;
        font-size: 0.7em;
    }

    .modal-content {
        width: 95%;
        max-height: none;
        margin: 20px auto;
    }

    .books-dual-container {
        flex-direction: column;
    }

    .books-column-divider {
        width: 100%;
        height: 1px;
        margin: 15px 0;
    }
}

/* --- SETTINGS LAYOUT --- */
.settings-modal-wide {
    width: 700px;
    padding: 0;
    max-width: 90vw;
    height: 450px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.settings-container {
    display: flex;
    flex: 1;
    height: 100%;
}

.settings-sidebar {
    width: 200px;
    background: var(--bg-element);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 10px;
    gap: 5px;
}

.sidebar-header {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--text-primary);
    padding: 0 15px 20px 15px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 15px;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.tab-btn .material-symbols-outlined {
    font-size: 20px;
}

.tab-btn:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-color);
    color: #fff;
}

.settings-body {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    text-align: left;
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-content.active {
    display: block;
}

.tab-content h4 {
    margin-bottom: 20px;
    font-size: 1.4em;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.desc-text {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-element);
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    min-height: 50px;
}

.settings-modal-wide .close-button {
    z-index: 10;
    top: 10px;
    right: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 650px) {
    .settings-modal-wide {
        height: 80vh;
    }

    .settings-container {
        flex-direction: column;
    }

    .settings-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
        padding-right: 48px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
        mask-image: linear-gradient(to right, black calc(100% - 56px), transparent 100%);
    }

    .sidebar-header {
        display: none;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.85em;
        white-space: nowrap;
    }

    .tab-btn .material-symbols-outlined {
        display: none;
    }

    .settings-body {
        padding: 20px;
    }
}

.friday-end {
    background: #050505 !important;
    border-color: #222 !important;
    cursor: default;
    pointer-events: none;
}

body.light-mode .friday-end {
    background: #e0e0e0 !important;
    border-color: #ccc !important;
}

/* LIGHT MODE HIGHLIGHT FIXES */
body.light-mode .highlight-current {
    outline: 2px solid #1e8e3e;
    background: #e6f4ea;
    color: #0d652d;
}

body.light-mode .highlight-next {
    outline: 2px solid var(--accent-color);
    background: #e8f0fe;
    color: var(--accent-color);
}

body.light-mode .delete-btn {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

body.light-mode .delete-btn:hover {
    background: #fecaca;
    color: #7f1d1d;
}

body.light-mode .lesson-popup-close:hover {
    background: #d1d5db;
    color: #000;
}

body.light-mode .lesson-popup-btn {
    background: #e5e7eb;
    color: #1f2937;
}

body.light-mode .lesson-popup-btn:hover {
    background: #d1d5db;
}

body.light-mode .lesson-popup-btn.edit {
    background: var(--accent-color);
    color: #fff;
}

body.light-mode .lesson-popup-btn.edit:hover {
    background: var(--accent-hover);
}

/* AUTH MODAL STYLES */
.auth-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.google-btn, .apple-btn, .github-btn, .email-btn {
    background: #fff;
    color: #444;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
}

.google-btn:hover, .email-btn:hover {
    background: #f1f1f1;
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.apple-btn {
    background: #000;
    color: #fff;
    border: 1px solid #000;
}

.apple-btn:hover {
    background: #333;
    border-color: #333;
    transform: translateY(-1px);
}

.github-btn {
    background: #24292e;
    color: #fff;
    border: 1px solid #24292e;
}

.github-btn:hover {
    background: #111;
    border-color: #111;
    transform: translateY(-1px);
}

body.light-mode .google-btn, body.light-mode .email-btn {
    background: #fff;
    border-color: #ccc;
    color: #444;
}

body.light-mode .apple-btn {
    background: #000;
    color: #fff;
}

body.light-mode .github-btn {
    background: #24292e;
    color: #fff;
}

/* ONBOARDING STYLES */
.tutorial-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 0.95em;
    color: var(--text-primary);
}

.color-dot-tutorial {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    display: inline-block;
}

.color-dot-tutorial.current {
    background: #111f11;
    border: 2px solid #0a8f08;
}

.color-dot-tutorial.next {
    background: #101924;
    border: 2px solid var(--accent-color);
}

body.light-mode .color-dot-tutorial.current {
    background: #e6f4ea;
    border-color: #1e8e3e;
}

body.light-mode .color-dot-tutorial.next {
    background: #e8f0fe;
    border-color: var(--accent-color);
}

/* MOBILE DAY NAVIGATOR & MAIN MODIFICATIONS */
.header-name-inline {
    display: none;
}

.mobile-day-nav {
    display: none;
}

.back-to-today-btn {
    display: none;
}

@media (max-width: 768px) {
    /* Modify sidebar behavior for mobile or let user adjust */

    .mobile-day-nav {
        display: flex;
        flex-direction: column;
        background: var(--bg-panel);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .mobile-week-tabs {
        display: flex;
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-week-tab {
        flex: 1;
        background: transparent;
        border: none;
        padding: 14px 0;
        font-size: 0.85em;
        font-weight: 600;
        color: var(--text-secondary);
        cursor: pointer;
        letter-spacing: 0.6px;
        text-transform: uppercase;
        border-bottom: 2px solid transparent;
        margin-bottom: -1px;
        transition: color 0.2s ease, border-color 0.2s ease;
        position: relative;
    }

    .mobile-week-tab.active {
        color: var(--accent-color);
        border-bottom-color: var(--accent-color);
    }

    .mobile-week-tab.current-week::before {
        content: 'CURRENT';
        position: absolute;
        top: 4px;
        right: 6px;
        background: var(--accent-color);
        color: #ffffff;
        font-size: 0.7em;
        font-weight: 700;
        padding: 2px 5px;
        border-radius: 4px;
        letter-spacing: 0.5px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }

    .mobile-day-controls {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 5px 4px;
    }

    .mobile-day-arrow {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 2.4em;
        line-height: 1;
        cursor: pointer;
        padding: 0 12px;
        border-radius: 6px;
        transition: color 0.15s, background 0.15s;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-day-arrow:active {
        color: var(--text-primary);
        background: var(--bg-element-hover);
    }

    .mobile-day-arrow:disabled {
        opacity: 0.2;
        cursor: default;
    }

    .mobile-day-label-wrap {
        text-align: center;
        flex: 1;
    }

    .mobile-day-name {
        font-size: 1em;
        font-weight: 700;
        color: var(--text-primary);
        letter-spacing: 0.3px;
    }

    .dual-timetable-container {
        padding: 0;
        gap: 0;
        flex-direction: column;
        overflow-x: hidden;
        flex: 1;
        min-height: 0;
    }

    .week-title {
        display: none;
    }

    .week-column {
        min-width: 0;
        width: 100%;
        margin-bottom: 0;
        display: none;
        flex: 1;
        min-height: 0;
    }

    .week-column.mobile-active {
        display: flex;
        flex-direction: column;
    }

    .week-content {
        flex: 1;
        display: flex !important;
        flex-direction: column;
        min-height: 0;
        padding: 0;
    }

    .timetable {
        font-size: 0.92em;
        table-layout: fixed;
        flex: 1;
        height: 100%;
        border-radius: 0;
    }

    .timetable th:first-child, .timetable td:first-child {
        width: 90px;
        font-size: 0.75em;
        padding: 0 4px;
    }

    .timetable th.day-header, .timetable td.day-col {
        display: none;
    }

    .timetable th.day-header.mobile-day-active, .timetable td.day-col.mobile-day-active {
        display: table-cell;
    }

    .timetable tbody {
        height: 100%;
    }

    .timetable tbody tr {
        height: 1%;
    }

    .timetable td.day-col.mobile-day-active {
        padding: 6px 10px;
        font-size: 0.95em;
        width: auto;
        vertical-align: middle;
    }

    .timetable td.period-time {
        padding: 6px 4px;
        font-size: 0.72em;
        line-height: 1.3;
    }

    .subject {
        white-space: normal;
        word-break: break-word;
        line-height: 1.3;
        font-size: 0.95em;
    }

    .back-to-today-btn {
        display: flex;
        position: fixed;
        bottom: 24px;
        right: 24px;
        background: var(--accent-color);
        color: white;
        border: none;
        border-radius: 50%;
        width: 56px;
        height: 56px;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4);
        cursor: pointer;
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transform: scale(0.7) translateY(8px);
        transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
        font-size: 24px;
    }

    .back-to-today-btn:active {
        transform: scale(0.92) translateY(0) !important;
        box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
    }

    .back-to-today-btn.show {
        opacity: 1;
        pointer-events: auto;
        transform: scale(1) translateY(0);
    }

    .period-time .period-label-mobile {
        display: inline;
    }

    .period-time .period-label-desktop {
        display: none;
    }
}