/**
 * ================================
 * SideMind Bot - Design System v4
 * ================================
 *
 * SPA layout (sidebar + content) + unified components
 * Brand: SideMind by Synaptica Solution
 *
 * Version: 4.0
 * Updated: 2026-02-27
 */

/* === GOOGLE FONTS === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* === COLOR PALETTE === */
:root {
    /* Brand Colors */
    --brand-primary: #007acc;
    --brand-light: #00aaff;
    --brand-accent: #00d4ff;
    --brand-dark: #0a0a0f;
    --brand-darker: #050508;

    /* Aliases */
    --primary-color: #007acc;
    --primary-dark: #0066a8;
    --primary-light: #00aaff;
    --secondary-color: #00d4ff;
    --secondary-dark: #00a8cc;
    --secondary-light: #33e0ff;

    /* Surface Colors */
    --surface-dark: #0d0d14;
    --surface-card: #12121a;
    --surface-hover: #1a1a24;
    --surface-border: rgba(255, 255, 255, 0.1);
    --surface-border-light: rgba(255, 255, 255, 0.05);

    /* Background aliases */
    --bg-white: #12121a;
    --bg-light: #0d0d14;
    --bg-gray: #1a1a24;
    --bg-dark: #050508;

    /* Status Colors */
    --success-color: #10b981;
    --success-dark: #059669;
    --success-light: #34d399;
    --danger-color: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #f87171;
    --warning-color: #f59e0b;
    --warning-dark: #d97706;
    --warning-light: #fbbf24;
    --info-color: #3b82f6;
    --info-dark: #2563eb;
    --info-light: #60a5fa;

    /* Status Background */
    --bg-success-light: rgba(16, 185, 129, 0.15);
    --bg-danger-light: rgba(239, 68, 68, 0.15);
    --bg-warning-light: rgba(245, 158, 11, 0.15);
    --bg-info-light: rgba(59, 130, 246, 0.15);

    /* Card/Surface */
    --card-background: #12121a;
    --surface-background: #0d0d14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #22222e;

    /* Text Colors */
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);
    --text-muted: rgba(255, 255, 255, 0.3);

    /* Border Colors */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.05);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 30px rgba(0, 122, 204, 0.2);
    --shadow-glow-success: 0 0 30px rgba(16, 185, 129, 0.2);
    --shadow-glow-danger: 0 0 30px rgba(239, 68, 68, 0.2);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-family-mono: 'Fira Code', 'Monaco', 'Consolas', monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* SPA Layout */
    --sidebar-width: 260px;
    --topbar-height: 56px;
}

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--brand-dark);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface-dark); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }


/* =============================================
   SPA LAYOUT — Topbar + Sidebar + Content
   ============================================= */

/* --- Topbar --- */
.sm-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: rgba(12, 12, 18, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 var(--space-lg);
    z-index: 100;
    gap: var(--space-md);
}

.sm-topbar__logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: var(--text-primary);
    flex-shrink: 0;
}

.sm-topbar__logo img {
    height: 28px;
    width: auto;
    filter: brightness(1.2);
}

.sm-topbar__logo-text {
    font-size: var(--font-size-lg);
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, var(--brand-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sm-topbar__spacer { flex: 1; }

.sm-topbar__instance {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    background: rgba(255, 255, 255, 0.05);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-light);
}

.sm-topbar__user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sm-topbar__user-btn {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: inherit;
}

.sm-topbar__user-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.sm-topbar__hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.4rem;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.sm-topbar__hamburger:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* --- Main Layout --- */
.sm-layout {
    display: flex;
    margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height));
}

/* --- Sidebar --- */
.sm-sidebar {
    width: var(--sidebar-width);
    background: rgba(12, 12, 18, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-md) 0;
    z-index: 90;
    transition: transform var(--transition-slow);
}

.sm-sidebar__section {
    margin-bottom: var(--space-xs);
}

