/* ══════════════════════════════════════════════════════
   Shared Design System — Multi-App Platform Admin UI
   ══════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────── */
:root {
    --primary-50:  #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --secondary-500: #8b5cf6;
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --success-50:  #f0fdf4;
    --success-500: #22c55e;
    --success-600: #16a34a;
    --warning-50:  #fffbeb;
    --warning-500: #f59e0b;
    --error-50:  #fef2f2;
    --error-500: #ef4444;
    --surface: #ffffff;
    --bg: #f8fafc;
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.04);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
    --shadow-ring: 0 0 0 3px rgb(99 102 241 / 0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ── Base Typography ───────────────────────────────── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    color: var(--gray-800);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Lucide Icon System ────────────────────────────── */
.icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }
.icon-2xl { width: 40px; height: 40px; }

/* ── Page Header ───────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; background: linear-gradient(135deg, var(--primary-50) 0%, #f0f4ff 100%); padding: 24px 28px; border-radius: var(--radius-xl); border: 1px solid var(--gray-200); }
.page-title { font-size: 1.625rem; font-weight: 700; color: var(--gray-900); letter-spacing: -0.02em; line-height: 1.3; }
.page-subtitle { color: var(--gray-600); font-size: 0.875rem; margin-top: 4px; }
.header-actions { display: flex; gap: 10px; align-items: center; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-md);
    font-weight: 600; font-size: 0.8125rem; letter-spacing: 0.01em;
    text-decoration: none; cursor: pointer; border: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.btn-primary {
    background: var(--primary-600); color: white;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), inset 0 1px 0 rgb(255 255 255 / 0.1);
}
.btn-primary:hover { background: var(--primary-700); box-shadow: var(--shadow-md), inset 0 1px 0 rgb(255 255 255 / 0.1); }
.btn-secondary {
    background: var(--surface); color: var(--gray-700);
    border: 1px solid var(--gray-200); box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-danger { background: #dc2626; color: white; box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #d97706; color: white; box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); }
.btn-warning:hover { background: #b45309; }
.btn-ghost { background: transparent; color: var(--gray-600); border: none; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

/* ── Action Button (small inline) ──────────────────── */
.action-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 500; border: 1px solid var(--gray-200); background: var(--surface); color: var(--gray-600); cursor: pointer; transition: all var(--transition-fast); }
.action-btn:hover { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary-700); }
.action-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.action-btn:disabled:hover { background: var(--surface); border-color: var(--gray-200); color: var(--gray-600); }
.action-btn-danger { color: #dc2626; border-color: #fecaca; }
.action-btn-danger:hover { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.12);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

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

.form-hint {
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-top: 4px;
    display: block;
}

/* ── Modal ──────────────────────────────────────────── */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgb(15 23 42 / 0.4); z-index: 1000; backdrop-filter: blur(4px); align-items: center; justify-content: center; overflow-y: auto; padding: 20px; }
.modal.show { display: flex; }
.modal-content { background: white; border-radius: var(--radius-xl); padding: 28px; max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-xl); margin: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--gray-200); background: var(--gray-50); margin: -28px -28px 20px; padding: 20px 28px; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.modal-title { font-size: 1.125rem; font-weight: 700; color: var(--gray-900); }
.close-btn { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--gray-400); padding: 4px 8px; border-radius: var(--radius-sm); transition: all var(--transition-fast); }
.close-btn:hover { background: var(--gray-100); color: var(--gray-600); }

