/* ============================================
   TaskFlow Pro — Stylesheet
   Modern, elegant, white, responsive
   ============================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --accent: #f59e0b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;

    --bg: #f8f9fc;
    --white: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --sidebar-w: 250px;
    --topbar-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 24px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.08);

    --font: 'DM Sans', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}
.sidebar-logo span { color: var(--primary); }

.sidebar-close {
    display: none;
    background: none; border: none;
    font-size: 1.2rem; color: var(--text-secondary);
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0.75rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.nav-item i { width: 20px; text-align: center; font-size: 1rem; }

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

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.logout-btn { color: var(--danger) !important; }
.logout-btn:hover { background: #fef2f2 !important; }

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none; border: none;
    font-size: 1.3rem; color: var(--text);
    cursor: pointer;
}

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    flex: 1;
}

.today-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.content-area {
    padding: 1.75rem 2rem;
}

/* ---- Cards ---- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ---- Grid Layouts ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-icon.purple { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: var(--success); }
.stat-icon.orange { background: #fffbeb; color: var(--warning); }
.stat-icon.red { background: #fef2f2; color: var(--danger); }
.stat-icon.blue { background: #eff6ff; color: #3b82f6; }

.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.btn-secondary { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--white); border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: #f0fdf4; color: var(--success); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg);
    transition: all 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

select.form-control {
    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='%2394a3b8' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

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

.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* ---- Modal ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-backdrop.show { display: flex; }

.modal {
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-close {
    background: none; border: none;
    font-size: 1.2rem; color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    transition: all 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ---- Tables ---- */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--white);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfe; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-active { background: #f0fdf4; color: #16a34a; }
.badge-paused { background: #fffbeb; color: #d97706; }
.badge-completed { background: var(--primary-light); color: var(--primary); }
.badge-archived { background: var(--bg); color: var(--text-muted); }
.badge-pending { background: #eff6ff; color: #3b82f6; }
.badge-in_progress { background: #fffbeb; color: #d97706; }
.badge-cancelled { background: #fef2f2; color: var(--danger); }
.badge-running { background: #f0fdf4; color: #16a34a; }

.badge-low { background: #f0fdf4; color: #16a34a; }
.badge-medium { background: #eff6ff; color: #3b82f6; }
.badge-high { background: #fffbeb; color: #d97706; }
.badge-urgent { background: #fef2f2; color: var(--danger); }

/* ---- Color dot ---- */
.color-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.4rem;
    flex-shrink: 0;
}

/* ---- Activity Timeline ---- */
.timeline { list-style: none; }
.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border-light);
}
.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 0.5rem;
    flex-shrink: 0;
}

.timeline-content { flex: 1; }
.timeline-title { font-weight: 600; font-size: 0.88rem; }
.timeline-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.timeline-duration {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary);
    white-space: nowrap;
}

/* ---- Notes Grid ---- */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.note-card {
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
    background: var(--white);
    position: relative;
    transition: all 0.2s;
    cursor: default;
}
.note-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.note-card.pinned { border-color: var(--warning); }
.note-card.pinned::before {
    content: '📌';
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 0.85rem;
}

.note-card-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.5rem; }
.note-card-body { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; max-height: 120px; overflow: hidden; }
.note-card-footer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.note-actions { display: flex; gap: 0.35rem; }
.note-actions button {
    background: none; border: none;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: all 0.15s;
}
.note-actions button:hover { background: var(--bg); color: var(--text); }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; display: block; opacity: 0.3; }
.empty-state p { font-size: 0.9rem; }

/* ---- Calendar Custom ---- */
.fc {
    --fc-border-color: var(--border);
    --fc-today-bg-color: var(--primary-light);
    --fc-event-bg-color: var(--primary);
    --fc-event-border-color: var(--primary);
    font-family: var(--font) !important;
}
.fc .fc-button { border-radius: var(--radius-sm) !important; font-family: var(--font); font-weight: 600; font-size: 0.82rem; }
.fc .fc-button-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--primary-dark) !important; }
.fc .fc-toolbar-title { font-size: 1.1rem !important; font-weight: 700 !important; }
.fc .fc-col-header-cell-cushion { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.fc .fc-daygrid-day-number { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.fc .fc-event { border-radius: 5px !important; padding: 2px 5px; font-size: 0.78rem; }

/* ---- Action Bar ---- */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.action-bar-right { display: flex; gap: 0.5rem; align-items: center; }

/* ---- Filter Tabs ---- */
.filter-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--bg);
    padding: 4px;
    border-radius: var(--radius-sm);
}
.filter-tab {
    padding: 0.4rem 0.9rem;
    border: none;
    background: none;
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.filter-tab.active {
    background: var(--white);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ---- Task List ---- */
.task-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}
.task-item:hover { background: #fafbfe; }

.task-check {
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    background: none;
}
.task-check:hover { border-color: var(--primary); }
.task-check.done { background: var(--success); border-color: var(--success); color: #fff; font-size: 0.65rem; }

.task-info { flex: 1; min-width: 0; }
.task-title { font-size: 0.88rem; font-weight: 500; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }
.task-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; display: flex; gap: 0.75rem; }

.task-actions { display: flex; gap: 0.25rem; opacity: 0; transition: opacity 0.15s; }
.task-item:hover .task-actions { opacity: 1; }

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
}

.login-box {
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    padding: 3rem;
}

.login-logo {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}
.login-logo span { color: var(--primary); }
.login-subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 2rem; }

/* ---- Responsive ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 90;
}

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .sidebar-overlay.show { display: block; }

    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }

    .content-area { padding: 1rem; }
    .topbar { padding: 0 1rem; }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }

    .action-bar { flex-direction: column; align-items: stretch; }
    .action-bar-right { justify-content: flex-end; }

    .notes-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .login-box { padding: 2rem 1.5rem; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.35rem; }
}

/* ---- Chart Container ---- */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ---- Timer Display ---- */
.timer-display {
    font-family: var(--mono);
    font-size: 2rem;
    font-weight: 500;
    color: var(--primary);
    text-align: center;
    padding: 1rem;
    letter-spacing: 0.05em;
}

.timer-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

/* ---- Pulse Animation ---- */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulse { animation: pulse 2s ease-in-out infinite; }

/* ---- Project Colors Indicator ---- */
.project-color-bar {
    width: 4px;
    border-radius: 2px;
    align-self: stretch;
    flex-shrink: 0;
}

/* ---- Utility ---- */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.font-mono { font-family: var(--mono); }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