.sm-sidebar__section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--space-sm) var(--space-lg) var(--space-xs);
}

.sm-sidebar__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    user-select: none;
}

.sm-sidebar__item:hover {
    background: rgba(0, 122, 204, 0.1);
    color: var(--text-primary);
    border-left-color: rgba(0, 122, 204, 0.3);
}

.sm-sidebar__item--active {
    background: rgba(0, 122, 204, 0.15);
    color: var(--brand-light);
    border-left-color: var(--brand-primary);
    font-weight: 600;
}

.sm-sidebar__item-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.sm-sidebar__item-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sm-sidebar__item-arrow {
    font-size: var(--font-size-xs);
    transition: transform var(--transition-fast);
    color: var(--text-muted);
}

.sm-sidebar__item--expanded .sm-sidebar__item-arrow {
    transform: rotate(90deg);
}

.sm-sidebar__subitems {
    display: none;
    padding-left: var(--space-lg);
}

.sm-sidebar__subitems--open {
    display: block;
}

.sm-sidebar__subitem {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-lg) 6px calc(var(--space-lg) + 20px + var(--space-sm));
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.sm-sidebar__subitem:hover {
    color: var(--text-primary);
    background: rgba(0, 122, 204, 0.08);
}

.sm-sidebar__subitem--active {
    color: var(--brand-light);
    background: rgba(0, 122, 204, 0.12);
    border-left-color: var(--brand-accent);
    font-weight: 500;
}

/* --- Content Area --- */
.sm-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-xl) var(--space-2xl);
    min-height: calc(100vh - var(--topbar-height));
    max-width: 1200px;
}

.sm-content__header {
    margin-bottom: var(--space-xl);
}

.sm-content__title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.sm-content__subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* --- Footer (compact) --- */
.sm-footer {
    margin-left: var(--sidebar-width);
    padding: var(--space-md) var(--space-2xl);
    border-top: 1px solid var(--border-light);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sm-footer a {
    color: var(--brand-light);
    text-decoration: none;
}

.sm-footer a:hover {
    color: var(--brand-accent);
}


/* =============================================
   COMPONENTS — Unified
   ============================================= */

/* --- Container --- */
.sidemind-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* --- Card --- */
.sidemind-card {
    background: rgba(18, 18, 26, 0.9);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-xl);
    margin-bottom: var(--space-xl);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
    animation: fadeInUp 0.4s ease-out;
}

.sidemind-card:hover {
    border-color: rgba(0, 122, 204, 0.3);
    box-shadow: var(--shadow-glow);
}

.sidemind-card__title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    border-bottom: 2px solid var(--brand-primary);
    padding-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sidemind-card__subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
    font-weight: 400;
}

