/* ===== CSS Variables & Theme System (Modern Minimalist / Glassmorphism) ===== */
:root {
    --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme - Clean & Vibrant */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 0 3px rgba(59, 130, 246, 0.3);

    --accent: #3b82f6;
    /* Blue */
    --accent-hover: #2563eb;
    --accent-light: #eff6ff;
    --accent-text: #1d4ed8;

    /* Extra vibrant colors for tabs */
    --color-1: #e0f2fe;
    --color-1-text: #0284c7;
    /* Sky */
    --color-2: #f3e8ff;
    --color-2-text: #7e22ce;
    /* Purple */
    --color-3: #dcfce7;
    --color-3-text: #15803d;
    /* Green */
    --color-4: #ffedd5;
    --color-4-text: #c2410c;
    /* Orange */
    --color-5: #ffe4e6;
    --color-5-text: #be123c;
    /* Rose */

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --code-bg: #f1f5f9;
    --code-text: #e11d48;
    --scrollbar-bg: #f8fafc;
    --scrollbar-thumb: #cbd5e1;
}

/* Dark Theme - Sleek & Modern */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border-color: #334155;
    --border-light: #1e293b;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 0 3px rgba(59, 130, 246, 0.4);

    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-light: rgba(59, 130, 246, 0.15);
    --accent-text: #93c5fd;

    /* Extra vibrant colors for tabs (Dark mode adjusted) */
    --color-1: rgba(14, 165, 233, 0.15);
    --color-1-text: #38bdf8;
    --color-2: rgba(168, 85, 247, 0.15);
    --color-2-text: #c084fc;
    --color-3: rgba(34, 197, 94, 0.15);
    --color-3-text: #4ade80;
    --color-4: rgba(249, 115, 22, 0.15);
    --color-4-text: #fb923c;
    --color-5: rgba(244, 63, 94, 0.15);
    --color-5-text: #fb7185;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --code-bg: #0f172a;
    --code-text: #f43f5e;
    --scrollbar-bg: #0f172a;
    --scrollbar-thumb: #334155;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

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

/* ===== Auth Overlay ===== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.auth-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-box {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 380px;
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: authPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.auth-box h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-box p {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.auth-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}

/* ===== Modern Inputs ===== */
input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition);
    margin-bottom: 16px;
    font-family: var(--font-family);
}

input:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
    background: var(--surface);
}

