/* ============================================
   Layout: app shell, sidebar, header
   ============================================ */

#app-container { display: flex; min-height: 100vh; }

/* Sidebar Overlay (mobile drawer) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ---------- Sidebar ---------- */
#sidebar {
    width: var(--sidebar-width-expanded);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    transition: var(--transition-sidebar);
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    min-height: 44px;
}

.logo-icon { font-size: 1.5rem; color: var(--accent-blue); flex-shrink: 0; }
.app-title { font-size: 1.2rem; font-weight: 700; overflow: hidden; white-space: nowrap; flex: 1; }

/* Collapse chevron inside sidebar header */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    padding: 0;
}

.sidebar-toggle-btn:hover {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}

#sidebar.collapsed .sidebar-toggle-btn i { transform: rotate(180deg); }
#sidebar.collapsed .sidebar-toggle-btn { position: static; margin-top: 0.5rem; }
#sidebar.collapsed .sidebar-header { flex-direction: column; gap: 0.25rem; }

/* Mobile close button (reuses same element on small screens) */
@media (max-width: 768px) {
    .sidebar-toggle-btn {
        position: absolute;
        right: 0;
        top: 1.5rem;
        width: 32px;
        height: 32px;
    }
    .sidebar-toggle-btn i { transform: none !important; }
}

/* Navigation */
nav ul { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; margin: 0; padding: 0; }

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.2s;
}

.nav-item a i { width: 20px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
.nav-item a:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.nav-item.active a {
    background: var(--accent-blue);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

/* Categories */
.sidebar-section { margin-top: 1.5rem; }

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.9rem 0.6rem;
}

.sidebar-section-title i { font-size: 0.7rem; cursor: pointer; transition: color 0.2s; }
.sidebar-section-title i:hover { color: var(--accent-blue); }

.category-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin: 0;
    padding: 0;
}

.category-nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
}

.category-nav-item i { width: 20px; text-align: center; font-size: 0.85rem; flex-shrink: 0; }
.category-nav-item span:nth-child(2) { flex: 1; }
.category-nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.category-nav-item.active {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}

.category-count {
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.1rem 0.5rem;
    border-radius: 99px;
    min-width: 26px;
    text-align: center;
}

.category-nav-item.active .category-count {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
}

/* User profile */
.user-profile { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem; border-radius: var(--radius-md); }
.user-profile img { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.user-info { display: flex; flex-direction: column; overflow: hidden; }
#user-name { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#user-email { font-size: 0.72rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Collapsed sidebar (desktop) ---------- */
#sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
    padding: 1.5rem 0.6rem 1rem;
}

#sidebar.collapsed .app-title,
#sidebar.collapsed .user-info,
#sidebar.collapsed .sidebar-section-title,
#sidebar.collapsed .category-nav-item span,
#sidebar.collapsed .nav-item a span {
    display: none;
}

#sidebar.collapsed .nav-item a,
#sidebar.collapsed .category-nav-item {
    justify-content: center;
    padding: 0.7rem;
}

#sidebar.collapsed .category-count { display: none; }
#sidebar.collapsed .sidebar-footer { align-items: stretch; }
#sidebar.collapsed .user-profile { justify-content: center; padding: 0.5rem 0; }
#sidebar.collapsed #google-signin-btn { display: flex; justify-content: center; }
#sidebar.collapsed #logout-button { padding: 0.5rem; }
#sidebar.collapsed #logout-button i { margin: 0; }

/* ---------- Main content ---------- */
#main-content {
    margin-left: var(--sidebar-width-expanded);
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1500px;
    transition: var(--transition-main);
    min-width: 0;
}

body.sidebar-collapsed #main-content {
    margin-left: var(--sidebar-width-collapsed);
}

/* Header */
#main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.75rem;
    gap: 1rem;
}

.header-left { display: flex; align-items: flex-start; gap: 0.5rem; }

.header-left h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 0.3rem; letter-spacing: -0.02em; white-space: nowrap; }
.header-left p { color: var(--text-secondary); font-size: 0.95rem; margin: 0; }

.header-right { display: flex; align-items: center; gap: 0.65rem; flex-shrink: 0; }