/* --- Grid --- */
.sidemind-grid {
    display: grid;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.sidemind-grid--2col { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.sidemind-grid--3col { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.sidemind-grid--4col { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

/* --- Stats Grid (unified) --- */
.sm-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.sm-stat-card {
    background: var(--surface-card);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.sm-stat-card:hover {
    border-color: rgba(0, 122, 204, 0.3);
    transform: translateY(-2px);
}

.sm-stat-card__value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--brand-light);
    margin-bottom: var(--space-xs);
}

.sm-stat-card__label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.sm-stat-card--success .sm-stat-card__value { color: var(--success-light); }
.sm-stat-card--danger .sm-stat-card__value { color: var(--danger-light); }
.sm-stat-card--warning .sm-stat-card__value { color: var(--warning-light); }

/* --- Form --- */
.sidemind-form__group { margin-bottom: var(--space-lg); }

.sidemind-form__label {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: var(--space-xs);
    font-size: var(--font-size-sm);
}

.sidemind-form__input,
.sidemind-form__select,
.sidemind-form__textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
    font-family: inherit;
    color: var(--text-primary);
}

.sidemind-form__input::placeholder,
.sidemind-form__textarea::placeholder {
    color: var(--text-muted);
}

.sidemind-form__input:focus,
.sidemind-form__select:focus,
.sidemind-form__textarea:focus {
    outline: none;
    border-color: rgba(0, 122, 204, 0.5);
    box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.sidemind-form__input:disabled,
.sidemind-form__select:disabled,
.sidemind-form__textarea:disabled {
    background: rgba(255, 255, 255, 0.02);
    cursor: not-allowed;
    opacity: 0.5;
}

.sidemind-form__hint {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

.sidemind-form__select,
select.sidemind-form__input {
    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='%23ffffff' fill-opacity='0.5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.sidemind-form__select option,
select.sidemind-form__input option,
select option {
    background: #12121a;
    color: #f5f5f7;
    padding: 8px 12px;
}

select optgroup {
    background: #0d0d14;
    color: #00aaff;
    font-weight: 600;
}

/* --- Toggle Switch (unified) --- */
.sm-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.sm-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.sm-switch__slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    transition: var(--transition-base);
    border-radius: var(--radius-full);
}

.sm-switch__slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: var(--transition-base);
    border-radius: 50%;
}

.sm-switch input:checked + .sm-switch__slider {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-light) 100%);
    border-color: transparent;
}

.sm-switch input:checked + .sm-switch__slider:before {
    transform: translateX(22px);
    background-color: white;
}

.sm-switch input:focus + .sm-switch__slider {
    box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.2);
}

/* Keep old class names for backward compat */
.sidemind-switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.sidemind-switch input { opacity: 0; width: 0; height: 0; }
.sidemind-switch__slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255, 255, 255, 0.1); border: 1px solid var(--border-color); transition: var(--transition-base); border-radius: var(--radius-full); }
.sidemind-switch__slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 2px; bottom: 2px; background-color: var(--text-secondary); transition: var(--transition-base); border-radius: 50%; }
.sidemind-switch input:checked + .sidemind-switch__slider { background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-light) 100%); border-color: transparent; }
.sidemind-switch input:checked + .sidemind-switch__slider:before { transform: translateX(22px); background-color: white; }
.sidemind-switch input:focus + .sidemind-switch__slider { box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.2); }

/* --- Buttons --- */
.sidemind-btn {
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    justify-content: center;
    white-space: nowrap;
    font-family: inherit;
}

