/* =============================================
   CSS Variables & Reset
   ============================================= */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --accent-color: #0088cc;
    --accent-hover: #0077b5;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --border-color: #3d3d3d;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Light theme */
.light-theme {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e0e0e0;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Neon theme */
.theme-neon {
    --bg-primary: #0a0a1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #2a2a4e;
    --accent-color: #00ffff;
    --accent-hover: #00cccc;
    --border-color: #2a2a4e;
}

/* Pastel theme */
.theme-pastel {
    --bg-primary: #f5f0e8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #efe8dc;
    --text-primary: #3d3d3d;
    --text-secondary: #777777;
    --accent-color: #7c9885;
    --border-color: #e0d8cc;
}

/* Corporate theme */
.theme-corporate {
    --bg-primary: #1e2a38;
    --bg-secondary: #2d3e50;
    --bg-tertiary: #3d4e60;
    --accent-color: #3498db;
    --border-color: #3d4e60;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* =============================================
   Container & Layout
   ============================================= */
.container {
    min-height: 100vh;
    padding: 16px;
    padding-bottom: 100px;
    max-width: 600px;
    margin: 0 auto;
}

/* =============================================
   Header
   ============================================= */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 8px 0;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-header:hover {
    background: var(--bg-tertiary);
}

.btn-header span {
    font-size: 20px;
}

.btn-header small {
    font-size: 10px;
    color: var(--text-secondary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

.btn-text {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 14px;
    cursor: pointer;
}

/* =============================================
   Stats Bar
   ============================================= */
.stats-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.stat-chip.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.stat-chip:not(.active):hover {
    background: var(--bg-tertiary);
}

.stat-chip-value {
    font-weight: 700;
}

.stat-chip-label {
    font-weight: 400;
}

/* =============================================
   Task Cards
   ============================================= */
.tasks-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.task-group {
    margin-bottom: 8px;
}

.task-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 4px;
}

.task-group-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.task-group-count {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    color: var(--text-secondary);
}

.task-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    border-left: 4px solid var(--accent-color);
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
}

.task-card.done {
    opacity: 0.6;
}

.task-card.done .task-card-title {
    text-decoration: line-through;
}

/* Category colors */
.task-card.cat-personal {
    border-left-color: #0088cc;
}

.task-card.cat-work {
    border-left-color: #ff9800;
}

.task-card.cat-shopping {
    border-left-color: #9c27b0;
}

.task-card.cat-health {
    border-left-color: #e91e63;
}

.task-card-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 12px;
    flex-shrink: 0;
}

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

.task-card-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.task-card-time {
    font-weight: 500;
}

.task-card-badge {
    font-size: 12px;
}

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

.task-card-more-arrow {
    font-size: 16px;
}

/* =============================================
   Empty State
   ============================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* =============================================
   Add Task Button
   ============================================= */
.add-task-btn {
    position: fixed;
    bottom: 24px;
    left: 16px;
    right: 16px;
    max-width: 568px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    background: var(--accent-color);
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.4);
}

.add-task-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.add-task-icon {
    font-size: 20px;
    font-weight: 700;
}

/* =============================================
   Loading & Error
   ============================================= */
.loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger-color);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
    text-align: center;
}

/* =============================================
   Create Task Form
   ============================================= */
