/* ========================================
   CSS Custom Properties
   ======================================== */
:root {
    --bg-primary: #010b13;
    --bg-secondary: #060f18;
    --bg-card: #0a1a2a;
    --bg-input: #0d2035;
    --bg-hover: #122a40;
    --text-primary: #e8e8e8;
    --text-secondary: #8899aa;
    --text-muted: #556677;
    --accent-orange: #ffa100;
    --accent-red: #ff1500;
    --accent-green: #00c853;
    --border-color: #1a2a3a;
    --radius-pill: 9999px;
    --radius-card: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --font-heading: 'Fjalla One', sans-serif;
    --font-body: 'Montserrat', sans-serif;
    --sidebar-width: 260px;
    --toolbar-height: 60px;
    --transition: 0.2s ease;
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ========================================
   Login Overlay
   ======================================== */
.login-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 1000;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    margin: 0 20px;
}

.login-title {
    font-family: var(--font-heading);
    font-size: 32px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-orange);
    text-align: center;
    margin-bottom: 32px;
}

.login-error {
    background: rgba(255, 21, 0, 0.15);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

/* ========================================
   Forms
   ======================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-orange);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238899aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group input[type="color"] {
    width: 48px;
    height: 36px;
    padding: 2px;
    cursor: pointer;
    border-radius: var(--radius-xs);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .flex-1 { flex: 1; }
.form-row .flex-2 { flex: 2; }

.color-picker {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-preview {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-orange);
    color: #000;
}
.btn-primary:hover { background: #ffb333; }

.btn-danger {
    background: var(--accent-red);
    color: #fff;
}
.btn-danger:hover { background: #ff4433; }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-outline:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-sm { padding: 6px 16px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-icon.active { color: var(--accent-orange); }

.btn-icon-sm {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    display: flex;
    align-items: center;
}
.btn-icon-sm:hover { color: var(--accent-orange); }

.btn-icon-xs {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}
.btn-icon-xs:hover { color: var(--accent-orange); }

/* ========================================
   App Layout
   ======================================== */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ========================================
   Mobile Header
   ======================================== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    padding: 0 16px;
    z-index: 90;
    gap: 12px;
}

.mobile-title {
    font-family: var(--font-heading);
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-orange);
}

.mobile-timer-indicator {
    margin-left: auto;
}

.pulse-dot {
    display: block;
    width: 10px;
    height: 10px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-close { display: none; }

.app-title {
    font-family: var(--font-heading);
    font-size: 22px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-orange);
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
}

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

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    margin-bottom: 8px;
}

.sidebar-section-header h2 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.calendar-list {
    list-style: none;
}

.calendar-list li {
    display: flex;
    align-items: center;
    gap: 4px;
}

.calendar-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-align: left;
    width: 100%;
}

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

.calendar-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 600;
}

.calendar-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Timer Widget */
.timer-widget {
    margin: 12px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--accent-green);
    border-radius: var(--radius-card);
    text-align: center;
}

.timer-widget-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-green);
    margin-bottom: 4px;
}

.timer-widget-task {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timer-widget-time {
    font-size: 28px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent-green);
    margin-bottom: 12px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 98;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
    flex-wrap: wrap;
}

.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-pill);
}

.tab {
    padding: 8px 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-pill);
    transition: all var(--transition);
}

.tab:hover { color: var(--text-primary); }
.tab.active {
    background: var(--accent-orange);
    color: #000;
    font-weight: 600;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
}

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ========================================
   Task Cards (List View)
   ======================================== */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    border-left: 4px solid var(--accent-orange);
    cursor: pointer;
    transition: all var(--transition);
}

.task-card:hover {
    background: var(--bg-hover);
}

.task-card.expanded {
    background: var(--bg-card);
}

.task-card.urgent {
    background: rgba(255, 165, 0, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 165, 0, 0.15), 0 0 12px rgba(255, 165, 0, 0.08);
    animation: urgent-glow 3s ease-in-out infinite;
}

.task-card.overdue {
    background: rgba(255, 21, 0, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 21, 0, 0.2), 0 0 16px rgba(255, 21, 0, 0.1);
    animation: overdue-glow 2s ease-in-out infinite;
}

@keyframes urgent-glow {
    0%, 100% { box-shadow: inset 0 0 0 1px rgba(255, 165, 0, 0.15), 0 0 12px rgba(255, 165, 0, 0.08); }
    50% { box-shadow: inset 0 0 0 1px rgba(255, 165, 0, 0.3), 0 0 20px rgba(255, 165, 0, 0.15); }
}