.sidemind-btn--primary {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-light) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 122, 204, 0.3);
}
.sidemind-btn--primary:hover {
    background: linear-gradient(135deg, #0088dd 0%, #00bbff 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 170, 255, 0.4);
}

.sidemind-btn--secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.sidemind-btn--secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.sidemind-btn--success {
    background: linear-gradient(135deg, var(--success-dark) 0%, var(--success-color) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.sidemind-btn--success:hover {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.sidemind-btn--danger {
    background: linear-gradient(135deg, var(--danger-dark) 0%, var(--danger-color) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}
.sidemind-btn--danger:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.sidemind-btn--warning {
    background: linear-gradient(135deg, var(--warning-dark) 0%, var(--warning-color) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}
.sidemind-btn--warning:hover {
    background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.sidemind-btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}
.sidemind-btn--ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.sidemind-btn--full { width: 100%; }
.sidemind-btn--lg { padding: var(--space-md) var(--space-xl); font-size: var(--font-size-lg); }
.sidemind-btn--sm { padding: var(--space-xs) var(--space-sm); font-size: var(--font-size-sm); }
.sidemind-btn:disabled { background: rgba(255, 255, 255, 0.1); color: var(--text-muted); cursor: not-allowed; transform: none; box-shadow: none; }

/* --- Badge --- */
.sidemind-badge {
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    border: 1px solid transparent;
}

.sidemind-badge--success { background: rgba(16, 185, 129, 0.2); color: var(--success-light); border-color: rgba(16, 185, 129, 0.3); }
.sidemind-badge--danger { background: rgba(239, 68, 68, 0.2); color: var(--danger-light); border-color: rgba(239, 68, 68, 0.3); }
.sidemind-badge--warning { background: rgba(245, 158, 11, 0.2); color: var(--warning-light); border-color: rgba(245, 158, 11, 0.3); }
.sidemind-badge--info { background: rgba(0, 122, 204, 0.2); color: var(--brand-light); border-color: rgba(0, 170, 255, 0.3); }
.sidemind-badge--gray { background: rgba(255, 255, 255, 0.1); color: var(--text-secondary); border-color: rgba(255, 255, 255, 0.1); }
.sidemind-badge--primary { background: rgba(0, 122, 204, 0.2); color: var(--brand-light); border-color: rgba(0, 170, 255, 0.3); }

/* --- Alerts --- */
.sidemind-alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    border-left: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    animation: slideInRight var(--transition-base);
}

.sidemind-alert--success { background: rgba(16, 185, 129, 0.15); border-color: var(--success-color); color: var(--success-light); }
.sidemind-alert--danger { background: rgba(239, 68, 68, 0.15); border-color: var(--danger-color); color: var(--danger-light); }
.sidemind-alert--warning { background: rgba(245, 158, 11, 0.15); border-color: var(--warning-color); color: var(--warning-light); }
.sidemind-alert--info { background: rgba(0, 122, 204, 0.15); border-color: var(--brand-primary); color: var(--brand-light); }

/* --- Status Item --- */
.sidemind-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-light);
}

.sidemind-status:last-child { border-bottom: none; }
.sidemind-status__label { font-weight: 600; color: var(--text-secondary); font-size: var(--font-size-sm); }
.sidemind-status__value { font-weight: 600; color: var(--text-primary); }

/* --- Info Grid --- */
.sidemind-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

.sidemind-info-item {
    background: rgba(255, 255, 255, 0.05);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--brand-primary);
    transition: all var(--transition-base);
}
.sidemind-info-item:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.sidemind-info-item__label { font-size: var(--font-size-xs); color: var(--text-tertiary); margin-bottom: var(--space-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.sidemind-info-item__value { font-weight: 700; color: var(--text-primary); font-size: var(--font-size-xl); }

/* --- Tabs (unified) --- */
.sm-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-xs);
}

.sm-tab {
    padding: var(--space-sm) var(--space-lg);
    border: 1px solid var(--border-color);
    background: var(--surface-card);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: pointer;
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    transition: all var(--transition-base);
    font-family: inherit;
    border-bottom: none;
}

.sm-tab:hover {
    border-color: var(--brand-primary);
    color: var(--brand-light);
}

.sm-tab--active {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-light) 100%);
    color: white;
    border-color: transparent;
}

.sm-tab-panel { display: none; }
.sm-tab-panel--active { display: block; }

/* --- Modal (unified) --- */
.sm-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn var(--transition-base);
}

.sm-modal--open { display: flex; align-items: center; justify-content: center; }

.sm-modal__content {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    animation: slideUp var(--transition-slow);
    position: relative;
}

.sm-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.sm-modal__title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
}

.sm-modal__close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    line-height: 1;
}

.sm-modal__close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.sm-modal__body { margin-bottom: var(--space-xl); }

.sm-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

/* --- Spinner --- */
.sidemind-spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--brand-primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: var(--space-xl) auto;
}

.sidemind-spinner--sm { width: 24px; height: 24px; border-width: 3px; }
.sidemind-spinner--lg { width: 70px; height: 70px; border-width: 5px; }

/* --- Backend Card (for AI backends) --- */
.sm-backend-card {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sm-backend-card--active { border-color: var(--success-color); box-shadow: var(--shadow-glow-success); }
.sm-backend-card--inactive { border-color: var(--border-color); opacity: 0.7; }

.sm-backend-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.sm-backend-card__name { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }

.sm-backend-card__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.sm-backend-card__dot--on { background: var(--success-color); box-shadow: 0 0 6px var(--success-color); }
.sm-backend-card__dot--off { background: var(--danger-color); }
.sm-backend-card__dot--unconfigured { background: var(--text-muted); }

/* --- Channel Card --- */
.channel-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: all var(--transition-base);
}
.channel-card:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(0, 122, 204, 0.3); }