/* ===== Modern Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-family);
}

.btn:active {
    transform: translateY(1px);
}

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

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

.btn-secondary {
    background: var(--surface);
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1.1rem;
}

.btn-icon:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.btn-full {
    width: 100%;
    margin-top: 8px;
}

/* ===== Top Navigation (Glassmorphism) ===== */
.top-nav {
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .top-nav {
    background: rgba(30, 41, 59, 0.8);
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.nav-brand .brand-icon {
    font-size: 1.4rem;
}

.search-wrapper {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-wrapper input {
    width: 100%;
    margin: 0;
    padding: 10px 16px 10px 42px;
    border-radius: var(--radius-xl);
    background: var(--surface);
}

.search-wrapper .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ===== Tab Bar (Colorful Pills) ===== */
.tab-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 32px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-bar::-webkit-scrollbar {
    height: 0;
}

.tab-item {
    padding: 8px 20px;
    border-radius: var(--radius-xl);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid transparent;
    background: #e0f2fe;
    color: #0369a1;
    transition: all var(--transition);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

[data-theme="dark"] .tab-item {
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
}

.tab-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    filter: brightness(0.95);
}

[data-theme="dark"] .tab-item:hover {
    filter: brightness(1.1);
}

.tab-item.active {
    background: #1e3a8a;
    color: #ffffff;
    border-color: transparent;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

[data-theme="dark"] .tab-item.active {
    background: #2563eb;
    color: #fff;
}

.tab-item .tab-edit-actions {
    display: none;
    gap: 4px;
    margin-left: 4px;
}

.tab-item:hover .tab-edit-actions,
.tab-item.active .tab-edit-actions {
    display: inline-flex;
}

.tab-edit-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(255, 255, 255, 0.3);
    color: inherit;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all var(--transition);
}

[data-theme="dark"] .tab-edit-btn {
    background: rgba(0, 0, 0, 0.2);
}

.tab-edit-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

[data-theme="dark"] .tab-edit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tab-add {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    background: transparent !important;
    border: 2px dashed var(--border-color) !important;
    color: var(--text-muted) !important;
    font-size: 1.2rem;
}

.tab-add:hover {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
    transform: none;
    box-shadow: none;
}

/* ===== Content Area ===== */
.content-area {
    padding: 24px 32px 120px;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sub-tabs header */
.sub-tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

[data-theme="dark"] .sub-tab-header {
    background: rgba(79, 70, 229, 0.15);
    color: #818cf8;
}

.sub-tab-header:hover {
    filter: brightness(0.96);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .sub-tab-header:hover {
    filter: brightness(1.1);
}

.sub-tab-header.active {
    border-color: currentColor;
    box-shadow: 0 0 0 1px currentColor;
}

.sub-tab-title {
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
}

.sub-tab-title .chevron {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
    color: inherit;
    opacity: 0.6;
}

.sub-tab-header.active .chevron {
    transform: rotate(90deg);
    opacity: 1;
}



.sub-tab-count {
    font-size: 0.75rem;
    color: inherit;
    background: rgba(255, 255, 255, 0.4);
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
}

[data-theme="dark"] .sub-tab-count {
    background: rgba(0, 0, 0, 0.2);
}

.sub-tab-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity var(--transition);
}

.sub-tab-header:hover .sub-tab-actions {
    opacity: 1;
}

/* Content cards */
.content-block {
    margin-bottom: 24px;
}

.content-block.hidden {
    display: none;
}

.content-items {
    display: none;
    padding: 4px 0 12px 16px;
    border-left: 2px solid var(--border-color);
    margin-left: 20px;
}

.content-items.open {
    display: block;
    animation: fadeIn 0.2s ease;
}

.content-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition);
    position: relative;
}

.content-item:hover {
    border-color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}

.content-item .item-content {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.content-item .item-content p {
    margin: 0;
}

.content-item .item-content code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Fira Code', 'Consolas', monospace;
    border: 1px solid var(--border-color);
}

.content-item .item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}

.content-item:hover .item-actions {
    opacity: 1;
}

.content-item-simple {
    padding: 16px 20px;
}

.content-item-simple .item-content a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.content-item-simple .item-content a:hover {
    text-decoration: underline;
}

.add-item-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    color: var(--text-muted);
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
    margin-top: 8px;
}

.add-item-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light);
}

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 560px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--border-color);
}

.modal-overlay.open .modal {
    transform: scale(1) translateY(0);
}

.modal h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.modal label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    margin-top: 20px;
}

.modal label:first-of-type {
    margin-top: 0;
}

.modal textarea {
    min-height: 140px;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

.modal .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 32px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    animation: toastSlide 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 380px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.info {
    border-left: 4px solid var(--accent);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

@keyframes toastSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ===== Commit Bar ===== */
.commit-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-xl);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: max-content;
    max-width: 90vw;
}

[data-theme="light"] .commit-bar {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--border-color);
}

.commit-bar.visible {
    transform: translateX(-50%) translateY(0);
}

.commit-bar .changes-info {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

[data-theme="light"] .commit-bar .changes-info {
    color: var(--text-primary);
}

.commit-bar .changes-info strong {
    color: var(--warning);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* ===== Utils ===== */
mark {
    background: var(--warning);
    color: #fff;
    padding: 0 4px;
    border-radius: 4px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.7;
}

.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .top-nav {
        padding: 12px 20px;
        flex-wrap: wrap;
    }

    .search-wrapper {
        order: 3;
        max-width: 100%;
        flex-basis: 100%;
        margin-top: 12px;
    }

    .nav-brand span:not(.brand-icon) {
        display: none;
    }

    .tab-bar {
        padding: 16px 20px 0;
    }

    .content-area {
        padding: 20px 20px 120px;
    }

    .auth-box {
        padding: 32px 24px;
        border-radius: var(--radius-lg);
    }

    .modal {
        padding: 24px;
        width: 95vw;
    }

    .commit-bar {
        bottom: 16px;
        padding: 16px;
        flex-direction: column;
        gap: 16px;
        width: calc(100% - 32px);
        max-width: none;
        border-radius: var(--radius-lg);
    }

    .content-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .content-item .item-actions {
        width: 100%;
        justify-content: flex-end;
        opacity: 1;
        border-top: 1px solid var(--border-light);
        padding-top: 8px;
    }
}