/* ===== CUSTOM PROPERTIES ===== */
:root {
    --bg-body: #0a0a14;
    --bg-card: #16162a;
    --bg-hover: #1c1c35;
    --bg-sidebar: #080812;
    --bg-input: #1c1c35;
    --border: #232340;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #6c6bfa;
    --accent-hover: #8281fb;
    --danger: #ef4444;
    --success: #34d399;
    --warning: #f59e0b;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
    --bg-body: #f5f5f5;
    --bg-card: #ffffff;
    --bg-hover: #f3f4f6;
    --bg-sidebar: #1a1a2e;
    --bg-input: #f3f4f6;
    --border: #e5e7eb;
    --text-primary: #1a1a2e;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --accent: #5b5af7;
    --accent-hover: #6c6bfa;
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0a0a14;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loading-logo {
    animation: logoPulse 1.5s ease-in-out infinite;
    margin-bottom: 1.5rem;
}
.loading-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.25rem;
}
.loading-title .text-accent {
    color: var(--accent);
}
.loading-subtitle {
    font-size: 0.75rem;
    color: #6b7280;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 2rem;
}
.loading-bar {
    width: 12rem;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    overflow: hidden;
}
.loading-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 9999px;
    animation: loadingBar 3s ease-in-out forwards;
}
@keyframes logoPulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}
@keyframes loadingBar {
    0% {
        width: 0%;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
    }
}

/* ===== AUTH SCREEN ===== */
.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-body);
}
.auth-screen.hidden {
    display: none;
}
.auth-card {
    width: 100%;
    max-width: 24rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transition: background 0.3s, border-color 0.3s;
}
.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    background: var(--accent);
    margin-bottom: 0.75rem;
}
.auth-icon-text {
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
}
.auth-title {
    font-size: 1.25rem;
    font-weight: 700;
}
.auth-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.auth-form.hidden {
    display: none;
}
.auth-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}
.auth-input:focus {
    border-color: var(--accent);
}
.auth-input::placeholder {
    color: var(--text-muted);
}
.auth-btn {
    width: 100%;
    padding: 0.5rem;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}
