@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Futuristic Color Palette */
    --bg-primary: #0a0514; /* Deep dark purple almost black */
    --bg-secondary: #130a26; /* Slightly lighter deep purple */
    --bg-glass: rgba(26, 15, 46, 0.4);
    
    --primary-accent: #7b2cbf; /* Rich purple */
    --primary-light: #9d4edd;
    --primary-glow: rgba(123, 44, 191, 0.5);
    
    --secondary-accent: #00f5ff; /* Neon cyan */
    --secondary-glow: rgba(0, 245, 255, 0.5);
    
    --text-primary: #ffffff;
    --text-secondary: #a098b0;
    --text-muted: #6b637a;

    /* Status Colors */
    --success: #00e676;
    --success-bg: rgba(0, 230, 118, 0.1);
    --warning: #ffb300;
    --warning-bg: rgba(255, 179, 0, 0.1);
    --danger: #ff1744;
    --danger-bg: rgba(255, 23, 68, 0.1);
    --info: #00b0ff;
    --info-bg: rgba(0, 176, 255, 0.1);

    /* Glassmorphism & Borders */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --border-radius-full: 9999px;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --header-height: 70px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f4f6fa;
    --bg-secondary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    
    --text-primary: #1a1525;
    --text-secondary: #5a5266;
    --text-muted: #8e879c;
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    position: relative;
    line-height: 1.5;
}

/* Media should scale proportionally */
img,
video,
canvas,
svg {
    max-width: 100%;
    height: auto;
}

iframe {
    max-width: 100%;
}

/* Animated Background Glows */
body::before, body::after {
    content: '';
    position: fixed;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.4;
    animation: drift 20s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

body::before {
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    top: -20%;
    left: -10%;
}

body::after {
    background: radial-gradient(circle, var(--secondary-glow) 0%, transparent 70%);
    bottom: -20%;
    right: -10%;
    animation-delay: -10s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.1); }
}

/* Typography elements */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

p {
    font-size: clamp(0.95rem, 0.92rem + 0.25vw, 1.05rem);
}

h1 { font-size: clamp(1.8rem, 1.4rem + 2.2vw, 3rem); }
h2 { font-size: clamp(1.4rem, 1.2rem + 1.4vw, 2.1rem); }
h3 { font-size: clamp(1.25rem, 1.1rem + 1.1vw, 1.9rem); }
h4 { font-size: clamp(1.05rem, 1rem + 0.7vw, 1.35rem); }

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

/* Accessible focus states */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid var(--secondary-accent);
    outline-offset: 3px;
}

ul {
    list-style: none;
}

/* App Layout */
.app-container {
    display: block;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    transition: width var(--transition-normal), transform var(--transition-normal);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 1.5rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    gap: 12px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--glass-border);
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.brand-text {
    transition: opacity var(--transition-fast);
    white-space: nowrap;
}

.sidebar.collapsed .brand-text {
    opacity: 0;
    pointer-events: none;
}

.nav-menu {
    flex: 1;
    padding: 24px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-menu::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    gap: 16px;
    transition: all var(--transition-fast);
    cursor: pointer;
    font-weight: 500;
    overflow: hidden;
}

.nav-item i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .nav-text {
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-item .nav-text {
    opacity: 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, var(--primary-accent), rgba(123, 44, 191, 0.1));
    color: var(--text-primary);
    border-left: 3px solid var(--secondary-accent);
}

.nav-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 16px 16px;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 95;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.no-scroll {
    overflow: hidden;
}

/* Main Content Area */
.main-content {
    width: 100%;
    margin-left: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-normal), width var(--transition-normal);
    min-height: 100vh;
    overflow-x: hidden;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(1rem, 2vw, 2rem);
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color var(--transition-fast);
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toggle-sidebar:hover {
    color: var(--secondary-accent);
}

.search-bar {
    position: relative;
    width: min(22rem, 45vw);
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-full);
    padding: 10px 16px 10px 44px;
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition-fast);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(255, 255, 255, 0.05);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.icon-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.icon-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-accent);
    padding: 2px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Page Content padding */
.page-content {
    padding: clamp(1rem, 2.5vw, 2rem);
    flex: 1;
}

/* Glass Card */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    padding: 24px;
    box-shadow: var(--glass-shadow);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1.1rem;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    outline: none;
    min-height: 44px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: var(--border-radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-badge.success { background: var(--success-bg); color: var(--success); }
.status-badge.warning { background: var(--warning-bg); color: var(--warning); }
.status-badge.danger { background: var(--danger-bg); color: var(--danger); }
.status-badge.info { background: var(--info-bg); color: var(--info); }

/* Forms & Inputs */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(255, 255, 255, 0.05);
}