/* --- Email Reauth Warning --- */
.email-reauth-warning {
    display: none;
    margin: var(--space-sm) 0;
    padding: var(--space-sm);
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    color: var(--warning-light);
}

/* --- QR Code --- */
.qr-container { text-align: center; min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.qr-code { background: white; padding: var(--space-lg); border-radius: var(--radius-md); margin: var(--space-lg) 0; box-shadow: var(--shadow-md); }
.qr-code canvas { border: 3px solid var(--brand-primary); border-radius: var(--radius-sm); }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--space-sm); text-align: left; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-secondary); font-weight: 600; text-transform: uppercase; font-size: var(--font-size-xs); letter-spacing: 0.05em; }
tr:hover { background: rgba(0, 122, 204, 0.1); }

/* --- Details/Summary --- */
details { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: var(--space-md); transition: all var(--transition-base); }
details[open] { background: rgba(255, 255, 255, 0.05); }
details summary { cursor: pointer; font-weight: 600; color: var(--brand-light); padding: var(--space-sm) 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▶ "; display: inline-block; transition: transform var(--transition-base); }
details[open] summary::before { transform: rotate(90deg); }

/* --- Code --- */
code { background: rgba(255, 255, 255, 0.1); padding: 2px 6px; border-radius: 4px; font-family: var(--font-family-mono); font-size: 0.85em; color: var(--brand-light); }

/* --- Links --- */
a { color: var(--brand-light); text-decoration: none; transition: color var(--transition-base); }
a:hover { color: var(--brand-accent); text-decoration: underline; }

/* --- Lists --- */
ul, ol { color: var(--text-secondary); }
ul li, ol li { margin-bottom: var(--space-xs); }


/* =============================================
   AUTH PAGES — Background Animation
   ============================================= */

.sm-auth-bg {
    position: relative;
    overflow: hidden;
}

.sm-auth-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 30% 30%, rgba(0, 122, 204, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(0, 212, 255, 0.1) 0%, transparent 50%);
    animation: backgroundPulse 15s ease-in-out infinite;
    z-index: -1;
}

@keyframes backgroundPulse {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(-5%, -5%) rotate(5deg); }
}


/* =============================================
   ANIMATIONS
   ============================================= */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse-live { animation: pulse-live 2s infinite; }


/* =============================================
   UTILITIES
   ============================================= */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.flex { display: flex; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

.hidden { display: none !important; }
.visible { display: block; }


/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
    :root {
        --font-size-4xl: 1.875rem;
        --font-size-3xl: 1.5rem;
    }

    .sm-topbar__hamburger { display: block; }
    .sm-topbar__instance { display: none; }

    .sm-sidebar {
        transform: translateX(-100%);
        z-index: 95;
        box-shadow: var(--shadow-2xl);
    }

    .sm-sidebar--open {
        transform: translateX(0);
    }

    .sm-sidebar__overlay {
        display: none;
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 89;
    }

    .sm-sidebar__overlay--visible {
        display: block;
    }

    .sm-content {
        margin-left: 0;
        padding: var(--space-lg) var(--space-md);
    }

    .sm-footer {
        margin-left: 0;
        padding: var(--space-md);
        flex-direction: column;
        gap: var(--space-xs);
        text-align: center;
    }

    .sidemind-grid--2col,
    .sidemind-grid--3col,
    .sidemind-grid--4col,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .sidemind-card { padding: var(--space-lg); }

    .sidemind-info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .sm-content { padding: var(--space-md) var(--space-sm); }
    .sm-content__title { font-size: var(--font-size-xl); }
}
