/* ===== Reset & Variables ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1b23;
    --bg-tertiary: #24252e;
    --bg-hover: #2e303a;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-dim: rgba(99, 102, 241, 0.15);
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    --warning: #f59e0b;
    --border: #2e303a;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;

    --priority-low: #22c55e;
    --priority-medium: #f59e0b;
    --priority-high: #ef4444;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

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

/* ===== Sidebar ===== */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.nav-list {
    list-style: none;
    padding: 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

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

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent-hover);
}

.nav-icon {
    font-size: 1.2rem;
}

/* ===== Main Content ===== */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

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

.page-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
}

/* ===== Buttons ===== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

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

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

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

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: all var(--transition);
}

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

/* ===== Calendar ===== */
.calendar-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

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

.calendar-nav h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 8px;
}

.calendar-header span {
    padding: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
    position: relative;
    min-height: 48px;
}

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

.calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.4;
}

.calendar-day.today {
    background: var(--accent-dim);
    color: var(--accent-hover);
    font-weight: 700;
}

.calendar-day.selected {
    background: var(--accent);
    color: #fff;
}

.calendar-day.has-event::after {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    position: absolute;
    bottom: 6px;
}

.calendar-day.today.has-event::after,
.calendar-day.selected.has-event::after {
    background: #fff;
}

/* Day Detail Panel */
.day-detail {
    margin-top: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

.day-detail.hidden {
    display: none;
}

.day-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.events-list {
    margin-bottom: 16px;
}

.event-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.event-item span {
    color: var(--text-primary);
}

.event-time {
    color: var(--text-muted) !important;
    font-size: 0.85rem;
    margin-right: 12px;
}

.event-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition);
}

.event-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.add-event-form {
    display: flex;
    gap: 8px;
}

.add-event-form input[type="text"] {
    flex: 1;
}

/* ===== All Events Page ===== */
.all-events-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

.all-events-header {
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.all-events-list {
    list-style: none;
}

.all-events-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    margin-bottom: 8px;
    border-left: 3px solid var(--accent);
}

.all-events-item-main {
    min-width: 0;
}

.all-events-title {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.all-events-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.all-events-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 16px;
}

/* ===== Input Styles ===== */
input[type="text"],
input[type="time"],
select,
textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition);
    outline: none;
}

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

input[type="text"]::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* ===== Todo List ===== */
.todo-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

.todo-input-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.todo-input-wrapper input {
    flex: 1;
}

.todo-input-wrapper select {
    width: 120px;
}

.todo-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.filter-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

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

.todo-list {
    list-style: none;
    margin-bottom: 16px;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.todo-item.priority-low {
    border-left-color: var(--priority-low);
}

.todo-item.priority-medium {
    border-left-color: var(--priority-medium);
}

.todo-item.priority-high {
    border-left-color: var(--priority-high);
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.todo-checkbox:hover {
    border-color: var(--accent);
}

.todo-item.completed .todo-checkbox {
    background: var(--success);
    border-color: var(--success);
}

.todo-item.completed .todo-checkbox::after {
    content: '✓';
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.todo-text {
    flex: 1;
    font-size: 0.95rem;
}

.todo-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: all var(--transition);
}

.todo-item:hover .todo-delete {
    opacity: 1;
}

.todo-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.todo-stats {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Notes ===== */
.notes-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 140px);
}

.notes-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notes-sidebar input {
    width: 100%;
}

.notes-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.note-list-item {
    padding: 14px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.note-list-item:hover {
    background: var(--bg-hover);
}

.note-list-item.active {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.note-list-item h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-list-item p {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notes-editor {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.note-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 1rem;
}

.note-editor-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
}

.note-editor-area.hidden {
    display: none;
}

#note-title-input {
    font-size: 1.3rem;
    font-weight: 700;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 8px 0;
    margin-bottom: 16px;
}

#note-title-input:focus {
    border-color: var(--accent);
}

#note-content-input {
    flex: 1;
    resize: none;
    background: transparent;
    border: none;
    font-size: 0.95rem;
    line-height: 1.7;
}

#note-content-input:focus {
    border-color: transparent;
}

.note-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

#note-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-header h1,
    .nav-item span:not(.nav-icon) {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .content {
        padding: 20px;
    }

    .notes-container {
        flex-direction: column;
        height: auto;
    }

    .notes-sidebar {
        width: 100%;
        max-height: 200px;
    }

    .notes-editor {
        min-height: 400px;
    }

    .todo-input-wrapper {
        flex-wrap: wrap;
    }

    .add-event-form {
        flex-wrap: wrap;
    }
}