/*
  ==========================
  TASKS PAGE (BASE + LAYOUT)
  ==========================
*/

:root {
    --tasks-surface: rgb(255, 255, 255);
    --tasks-surface-border: #ddd;
    --tasks-grid-line: rgba(0, 0, 0, 0.12);
    --tasks-time-col: 68px;
    --tasks-slot-height: 132px;
    --tasks-month-day-height: 56px;
    --tasks-month-day-gap: 6px;
    --tasks-month-day-rows: 6;
}

html, body {
    text-align: center;
    display: flex;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overscroll-behavior: none;
    width: 100%;
    font-family: "Manrope";
}

.content {
    text-align: center;
    flex: 1;
    padding: 24px;
    width: 100%;
    box-sizing: border-box;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hidden { display: none; }

/* NAVBAR */
.navbar {
    width: 180px;
    border-right: 1px solid #ddd;
    padding: 16px;
    text-align: left;
    transition: width 0.24s ease, padding 0.24s ease;
}

.navbar ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    font-family: "Noto Sans";
    gap: 12px;
    padding: 0;
    margin-top: 16px;
    font-size: 20px;
    text-align: center;
    transition: opacity 0.2s ease, transform 0.2s ease, margin-top 0.2s ease;
}

.navbar a {
    border-radius: 6px;
    display: block;
    width: 100%;
    text-decoration: none;
    color: black;
}

.navbar a:hover {
    background: rgba(4, 255, 0, 0.742);
}

.navbar a.active {
    background: rgba(124, 255, 122, 0.66);
    font-weight: 700;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 70px;
    cursor: pointer;
    margin-bottom: 10px;
    margin-left: 50px;
    text-align: center;
    transition: margin-left 0.24s ease;
}

body.nav-collapsed .navbar {
    width: 72px;
    padding: 16px 10px;
    overflow: hidden;
}

body.nav-collapsed .navbar ul {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-12px);
    margin-top: 0;
    height: 0;
}

body.nav-collapsed .menu-toggle {
    margin-left: 0;
}

h1 {
    color: black;
    font-family: "Manrope";
    font-size: 36px;
    font-weight: 700;
}

h2 {
    color: black;
    font-family: "Manrope";
    font-size: 28px;
    font-weight: 600;
}

.page-title {
    margin: 0px;
    letter-spacing: 1px;
    font-family: "Manrope";
    font-size: 34px;
    font-weight: 700;
}

.btn-primary {
    font-size: 18px;
    border-radius: 20px;
    background-color: black;
    border: 2px solid grey;
    color: white;
    width: 30px;
    height: 30px;
    align-self: center;
    justify-self: center;
}

.btn-primary:hover {
    background-color: rgb(80, 90, 80);
    cursor: pointer;
    border-color: black;
    color: black;
}

.btn-secondary {
    font-size: 14px;
    border-radius: 5px;
    background-color: rgb(141, 157, 141);
    border: 2px solid black;
    color: black;
    width: 70px;
    height: 30px;
    align-self: center;
    justify-self: center;
}

.btn-secondary:hover {
    background-color: rgb(80, 90, 80);
    cursor: pointer;
    border-color: grey;
    color: black;
}

/* Controls */
.tasks-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 14px;
    align-items: center;
    margin-bottom: 5px;
}

.tasks-nav-group {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
}

#today-btn {
    font-size: 20px;
    border-radius: 5px;
    background-color: black;
    border: 2px solid grey;
    color: white;
    width: 100px;
    height: 38px;
}

.tasks-nav-btn {
    font-size: 25px;
    border-radius: 20px;
    background-color: black;
    border: 2px solid grey;
    color: white;
    width: 40px;
    height: 38px;
}

#today-btn:hover,
.tasks-nav-btn:hover {
    background-color: rgb(80, 90, 80);
    cursor: pointer;
    border-color: black;
    color: black;
}

.tasks-view-toggle {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.tasks-view-toggle .btn-secondary {
    width: 78px;
}

.tasks-view-toggle .btn-secondary.active {
    background: black;
    color: white;
    border-color: grey;
}

.tasks-surface {
    border: 2px solid var(--tasks-surface-border);
    background: var(--tasks-surface);
    border-radius: 10px;
    padding: 12px;
    box-sizing: border-box;
}

/* Week View */
.tasks-grid-shell {
    display: grid;
    gap: 0;
    text-align: left;
}

.tasks-week-header-row {
    display: grid;
    grid-template-columns: var(--tasks-time-col) minmax(0, 1fr);
}

.tasks-time-header {
    border-right: 1px solid var(--tasks-grid-line);
    border-bottom: 1px solid var(--tasks-grid-line);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.4px;
    padding: 10px 8px;
    box-sizing: border-box;
    text-align: right;
}

.tasks-week-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-bottom: 1px solid var(--tasks-grid-line);
}

