/* ============================================
   AI SaaS Platform - Premium Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Brand Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #06b6d4;

    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --success-dark: #065f46;
    --error: #ef4444;
    --error-light: #fee2e2;
    --error-dark: #991b1b;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-dark: #92400e;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --info-dark: #1e40af;

    /* Backgrounds */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-dark: #0f172a;
    --bg-dark-secondary: #1e293b;
    --bg-dark-tertiary: #334155;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --text-white: #ffffff;

    /* Borders */
    --border: #e2e8f0;
    --border-dark: #cbd5e1;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-secondary: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-error: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-dark: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Spacing */
    --sidebar-width: 270px;
    --header-height: 70px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* ============================================
   Dark Theme Overrides
   Applied when <html data-theme="dark">
   ============================================ */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #263248;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --border: #334155;
    --border-dark: #475569;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Topbar */
[data-theme="dark"] .topbar {
    background: #1e293b;
    border-color: #334155;
}

/* Cards & stat cards */
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .card-footer {
    background: #263248;
    border-color: #334155;
}

[data-theme="dark"] .card-header {
    border-color: #334155;
}

/* Tables */
[data-theme="dark"] .table thead th {
    background: #263248;
    color: var(--text-secondary);
}

[data-theme="dark"] .table tbody tr:hover {
    background: #263248;
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    border-color: #334155;
}

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #263248;
    border-color: #334155;
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus {
    border-color: var(--primary);
    background: #1e293b;
}

/* Auth card */
[data-theme="dark"] .auth-card {
    background: #1e293b;
    color: var(--text-primary);
}

/* Modal/overlay */
[data-theme="dark"] .modal-box {
    background: #1e293b;
    border-color: #334155;
}

/* Alert variants */
[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

/* Plugin cards */
[data-theme="dark"] .plugin-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .code-preview-block {
    background: #0d1117;
    border-color: #30363d;
}

[data-theme="dark"] .code-preview-header {
    background: #161b22;
    border-color: #30363d;
}

/* Smooth transition when toggling */
body,
.topbar,
.card,
.stat-card,
.form-control,
.modal-box,
.plugin-card {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.15s ease;
}

/* ============================================
   Theme Toggle Button
   ============================================ */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-full);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: white;
}

/* In topbar context (light bg) */
.topbar .theme-toggle-btn {
    border-color: var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.topbar .theme-toggle-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

[data-theme="dark"] .topbar .theme-toggle-btn {
    background: #263248;
    border-color: #334155;
    color: var(--text-secondary);
}

/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
}

button {
    cursor: pointer;
    font-family: inherit;
}

input,
textarea,
select {
    font-family: inherit;
}