.auth-btn:hover {
    background: var(--accent-hover);
}
.auth-switch {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.auth-link {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}
.auth-link:hover {
    text-decoration: underline;
}

/* ===== APP LAYOUT ===== */
.app {
    display: flex;
    min-height: 100vh;
}
.app.hidden {
    display: none;
}

/* ===== SIDEBAR ===== */
.sidebar {
    display: none;
    flex-direction: column;
    width: 250px;
    position: fixed;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    z-index: 100;
    padding: 1.75rem;
    transition: background 0.3s, border-color 0.3s;
}
@media (min-width: 768px) {
    .sidebar {
        display: flex;
    }
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    padding-left: 0.25rem;
}
.sidebar-brand-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.025em;
}
.sidebar-brand-text .text-accent {
    color: var(--accent);
    font-weight: 400;
}
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}
.sidebar-link:hover {
    color: #d1d5db;
    background: rgba(255, 255, 255, 0.05);
}
.sidebar-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}
.sidebar-link .sidebar-icon {
    width: 1.25rem;
    text-align: center;
    opacity: 0.7;
}
.sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin: 0.5rem 0.5rem;
}
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: auto;
}
.sidebar-theme {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
}
.sidebar-theme-label {
    font-size: 0.875rem;
    color: #6b7280;
}
.theme-toggle {
    width: 2.75rem;
    height: 1.5rem;
    background: var(--accent);
    border: none;
    border-radius: 9999px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.theme-toggle::after {
    content: '';
    position: absolute;
    width: 1.125rem;
    height: 1.125rem;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.2s;
}
[data-theme="light"] .theme-toggle::after {
    transform: translateX(1.25rem);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    padding: 1rem;
    padding-bottom: 6rem;
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
    transition: background 0.3s;
}
@media (min-width: 768px) {
    .main-content {
        margin-left: 250px;
        padding: 2rem;
        padding-bottom: 2rem;
    }
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
    padding: 0.375rem 0.5rem;
    transition: background 0.3s, border-color 0.3s;
}
@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }
}
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.625rem;
    font-weight: 500;
    color: #6b7280;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.15s;
}
.bottom-nav-item.active {
    color: var(--accent);
}
.bottom-nav-item .bottom-nav-icon {
    font-size: 1.25rem;
    line-height: 1.25rem;
}
.bottom-nav-item .bottom-nav-label {
    font-size: 0.625rem;
    line-height: 1;
}
.bottom-nav-more {
    position: relative;
}
.more-menu {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.375rem;
    min-width: 150px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    z-index: 300;
    transition: background 0.3s, border-color 0.3s;
}
.more-menu.hidden {
    display: none;
}
.more-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #d1d5db;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.more-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.more-menu-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin: 0.25rem 0;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 24rem;
    width: 100%;
    pointer-events: none;
}
.toast {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    animation: slideIn 0.3s ease;
    transition: opacity 0.3s, transform 0.3s;
}
.toast-success {
    background: var(--success);
}
.toast-error {
    background: var(--danger);
}
.toast-warning {
    background: var(--warning);
}
.toast-info {
    background: var(--accent);
}
.toast-exit {
    opacity: 0;
    transform: translateX(100px);
}
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== LOG ERROR BUTTON & MODAL ===== */
.log-error-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 500;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.log-error-btn:hover {
    transform: scale(1.05);
    background: var(--bg-hover);
}
@media (min-width: 768px) {
    .log-error-btn {
        bottom: 30px;
        right: 30px;
    }
}
.log-error-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 1rem;
}
.log-error-modal.hidden {
    display: none;
}
.log-error-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.log-error-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.log-error-header h3 {
    margin: 0;
    font-size: 1rem;
}
.log-error-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.log-error-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1.5rem;
    font-size: 0.85rem;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
}
.log-error-list .error-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.log-error-list .error-item .error-time {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-right: 0.5rem;
}
.log-error-list .error-item .error-msg {
    color: var(--danger);
}
.log-error-footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}
.log-error-clear {
    background: var(--danger);
    color: #fff;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
}
.log-error-clear:hover {
    opacity: 0.8;
}

/* ===== UTILITY CLASSES ===== */
.bg-card {
    background: var(--bg-card);
}
.bg-hover {
    background: var(--bg-hover);
}
.bg-sidebar {
    background: var(--bg-sidebar);
}
.border-theme {
    border-color: var(--border);
}
.text-secondary {
    color: var(--text-secondary);
}
.text-muted {
    color: var(--text-muted);
}
.text-accent {
    color: var(--accent);
}
.bg-accent {
    background: var(--accent);
}
.bg-accent-hover:hover {
    background: var(--accent-hover);
}
.border-accent {
    border-color: var(--accent);
}

/* Grid & Flex */
.grid {
    display: grid;
}
.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}
@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
@media (min-width: 1024px) {
    .lg\:grid-cols-\[280px_1fr\] {
        grid-template-columns: 280px 1fr;
    }
}
.gap-2 {
    gap: 0.5rem;
}
.gap-3 {
    gap: 0.75rem;
}
.gap-4 {
    gap: 1rem;
}
.space-y-1>*+* {
    margin-top: 0.25rem;
}
.space-y-2>*+* {
    margin-top: 0.5rem;
}
.space-y-3>*+* {
    margin-top: 0.75rem;
}
.space-y-4>*+* {
    margin-top: 1rem;
}

/* Text */
.text-xs {
    font-size: 0.75rem;
}
.text-sm {
    font-size: 0.875rem;
}
.text-lg {
    font-size: 1.125rem;
}
.text-xl {
    font-size: 1.25rem;
}
.text-2xl {
    font-size: 1.5rem;
}
.font-bold {
    font-weight: 700;
}
.font-semibold {
    font-weight: 600;
}
.uppercase {
    text-transform: uppercase;
}
.tracking-wider {
    letter-spacing: 0.05em;
}
.leading-none {
    line-height: 1;
}