.week-day-header {
    min-height: 52px;
    padding: 8px 6px;
    background: rgba(119, 201, 118, 0.6);
    border-right: 1px solid var(--tasks-grid-line);
    box-sizing: border-box;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 2px;
    font-weight: 700;
    font-size: 13px;
}

.week-day-header:last-child {
    border-right: 0;
}

.week-day-header .weekday-name {
    font-size: 13px;
}

.week-day-header .weekday-date {
    font-size: 15px;
}

.week-day-header.today {
    background: rgba(124, 255, 122, 0.32);
    border-bottom: 2px solid rgba(3, 46, 8, 0.7);
}

.tasks-week-body-row {
    display: grid;
    grid-template-columns: var(--tasks-time-col) minmax(0, 1fr);
    max-height: calc(var(--tasks-slot-height) * 10 + 4px);
    overflow: auto;
}

.tasks-time-rail {
    border-right: 1px solid var(--tasks-grid-line);
}

.time-label {
    height: var(--tasks-slot-height);
    box-sizing: border-box;
    border-bottom: 1px solid var(--tasks-grid-line);
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 700;
}

.tasks-week-body {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: var(--tasks-slot-height);
}

.week-slot {
    border-right: 1px solid var(--tasks-grid-line);
    border-bottom: 1px solid var(--tasks-grid-line);
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.week-slot:nth-child(7n) {
    border-right: 0;
}

.slot-add-btn { /* note: this is intentionally separate to the shared button styling of btn-primary / btn-secondary */
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid grey;
    background: black;
    color: white;
    font-size: 15px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
    cursor: pointer;
}

.week-slot:hover .slot-add-btn,
.week-slot:focus-within .slot-add-btn {
    opacity: 1;
    pointer-events: auto;
}

.slot-add-btn:hover {
    background-color: rgb(80, 90, 80);
    border-color: black;
    color: black;
}

.task-card {
    position: static;
    width: calc(100% - 8px);
    margin: 2px 4px 0;
    border-radius: 7px;
    border: 1px solid rgba(0, 0, 0, 0.35);
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    padding: 4px 6px;
    min-height: 22px;
    max-height: 22px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;
}

.task-card.priority-high {
    background: #f0b4af;
}

.task-card.priority-medium {
    background: #c3d8c5;
}

.task-card.priority-low {
    background: #b8e7c7;
}

.tbd-chip-wrap {
    margin-top: 4px;
    width: 100%;
    display: grid;
    gap: 4px;
}

.slot-quarter-grid {
    margin-top: 28px;
    height: calc(var(--tasks-slot-height) - 28px);
    display: block;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.week-slot:hover .slot-quarter-grid,
.week-slot:focus-within .slot-quarter-grid {
    overflow-y: auto;
}

.slot-quarter {
    min-height: calc((var(--tasks-slot-height) - 28px) / 4);
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    display: grid;
    align-content: start;
    gap: 2px;
    padding-top: 1px;
}

.slot-quarter:first-child {
    border-top: 0;
}

.tbd-chip {
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    background: rgba(124, 255, 122, 0.6);
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    padding: 2px 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.tbd-chip:hover {
    background-color: rgb(200, 217, 202);
}

.tbd-more {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.75;
    text-align: left;
}

/* Month view shell */
.tasks-month-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 14px;
    align-items: start;
}

.tasks-month-calendar,
.tasks-month-agenda {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    padding: 10px;
    box-sizing: border-box;
}

.tasks-month-weekdays,
.tasks-month-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--tasks-month-day-gap);
}

.tasks-month-weekdays {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.tasks-month-day {
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    min-height: var(--tasks-month-day-height);
    background: rgba(124, 255, 122, 0.32);
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    padding: 6px;
    display: grid;
    align-content: space-between;
    gap: 4px;
}

.tasks-month-day.outside {
    opacity: 0.45;
}

.tasks-month-day.today {
    border-color: black;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.65);
}

.tasks-month-day.selected {
    outline: 2px solid rgba(3, 46, 8, 0.7);
}

.tasks-month-day-num {
    font-size: 14px;
    font-weight: 800;
}

.tasks-month-day-count {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.75;
}

.tasks-selected-date-label {
    margin: 0 0 8px;
    font-size: 16px;
}

.tasks-month-agenda-grid {
    display: grid;
    grid-template-columns: var(--tasks-time-col) minmax(0, 1fr);
    max-height: calc(
        (var(--tasks-month-day-height) * var(--tasks-month-day-rows)) +
        (var(--tasks-month-day-gap) * (var(--tasks-month-day-rows) - 1))
    );
    overflow: auto;
    border-top: 1px solid var(--tasks-grid-line);
    border-left: 1px solid var(--tasks-grid-line);
}

.tasks-month-body {
    display: grid;
    grid-auto-rows: var(--tasks-slot-height);
    border-right: 1px solid var(--tasks-grid-line);
}