/* ============================================
   Auth Pages
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--gradient-bg);
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    top: -200px;
    right: -200px;
    animation: float 8s ease-in-out infinite;
}

.auth-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    bottom: -150px;
    left: -100px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(5deg);
    }
}

.auth-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255, 255, 255, 0.2);
    padding: 48px 40px;
    width: 100%;
    max-width: 460px;
    position: relative;
    z-index: 1;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.auth-logo-icon {
    width: 44px;
    height: 44px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: var(--shadow-glow);
}

.auth-logo-text {
    font-size: 22px;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    transition: var(--transition);
}

.auth-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-tertiary);
    font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ============================================
   Dashboard Layout
   ============================================ */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gradient-dark);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition-slow);
    overflow: hidden;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    background: var(--gradient-primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.sidebar-brand-name {
    font-size: 16px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
}

.sidebar-brand-badge {
    font-size: 10px;
    background: var(--gradient-primary);
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
    margin-left: auto;
}

.sidebar-user {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-avatar {
    width: 38px;
    height: 38px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.sidebar-credits {
    padding: 12px 20px;
    background: rgba(99, 102, 241, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-credits-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 2px;
}

.sidebar-credits-value {
    font-size: 20px;
    font-weight: 800;
    color: white;
}

.sidebar-credits-unit {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-section-label {
    padding: 12px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255, 255, 255, 0.65);
    transition: var(--transition);
    position: relative;
    font-size: 13.5px;
    font-weight: 500;
}

.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
    color: white;
    background: rgba(99, 102, 241, 0.25);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
    border-radius: 0 3px 3px 0;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

.nav-item-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.nav-item.danger {
    color: rgba(239, 68, 68, 0.7);
}

.nav-item.danger:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 18px;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.topbar-spacer {
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-credit-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-credit-badge i {
    color: var(--warning);
}

.page-content {
    padding: 28px 32px;
    flex: 1;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition-slow);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.05;
    transform: translate(20px, -20px);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    color: white;
}

.stat-icon.purple {
    background: var(--gradient-primary);
}

.stat-icon.cyan {
    background: var(--gradient-secondary);
}

.stat-icon.green {
    background: var(--gradient-success);
}

.stat-icon.orange {
    background: var(--gradient-warning);
}

.stat-icon.red {
    background: var(--gradient-error);
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-sub {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header-left h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.card-header-left p,
.card-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
}

.form-label .required {
    color: var(--error);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-primary);
    background: white;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-control:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-group {
    position: relative;
}

.input-group .form-control {
    padding-right: 44px;
}

.input-group-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 15px;
    transition: var(--transition);
}

.input-group-icon:hover {
    color: var(--primary);
}

/* Password strength */
.password-strength {
    margin-top: 8px;
    display: flex;
    gap: 4px;
}

.strength-bar {
    flex: 1;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    transition: var(--transition-slow);
}

.strength-bar.active-weak {
    background: var(--error);
}

.strength-bar.active-fair {
    background: var(--warning);
}

.strength-bar.active-good {
    background: var(--info);
}

.strength-bar.active-strong {
    background: var(--success);
}

.strength-text {
    font-size: 11px;
    margin-top: 4px;
    font-weight: 500;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--gradient-error);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--gradient-warning);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 13px 28px;
    font-size: 15px;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-xs {
    padding: 4px 9px;
    font-size: 11px;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius);
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 13.5px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert i {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-dark);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-success i {
    color: var(--success);
}

.alert-error {
    background: var(--error-light);
    color: var(--error-dark);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-error i {
    color: var(--error);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-warning i {
    color: var(--warning);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-dark);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.alert-info i {
    color: var(--info);
}

/* ============================================
   Tables
   ============================================ */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--bg-primary);
}

.table-avatar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 10px;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 20px;
}

.avatar-name {
    font-weight: 600;
    color: var(--text-primary);
}

.avatar-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-error {
    background: var(--error-light);
    color: var(--error-dark);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.badge-info {
    background: var(--info-light);
    color: var(--info-dark);
}

.badge-primary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.badge-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    gap: 6px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
    background: white;
}

.page-link:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-link.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ============================================
   Chat Interface
   ============================================ */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 520px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    gap: 12px;
    text-align: center;
}

.chat-empty i {
    font-size: 40px;
    opacity: 0.4;
}

.chat-empty p {
    font-size: 14px;
}

.chat-message {
    display: flex;
    gap: 10px;
    animation: messageIn 0.3s ease;
    max-width: 85%;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-message.error {
    align-self: flex-start;
}

.chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-message.user .chat-msg-avatar {
    background: var(--gradient-primary);
    color: white;
}

.chat-message.assistant .chat-msg-avatar {
    background: var(--bg-dark-secondary);
    color: white;
    font-size: 14px;
}

.chat-msg-content {
    flex: 1;
    min-width: 0;
}

.chat-msg-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-message.user .chat-msg-bubble {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-msg-bubble {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-message.error .chat-msg-bubble {
    background: var(--error-light);
    color: var(--error-dark);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.chat-msg-bubble pre {
    background: var(--bg-dark);
    color: #e2e8f0;
    padding: 12px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 12px;
    margin: 8px 0;
}

.chat-msg-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

.chat-message.user .chat-msg-bubble code {
    background: rgba(255, 255, 255, 0.2);
}

.chat-msg-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-message.user .chat-msg-time {
    justify-content: flex-end;
}

.chat-msg-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    opacity: 0;
    transition: var(--transition);
}

.chat-message:hover .chat-msg-actions {
    opacity: 1;
}

.chat-msg-action-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-msg-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 14px 16px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

.chat-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.chat-model-select {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-primary);
    background: white;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.chat-model-select:focus {
    border-color: var(--primary);
}

.chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    resize: none;
    outline: none;
    transition: var(--transition);
    max-height: 120px;
    line-height: 1.5;
    font-family: inherit;
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-input-hint {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.chat-send-btn {
    width: 46px;
    height: 46px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 480px;
    width: 100%;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 16px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--error-light);
    color: var(--error);
}

/* ============================================
   Search
   ============================================ */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 14px;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    outline: none;
    transition: var(--transition);
    background: white;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border-left: 4px solid var(--primary);
    pointer-events: all;
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 380px;
    font-size: 13.5px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.toast-success {
    border-color: var(--success);
}

.toast.toast-error {
    border-color: var(--error);
}

.toast.toast-warning {
    border-color: var(--warning);
}

.toast i {
    font-size: 18px;
    flex-shrink: 0;
}

.toast.toast-success i {
    color: var(--success);
}

.toast.toast-error i {
    color: var(--error);
}

.toast.toast-warning i {
    color: var(--warning);
}

.toast-msg {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
}

/* ============================================
   Utilities
   ============================================ */
.text-muted {
    color: var(--text-secondary);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

.text-warning {
    color: var(--warning);
}

.text-primary-color {
    color: var(--primary);
}

.text-sm {
    font-size: 12px;
}

.text-xs {
    font-size: 11px;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-4 {
    margin-bottom: 16px;
}

.w-full {
    width: 100%;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
    display: block;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 13px;
}

.credit-amount.positive {
    color: var(--success);
    font-weight: 600;
}

.credit-amount.negative {
    color: var(--error);
    font-weight: 600;
}

.progress-bar-wrapper {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    height: 6px;
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
}

/* ============================================
   Admin-specific
   ============================================ */
.admin-sidebar .sidebar-brand-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.quick-action-card {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-slow);
    text-decoration: none;
    color: var(--text-primary);
}

.quick-action-card:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.03);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.quick-action-card i {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 8px;
    display: block;
}

.quick-action-card span {
    font-size: 13px;
    font-weight: 600;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .sidebar-toggle {
        display: flex;
    }

    .main-content {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px 0 64px;
    }

    .page-content {
        padding: 20px 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-value {
        font-size: 22px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 32px 24px;
    }

    .chat-container {
        height: 420px;
    }

    .table th,
    .table td {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 28px 20px;
    }
}

/* ============================================
   Topbar
   ============================================ */
.topbar {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.topbar-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.topbar-spacer {
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-credit-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    box-shadow: var(--shadow-xl);
    border-left: 4px solid var(--primary);
    min-width: 280px;
    max-width: 380px;
    pointer-events: all;
    transform: translateX(120%);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 14px;
    font-weight: 500;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left-color: var(--success);
}

.toast-success i {
    color: var(--success);
}

.toast-error {
    border-left-color: var(--error);
}

.toast-error i {
    color: var(--error);
}

.toast-warning {
    border-left-color: var(--warning);
}

.toast-warning i {
    color: var(--warning);
}

.toast-info {
    border-left-color: var(--info);
}

.toast-info i {
    color: var(--info);
}

.toast-message {
    flex: 1;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.toast-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* ============================================
   Avatar
   ============================================ */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 20px;
}

.table-avatar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.avatar-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   Search Bar
   ============================================ */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 14px;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: white;
}

/* ============================================
   Sidebar Brand Badge
   ============================================ */
.sidebar-brand-badge {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: white;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    margin-left: auto;
}

/* ============================================
   Alert Close Button
   ============================================ */
.alert {
    position: relative;
}

.alert-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.alert-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-xs {
    font-size: 11px;
}

.text-sm {
    font-size: 12px;
}

.text-muted {
    color: var(--text-secondary);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

.text-warning {
    color: var(--warning);
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.mt-1 {
    margin-top: 4px;
}

.required {
    color: var(--error);
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}

/* Stat icon colors */
.stat-icon.red {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.stat-icon.purple {
    background: var(--gradient-primary);
}

.stat-icon.cyan {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.stat-icon.green {
    background: var(--gradient-success);
}

.stat-icon.orange {
    background: var(--gradient-warning);
}

/* Card header left */
.card-header-left h2 {
    margin: 0;
}

.card-header-left p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Sidebar credits unit */
.sidebar-credits-unit {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.7;
}

/* Password strength bars */
.password-strength {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.strength-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-full);
    transition: background 0.3s ease;
}

.strength-bar.active-weak {
    background: #ef4444;
}

.strength-bar.active-fair {
    background: #f59e0b;
}

.strength-bar.active-good {
    background: #3b82f6;
}

.strength-bar.active-strong {
    background: #10b981;
}

/* Input group icon */
.input-group {
    position: relative;
}

.input-group .form-control {
    padding-right: 44px;
}

.input-group-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-tertiary);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.input-group-icon:hover {
    color: var(--text-primary);
}

/* Chat toolbar */
.chat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.chat-model-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.chat-model-select:focus {
    border-color: var(--primary);
}

/* Chat message action button */
.chat-msg-action-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    margin-left: 8px;
}

.chat-msg-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Btn sizes */
.btn-xs {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-warning {
    background: var(--gradient-warning);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.btn-warning:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-danger {
    background: var(--gradient-error);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

/* Profile two-column responsive */
@media (max-width: 768px) {
    .topbar {
        padding: 0 16px 0 64px;
    }

    div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* -- Chat Launch Card (Dashboard) -------------------------------- */
.chat-launch-card {
    overflow: hidden;
}

.chat-launch-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
}

.chat-launch-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    background: var(--gradient-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}

.chat-launch-text {
    flex: 1;
}

.chat-launch-text h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.chat-launch-text p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-launch-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.chat-launch-models {
    padding: 10px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
}

/* -- Utility ----------------------------------------------------- */
.btn-xs {
    padding: 4px 8px !important;
    font-size: 11px !important;
}

/* -- App Footer ------------------------------------------------- */
.app-footer {
    text-align: center;
    padding: 16px 24px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.footer-sep {
    opacity: 0.4;
}

.footer-powered-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer-powered-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* -- App Footer ------------------------------------------------ */
.app-footer {
    text-align: center;
    padding: 16px 24px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.footer-sep {
    opacity: 0.4;
}

.footer-powered-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.footer-powered-link:hover {
    text-decoration: underline;
}