select.form-control option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn var(--transition-normal) forwards;
}

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

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.template-layout {
    display: flex;
    gap: 1.5rem;
}

/* Mobile-first layout defaults */
.main-content { margin-left: 0; }
.sidebar.mobile-open { transform: translateX(0); }
.search-bar { display: none; }

.d-flex.justify-between.align-center {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

/* Prevent stacking inside small components like cards or table headers */
.glass-card .d-flex.justify-between.align-center,
.status-badge .d-flex.justify-between.align-center,
.nav-item .d-flex.justify-between.align-center {
    flex-direction: row;
    align-items: center;
}

@media (min-width: 480px) {
    .header-right { gap: 1rem; }
}

@media (min-width: 768px) {
    .sidebar { transform: translateX(0); }
    .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
    .search-bar { display: block; }

    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .d-flex.justify-between.align-center {
        flex-direction: row;
        align-items: center;
    }

    .template-layout {
        flex-direction: row;
    }
}

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

@media (min-width: 1280px) {
    .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Tables */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.modern-table th {
    padding: 16px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
}

.modern-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    vertical-align: middle;
}

.modern-table tbody tr {
    transition: background var(--transition-fast);
}

.modern-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Utility Classes */
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.text-gradient {
    background: linear-gradient(135deg, var(--secondary-accent), var(--primary-accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    padding: 16px 24px;
    color: var(--text-primary);
    box-shadow: var(--glass-shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.toast.show {
    transform: translateX(0);
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--primary-accent);
}

.toast.success::before { background: var(--success); }
.toast.info::before { background: var(--info); }
.toast.warning::before { background: var(--warning); }
.toast.danger::before { background: var(--danger); }

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.info .toast-icon { color: var(--info); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.danger .toast-icon { color: var(--danger); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
    font-family: 'Outfit', sans-serif;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

/* Animations for toast progress bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
}

.toast-progress-bar {
    height: 100%;
    width: 100%;
    background: var(--primary-accent);
    transform-origin: left;
    animation: toastProgress 4s linear forwards;
}

.toast.success .toast-progress-bar { background: var(--success); }
.toast.info .toast-progress-bar { background: var(--info); }
.toast.warning .toast-progress-bar { background: var(--warning); }
.toast.danger .toast-progress-bar { background: var(--danger); }

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ===== Settings Page — Fully Responsive (CSS-only, no HTML changes) ===== */

/* ---- Mobile-first: all breakpoints below 768px ---- */

/* 1. Force template-layout (sidebar + content) to STACK vertically on mobile */
.page-content .template-layout {
    flex-direction: column !important;
}

/* 2. Override inline width:250px on the settings nav — go full width on mobile */
.settings-nav {
    width: 100% !important;
    flex-shrink: 0 !important;
    min-width: 0 !important;
}

/* 3. The content area (inline flex:1) must not overflow on mobile */
.template-layout > div[style*="flex: 1"] {
    min-width: 0 !important;
    width: 100% !important;
}

/* 4. Reset span-2 grid-columns so they stay in 1 column on mobile */
#profile .grid-2 .form-group[style*="grid-column"],
#security .grid-2 .form-group[style*="grid-column"] {
    grid-column: span 1 !important;
}

/* 5. Wrap avatar + upload button row on very small screens */
@media (max-width: 480px) {
    #profile .d-flex.align-center.gap-3.mb-4 {
        flex-wrap: wrap;
    }
    #profile-img-preview {
        flex-shrink: 0;
    }

    /* Workspace URL prefix + input: stack them */
    #workspace .d-flex.align-center {
        flex-direction: column;
        align-items: stretch;
    }
    #workspace .d-flex.align-center span {
        border-right: 1px solid var(--glass-border) !important;
        border-bottom: none;
        border-radius: 8px 8px 0 0 !important;
    }
    #workspace .d-flex.align-center .form-control {
        border-radius: 0 0 8px 8px !important;
    }

    /* 2FA row: stack the button below text on tiny screens */
    #security .d-flex.justify-between.align-center[style*="background"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
    }
}

/* ---- Tablet / Desktop: 768px and above ---- */
@media (min-width: 768px) {
    /* Restore side-by-side layout */
    .page-content .template-layout {
        flex-direction: row !important;
    }

    /* Restore fixed sidebar width */
    .settings-nav {
        width: 250px !important;
        flex-shrink: 0 !important;
    }

    /* Content area takes remaining space */
    .template-layout > div[style*="flex: 1"] {
        width: auto !important;
    }

    /* Restore span-2 now that .grid-2 has 2 columns */
    #profile .grid-2 .form-group[style*="grid-column"],
    #security .grid-2 .form-group[style*="grid-column"] {
        grid-column: span 2 !important;
    }
}