.month-slot {
    border-bottom: 1px solid var(--tasks-grid-line);
    position: relative;
    min-height: var(--tasks-slot-height);
}

.month-slot .task-card {
    position: static;
    margin: 5px;
    width: auto;
}

.month-tbd-row {
    border-bottom: 1px solid var(--tasks-grid-line);
    padding: 8px;
    display: grid;
    gap: 8px;
}

.month-tbd-label {
    font-size: 12px;
    font-weight: 800;
}

.month-tbd-chips {
    display: grid;
    gap: 6px;
}

/* Add task modal */
#modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 9;
}

#add-task-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    font-family: "Noto Sans";
    background: white;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #ddd;
    z-index: 10;
    text-align: left;
}

#add-task-modal .form-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    align-items: start;
    column-gap: 12px;
    margin-bottom: 12px;
}

#add-task-modal .form-row label {
    text-align: left;
    margin: 0;
    padding-top: 8px;
}

#add-task-modal input,
#add-task-modal textarea {
    width: 80%;
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-family: "Noto Sans";
}

#add-task-modal select {
    width: 60%;
    max-width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-family: "Noto Sans";
}

#task-time {
    width: 60%;
    max-width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-family: "Noto Sans";
    appearance: none;
    background: white;
    color: #111;
}

#task-time:focus {
    outline: 2px solid rgba(3, 46, 8, 0.4);
    outline-offset: 1px;
}

#task-time::-webkit-calendar-picker-indicator {
    opacity: 0.75;
    cursor: pointer;
}

#task-notes {
    resize: none;
    height: 90px;
    max-height: 90px;
    overflow-y: auto;
}

.task-status {
    margin: 8px 0 12px;
    font-family: "Noto Snas";
    font-weight: 700;
    text-align: center;
    min-height: 1.2em;
}

.task-schedule-context {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    opacity: 0.85;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

/* SYSTEM SETTINGS */
.system-settings {
    position: fixed;
    bottom: 50px;
    left: 50px;
    transition: transform 0.24s ease, opacity 0.2s ease;
}

body.nav-collapsed .system-settings {
    transform: translateX(-120px);
    opacity: 0;
    pointer-events: none;
}

#system-settings-btn {
    appearance: none;
    background: transparent;
    font-size: 40px;
    align-self: center;
    justify-self: center;
    border: none;
    cursor: pointer;
}

#system-settings-btn:hover {
    transition: transform 0.3s ease, filter 0.3s ease;
    transform: scale(1.15) rotate(8deg);
    filter: brightness(1.05);
}

#system-settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    font-family: "Noto Sans";
    background: white;
    border-radius: 12px;
    padding: 0;
    border: 1px solid #ddd;
    z-index: 900;
    text-align: left;
    overflow: hidden;
}

.settings-layout {
    display: grid;
    grid-template-columns: 120px 1fr;
    min-height: 240px;
    margin-top: 12px;
}

.settings-sidebar {
    border-right: 1px solid #ddd;
    padding: 12px;
    background: #f7f7f7;
}

.settings-sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.settings-nav {
    width: 100%;
    text-align: left;
    border: 1px solid #ccc;
    background: white;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.settings-nav:hover {
    transform: scale(1.03);
    filter: brightness(1.02);
}

.settings-nav.active {
    border-color: #111;
    font-weight: 700;
}

.settings-header {
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid #ddd;
}

.settings-title {
    margin: 5px;
    text-align: center;
    font-size: 16px;
    font-weight: 800;
}

.settings-subtitle {
    margin-top: 6px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    opacity: 0.85;
}

.settings-panel p {
    margin-left: 10px;
}

.settings-panel.hidden { display: none; }

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
}

.setting-labels { text-align: left; margin-left: 10px; }

.setting-action-btn {
    min-width: 84px;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    margin-right: 10px;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.setting-action-btn:hover {
    transform: scale(1.03);
    filter: brightness(1.04);
}

.setting-action-btn.danger {
    background: #d84c4c;
    border-color: #b63b3b;
}

.setting-action-btn.success {
    background: #2f9a4a;
    border-color: #227738;
}

.setting-account-input {
    width: 130px;
    max-width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid #b9b9b9;
    font-family: inherit;
    font-size: 13px;
    margin-right: 10px;
    box-sizing: border-box;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 25px;
    margin-right: 10px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cfcfcf;
    border-radius: 999px;
    transition: 0.2s ease;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s ease;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .slider {
    background: rgba(124, 255, 122, 0.66);
}

.switch input:checked + .slider::before {
    transform: translateX(17px);
}

@media (max-width: 1200px) {
    .tasks-controls {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .tasks-nav-group,
    .tasks-view-toggle {
        justify-content: center;
    }

    .tasks-month-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    .content {
        padding: 16px;
    }

    :root {
        --tasks-time-col: 56px;
        --tasks-slot-height: 116px;
    }

    .tasks-range-label-wrap h2 {
        font-size: 28px;
    }
}