@keyframes overdue-glow {
    0%, 100% { box-shadow: inset 0 0 0 1px rgba(255, 21, 0, 0.2), 0 0 16px rgba(255, 21, 0, 0.1); }
    50% { box-shadow: inset 0 0 0 1px rgba(255, 21, 0, 0.4), 0 0 24px rgba(255, 21, 0, 0.2); }
}

.task-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
}

.task-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.task-card.expanded .task-chevron {
    transform: rotate(180deg);
}

.task-card-main {
    flex: 1;
    min-width: 0;
}

.task-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.task-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-deadline-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.task-deadline-badge.normal {
    background: var(--bg-input);
    color: var(--text-secondary);
}

.task-deadline-badge.urgent {
    background: rgba(255, 165, 0, 0.15);
    color: #ffa500;
}

.task-deadline-badge.overdue {
    background: var(--accent-red);
    color: #fff;
}

.deadline-warn-icon {
    flex-shrink: 0;
}

.task-deadline-badge.overdue .deadline-warn-icon {
    stroke: #fff;
}

.task-deadline-badge.urgent .deadline-warn-icon {
    stroke: #ffa500;
}

.task-time {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.task-timer-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.task-timer-btn:hover {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.task-timer-btn.running {
    border-color: var(--accent-green);
    color: var(--accent-green);
    animation: pulse 1.5s infinite;
}

.task-status-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.task-status-btn {
    padding: 4px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: none;
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition);
}

.task-status-btn:hover {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ========================================
   Task Accordion
   ======================================== */
.task-accordion {
    border-top: 1px solid var(--border-color);
    cursor: default;
}

.accordion-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.accordion-content {
    padding: 0 20px 20px;
}

.accordion-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.accordion-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.accordion-field a {
    font-size: 13px;
}

.accordion-field.accordion-notes {
    grid-column: 1 / -1;
}

.accordion-field span:not(.accordion-label) {
    font-size: 13px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.accordion-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.accordion-entries {
    padding: 16px 0;
}

.accordion-entries-header {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.entries-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.entry-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.entry-date {
    color: var(--text-secondary);
    min-width: 80px;
}

.entry-times {
    color: var(--text-primary);
    flex: 1;
}

.entry-duration {
    color: var(--accent-orange);
    font-weight: 600;
    text-align: right;
    min-width: 60px;
}

.entries-total {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-orange);
}

.entries-empty {
    padding: 12px;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.accordion-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   Calendar View
   ======================================== */
.calendar-grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.calendar-grid-title {
    font-family: var(--font-heading);
    font-size: 24px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.calendar-grid-nav {
    display: flex;
    gap: 8px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: var(--border-color);
    border-radius: var(--radius-card);
    overflow: hidden;
}

.calendar-grid .day-header {
    background: var(--bg-secondary);
    padding: 10px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.calendar-day {
    background: var(--bg-card);
    min-height: 100px;
    padding: 8px;
    vertical-align: top;
}

.calendar-day.other-month {
    background: var(--bg-primary);
    opacity: 0.4;
}

.calendar-day.today {
    background: var(--bg-hover);
}

.calendar-day-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.calendar-day.today .calendar-day-number {
    color: var(--accent-orange);
}

.calendar-task-chip {
    display: block;
    padding: 3px 8px;
    margin-bottom: 3px;
    border-radius: var(--radius-xs);
    font-size: 11px;
    color: var(--text-primary);
    background: var(--bg-input);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    border-left: 3px solid var(--accent-orange);
    transition: background var(--transition);
}

.calendar-task-chip:hover {
    background: var(--bg-hover);
}

.calendar-task-chip.urgent {
    border-left-color: var(--accent-red);
    background: rgba(255, 21, 0, 0.1);
}

/* ========================================
   Modal
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 0 16px;
}

.modal-card-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 99;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-close {
        display: flex;
    }

    .main-content {
        padding-top: 56px;
    }

    .toolbar {
        padding: 12px 16px;
    }

    .content-area {
        padding: 16px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .task-card-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .task-status-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .accordion-details {
        grid-template-columns: 1fr;
    }

    .entry-row {
        gap: 8px;
        font-size: 12px;
    }

    .calendar-day {
        min-height: 60px;
        padding: 4px;
    }

    .calendar-day-number {
        font-size: 10px;
    }

    .calendar-task-chip {
        font-size: 9px;
        padding: 2px 4px;
    }
}