/* Quick add button in header */
.btn-header-add { padding: 0.55rem 1rem; font-size: 0.85rem; border-radius: 12px; height: 42px; }

/* Icon buttons (bell, settings, theme) */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
    font-size: 1rem;
    padding: 0;
}

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

.icon-btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.mobile-menu-btn { display: none; }

/* View sections */
.view-section { display: none; }
.view-section.active { display: block !important; }

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        width: var(--sidebar-width-mobile);
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    #sidebar.mobile-open { transform: translateX(0); }

    #main-content { margin-left: 0; padding: 1.25rem 1rem; }
    body.sidebar-collapsed #main-content { margin-left: 0; }

    .mobile-menu-btn { display: flex; }
    .sidebar-toggle-btn { display: none; }

    .header-left h1 { font-size: 1.3rem; }
    .header-left p { font-size: 0.8rem; }
    #main-header { flex-direction: column; align-items: stretch; }
    .header-right { justify-content: flex-end; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    #main-content { padding: 1.5rem 1.75rem; }
}

/* ---- Feature: horizontal folder row in project detail ---- */
.folder-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 2px;
}
.folder-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary, var(--bg-primary));
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.folder-chip i { color: var(--accent-blue, #3b82f6); }
.folder-chip:hover { background: var(--bg-hover, rgba(59, 130, 246, 0.08)); border-color: var(--accent-blue, #3b82f6); }
.folder-chip.selected {
    background: var(--accent-blue, #3b82f6);
    border-color: var(--accent-blue, #3b82f6);
    color: #fff;
}
.folder-chip.selected i { color: #fff; }
.folder-chip:focus-visible { outline: 2px solid var(--accent-blue, #3b82f6); outline-offset: 2px; }
.folder-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 10px 0 16px;
}

/* ---- Feature: clickable sign-in link ---- */
.signin-link {
    color: var(--accent-blue, #3b82f6);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    border-radius: 4px;
}
.signin-link:hover { color: var(--accent-blue-hover, #2563eb); }
.signin-link:focus-visible { outline: 2px solid var(--accent-blue, #3b82f6); outline-offset: 2px; }

/* ---- Feature: Settings > Notifications ---- */
.settings-card { max-width: 720px; }
.settings-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem; }
.settings-section-head { display: flex; align-items: center; justify-content: space-between; margin: 1.25rem 0 0.5rem; }
.push-perm-box { background: var(--bg-secondary, var(--bg-primary)); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 1rem; }
.push-perm-box .btn { margin-top: 0.5rem; }
.push-device-list { list-style: none; margin: 0; padding: 0; }
.push-device-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; }
.push-device-item.inactive { opacity: 0.6; }
.push-device-name { flex: 1; }
.push-muted { color: var(--text-secondary); font-size: 0.85rem; }
.push-help summary { cursor: pointer; font-weight: 600; }
.push-help ol { margin: 0.5rem 0 0 1.25rem; font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }
.push-status-msg { display: none; margin-top: 0.75rem; padding: 8px 12px; border-radius: var(--radius-md); font-size: 0.88rem; background: var(--bg-secondary, var(--bg-primary)); }
.push-status-msg.visible { display: block; }
.push-status-msg.error { color: var(--accent-red, #ef4444); }

/* ---- Feature: phone reminder prompt (after task creation) ---- */
.reminder-prompt-overlay { z-index: 1200; }
.reminder-prompt-modal { max-width: 460px; width: 92%; }
.reminder-prompt-body p { margin: 0.35rem 0; }
.reminder-choice-row, .reminder-confirm-row, .reminder-dt-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 1rem; }
.reminder-dt-row { justify-content: flex-start; }
.reminder-dt-row .form-group { flex: 1; }

/* ---- Feature: task highlight from notification deep-link ---- */
.task-highlight-flash { animation: taskFlash 2s ease; }
@keyframes taskFlash {
    0%, 100% { background: transparent; }
    20%, 60% { background: rgba(59, 130, 246, 0.18); }
}
.signin-link-flash { animation: signinFlash 1.5s ease; }
@keyframes signinFlash {
    0%, 100% { box-shadow: none; }
    30% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5); }
}