/* ── Tabs ───────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--gray-200); margin-bottom: 24px; overflow-x: auto; }
.tab { padding: 10px 16px; text-align: center; cursor: pointer; transition: all var(--transition-fast); font-weight: 500; border: none; background: transparent; font-size: 0.8125rem; color: var(--gray-500); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary-600); border-bottom-color: var(--primary-600); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 100px; font-size: 0.6875rem; font-weight: 600; white-space: nowrap; letter-spacing: 0.01em; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fef2f2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #a16207; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #f3e8ff; color: #7c3aed; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-cyan { background: #ecfeff; color: #0e7490; }

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-dot-success { background: #22c55e; }
.badge-dot-danger { background: #ef4444; }
.badge-dot-warning { background: #f59e0b; }

/* ── Stat Cards ────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-card-icon.green { background: #dcfce7; color: #16a34a; }
.stat-card-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-card-icon.red { background: #fee2e2; color: #dc2626; }
.stat-card-icon.amber { background: #fef3c7; color: #d97706; }
.stat-card-icon.cyan { background: #cffafe; color: #0891b2; }

.stat-card-body { flex: 1; min-width: 0; }
.stat-card-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.stat-card-label { font-size: 0.75rem; color: var(--gray-500); margin-top: 2px; }
.stat-card-trend { font-size: 0.6875rem; font-weight: 600; margin-top: 4px; }
.stat-card-trend.up { color: #16a34a; }
.stat-card-trend.down { color: #dc2626; }

/* ── Data List ─────────────────────────────────────── */
.data-list { border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; }
.data-list-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--gray-100); border-bottom: 1px solid var(--gray-200); font-size: 0.6875rem; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; }
.data-list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--gray-100); transition: background var(--transition-fast); }
.data-list-item:last-child { border-bottom: none; }
.data-list-item:nth-child(even) { background: var(--gray-50); }
.data-list-item:hover { background: var(--primary-50); }
.data-list-item-info { flex: 1; min-width: 0; }
.data-list-item-title { font-weight: 600; color: var(--gray-800); font-size: 0.875rem; display: flex; align-items: center; gap: 8px; }
.data-list-item-subtitle { color: var(--gray-500); font-size: 0.8125rem; margin-top: 2px; }
.data-list-item-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.data-list-item-actions { display: flex; gap: 6px; flex-shrink: 0; margin-left: 12px; }
.data-list-empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--gray-400); }
.data-list-empty-icon { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--gray-300); }
.data-list-empty-icon svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.data-list-empty p { font-size: 0.875rem; margin-bottom: 4px; }
.data-list-empty small { font-size: 0.75rem; color: var(--gray-400); }

/* ── Section Card ──────────────────────────────────── */
.section-card { background: var(--surface); border-radius: var(--radius-xl); border: 1px solid var(--gray-200); overflow: hidden; }
.section-card-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--gray-200); background: linear-gradient(135deg, var(--gray-50) 0%, #f8faff 100%); }
.section-card-header h2, .section-card-header h3 { font-size: 0.875rem; font-weight: 600; color: var(--gray-800); display: flex; align-items: center; gap: 8px; margin: 0; }
.section-card-body { padding: 20px; }
.section-card-body.flush { padding: 0; }

/* ── Toggle Switch ─────────────────────────────────── */
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--gray-300); border-radius: 24px; cursor: pointer; transition: all var(--transition-base); }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; background: white; border-radius: 50%; top: 3px; left: 3px; transition: transform var(--transition-base); box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }
.toggle-switch input:checked + .toggle-slider { background: var(--primary-500); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Loading / Utility ─────────────────────────────── */
.loading { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--gray-200); border-top-color: var(--primary-500); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }

/* ── Notification ──────────────────────────────────── */
.notification { position: fixed; top: 20px; right: 20px; padding: 12px 16px; border-radius: var(--radius-md); color: white; font-weight: 600; font-size: 0.8125rem; z-index: 1001; transform: translateX(400px); transition: transform 0.3s; box-shadow: var(--shadow-lg); }
.notification.show { transform: translateX(0); }
.notification.success { background: #16a34a; }
.notification.error { background: #dc2626; }
.notification.info { background: #2563eb; }
.notification-body { display: flex; align-items: center; gap: 0.75rem; }
.notification-text { font-weight: 600; }
.notification-time { font-size: 0.8125rem; opacity: 0.8; margin-top: 0.25rem; }

/* ── Search Bar ─────────────────────────────────────── */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-bar-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
    display: flex;
}

.search-bar-input {
    width: 100%;
    padding: 12px 40px 12px 42px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    color: var(--gray-800);
    background: var(--surface);
    outline: none;
    transition: all var(--transition-fast);
}

.search-bar-input::placeholder {
    color: var(--gray-400);
}

.search-bar-input:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-bar-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-100);
    border: none;
    color: var(--gray-500);
    font-size: 1.1rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all var(--transition-fast);
}

.search-bar-clear:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}