/* Flex */
.flex {
    display: flex;
}
.items-center {
    align-items: center;
}
.items-start {
    align-items: flex-start;
}
.justify-between {
    justify-content: space-between;
}
.flex-1 {
    flex: 1 1 0%;
}
.flex-col {
    flex-direction: column;
}

/* Spacing */
.p-2 {
    padding: 0.5rem;
}
.p-3 {
    padding: 0.75rem;
}
.p-4 {
    padding: 1rem;
}
.p-6 {
    padding: 1.5rem;
}
.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}
.px-3 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}
.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}
.py-1\.5 {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}
.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}
.py-3 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}
.m-0 {
    margin: 0;
}
.mb-1 {
    margin-bottom: 0.25rem;
}
.mb-2 {
    margin-bottom: 0.5rem;
}
.mb-3 {
    margin-bottom: 0.75rem;
}
.mb-4 {
    margin-bottom: 1rem;
}
.mb-6 {
    margin-bottom: 1.5rem;
}
.mt-2 {
    margin-top: 0.5rem;
}
.mt-4 {
    margin-top: 1rem;
}
.ml-auto {
    margin-left: auto;
}
.mr-2 {
    margin-right: 0.5rem;
}
.rounded-lg {
    border-radius: 0.5rem;
}
.rounded-xl {
    border-radius: 0.75rem;
}
.rounded-2xl {
    border-radius: 1rem;
}
.rounded-full {
    border-radius: 9999px;
}
.border {
    border: 1px solid var(--border);
}
.border-b {
    border-bottom: 1px solid var(--border);
}
.border-t {
    border-top: 1px solid var(--border);
}
.border-l-4 {
    border-left-width: 4px;
}
.border-l-accent {
    border-left-color: var(--accent);
}
.border-accent {
    border-color: var(--accent);
}
.overflow-hidden {
    overflow: hidden;
}
.overflow-y-auto {
    overflow-y: auto;
}
.overflow-x-auto {
    overflow-x: auto;
}
.w-full {
    width: 100%;
}
.max-w-lg {
    max-width: 32rem;
}
.h-full {
    height: 100%;
}
.min-h-\[450px\] {
    min-height: 450px;
}
.h-\[calc\(100vh-160px\)\] {
    height: calc(100vh - 160px);
}
.h-1\.5 {
    height: 0.375rem;
}
.h-2 {
    height: 0.5rem;
}
.w-2 {
    width: 0.5rem;
}
.w-24 {
    width: 6rem;
}
.relative {
    position: relative;
}
.absolute {
    position: absolute;
}
.fixed {
    position: fixed;
}
.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}
.z-\[999\] {
    z-index: 999;
}
.z-50 {
    z-index: 50;
}
.hidden {
    display: none;
}
.block {
    display: block;
}
.inline-block {
    display: inline-block;
}
.text-center {
    text-align: center;
}
.text-left {
    text-align: left;
}
.self-start {
    align-self: flex-start;
}
.self-end {
    align-self: flex-end;
}
.opacity-0 {
    opacity: 0;
}
.opacity-50 {
    opacity: 0.5;
}
.group:hover .group-hover\:opacity-100 {
    opacity: 1;
}
.transition-opacity {
    transition: opacity 0.2s;
}
.transition-colors {
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}
.cursor-pointer {
    cursor: pointer;
}
.whitespace-nowrap {
    white-space: nowrap;
}
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.animate-pulse {
    animation: logoPulse 1.5s ease-in-out infinite;
}

/* Responsive overrides */
@media (max-width: 640px) {
    .main-content {
        padding: 0.75rem;
        padding-bottom: 5rem;
    }
    .auth-card {
        padding: 1.25rem;
        border-radius: 0.75rem;
    }
}
@media (min-width: 641px) and (max-width: 768px) {
    .main-content {
        padding: 1rem;
        padding-bottom: 5rem;
    }
}