.create-form {
    padding: 16px 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.flex-1 {
    min-width: 0;
}

input[type="text"],
select {
    display: block;
    width: 100%;
    padding: 14px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

input[type="date"],
input[type="time"] {
    display: block;
    width: 100%;
    padding: 12px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
select:focus {
    border-color: var(--accent-color);
}

.input-large {
    font-size: 18px;
    padding: 16px;
}

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 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

/* Category chips */
.category-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.category-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: 70px;
}

.category-chip input {
    display: none;
}

.category-chip span {
    font-size: 24px;
}

.category-chip small {
    font-size: 11px;
    color: var(--text-secondary);
}

.category-chip.selected {
    border-color: var(--accent-color);
    background: rgba(0, 136, 204, 0.1);
}

/* Quick time chips */
.quick-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-chip {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-chip:hover {
    background: var(--bg-tertiary);
}

/* Weekdays */
.weekdays {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.weekday-chip {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.weekday-chip input {
    display: none;
}

.weekday-chip span {
    font-size: 13px;
    font-weight: 500;
}

.weekday-chip:has(input:checked) {
    background: var(--accent-color);
    color: white;
}

/* =============================================
   Buttons
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    margin-bottom: 12px;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

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

.btn-outline:hover {
    background: var(--bg-secondary);
}

/* =============================================
   Task Detail View
   ============================================= */
.detail-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.detail-category {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.detail-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
}

.detail-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
}

.detail-icon {
    width: 24px;
    text-align: center;
}

.detail-status {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(0, 136, 204, 0.2);
    color: var(--accent-color);
}

.status-badge.done {
    background: rgba(76, 175, 80, 0.2);
    color: var(--success-color);
}

.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =============================================
   Calendar View
   ============================================= */
.calendar-toggle {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 4px;
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 16px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--accent-color);
    color: white;
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    font-size: 16px;
    font-weight: 600;
}

.calendar-content {
    padding: 8px 0;
}

/* Week view */
.week-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.week-day {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.week-day:hover {
    background: var(--bg-tertiary);
}

.week-day.today {
    border: 2px solid var(--accent-color);
}

.week-day-date {
    text-align: center;
    min-width: 50px;
}

.week-day-name {
    font-size: 12px;
    color: var(--text-secondary);
}

.week-day-num {
    font-size: 20px;
    font-weight: 600;
}

.week-day-tasks {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.week-task {
    font-size: 13px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.week-task.done {
    opacity: 0.5;
    text-decoration: line-through;
}

.week-task-more {
    color: var(--accent-color);
    background: transparent;
}

.week-task-empty {
    color: var(--text-secondary);
    background: transparent;
}

/* Month view */
.month-view {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.month-day-header {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.month-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.month-day:hover {
    background: var(--bg-tertiary);
}

.month-day.today {
    background: var(--accent-color);
    color: white;
}

.month-day.other-month {
    opacity: 0.3;
}

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

.month-day-dots {
    display: flex;
    gap: 2px;
}

.month-day-dot {
    width: 4px;
    height: 4px;
    background: var(--accent-color);
    border-radius: 50%;
}

.month-day.today .month-day-dot {
    background: white;
}

/* Selected day tasks */
.selected-day-tasks {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    display: none;
}

.day-tasks-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: capitalize;
}

.day-tasks-empty {
    color: var(--text-secondary);
    font-size: 14px;
}

.day-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.day-task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
}

.day-task-item.done {
    opacity: 0.6;
}

.day-task-time {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 45px;
}

.day-task-title {
    flex: 1;
    font-size: 14px;
}

.day-task-status {
    color: var(--success-color);
}

/* =============================================
   Settings View
   ============================================= */
.settings-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.settings-section h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.settings-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: none;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
}

.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-tertiary);
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

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

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

/* Theme selector */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-option.selected {
    border-color: var(--accent-color);
}

.theme-preview {
    width: 100%;
    height: 40px;
    border-radius: 8px;
}

.theme-option span {
    font-size: 12px;
    color: var(--text-secondary);
}

/* =============================================
   Modal
   ============================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-small {
    max-width: 320px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

/* Snooze modal */
.snooze-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.snooze-btn {
    padding: 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.snooze-btn:hover {
    background: var(--bg-tertiary);
}

/* =============================================
   Tooltip / Onboarding
   ============================================= */
.tooltip {
    position: fixed;
    bottom: 100px;
    left: 16px;
    right: 16px;
    background: var(--accent-color);
    color: white;
    padding: 16px;
    border-radius: 16px;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 136, 204, 0.5);
}

.tooltip-content {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.tooltip-close {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

/* =============================================
   Responsive
   ============================================= */
/* Responsive */
@media (max-width: 380px) {
    .category-chip {
        padding: 10px 12px;
    }
    
    .quick-chip {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .task-card-more {
        display: none;
    }
    
    .category-row {
        gap: 6px;
    }
    
    .category-chip {
        min-width: 60px;
        padding: 8px 10px;
    }
    
    .category-chip span {
        font-size: 20px;
    }
    
    .category-chip small {
        font-size: 10px;
    }
}
