/* ============================================
   SEARVATOR CRM - Modern White UI
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #fafafa;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-2: #f5f5f7;
    --surface-3: #ebebef;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #18181b;
    --text-2: #52525b;
    --text-3: #a1a1aa;
    --accent: #0f172a;
    --accent-light: #1e293b;
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.04);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.04);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.06), 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);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ===== LAYOUT ===== */
.app-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    font-size: 18px;
    box-shadow: var(--shadow-md);
}

.brand-name {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.02em;
}

.brand-tagline {
    font-size: 10px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    padding: 12px 12px 8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius);
    color: var(--text-2);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.2s var(--ease);
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
    transform: translateX(2px);
}

.nav-item.active {
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-md);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--surface-2);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 700;
    font-size: 13px;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-3); }

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-2);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s var(--ease);
}

.logout-btn:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 32px 40px;
    max-width: 1600px;
    width: 100%;
    animation: fadeInUp 0.5s var(--ease-out);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 20px;
}

.page-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.page-subtitle {
    color: var(--text-2);
    font-size: 14px;
    margin-top: 4px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-3);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; transform: translateY(-1px); }

.btn-danger {
    background: white;
    color: var(--danger);
    border: 1px solid var(--danger-light);
}
.btn-danger:hover { background: var(--danger-light); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--ease);
    animation: scaleIn 0.5s var(--ease-spring) backwards;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-strong);
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-color, var(--accent));
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.1;
}

.stat-meta {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card.green::before { background: var(--success); }
.stat-card.blue::before { background: var(--primary); }
.stat-card.amber::before { background: var(--warning); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.red::before { background: var(--danger); }

/* ===== CARDS ===== */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 24px;
    transition: all 0.3s var(--ease);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.card-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

.card-body { padding: 24px; }

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab {
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-2);
    transition: all 0.2s var(--ease);
    white-space: nowrap;
    border: none;
    background: transparent;
    font-family: inherit;
}

.tab:hover { color: var(--text); }

.tab.active {
    background: white;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.tab-content { display: none; animation: fadeInUp 0.3s var(--ease-out); }
.tab-content.active { display: block; }

/* ===== TABLES ===== */
.table-wrap {
    overflow-x: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: var(--surface-2);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.15s var(--ease);
}

.data-table tbody tr:hover {
    background: var(--surface-2);
}

.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.badge.success { background: var(--success-light); color: #047857; }
.badge.warning { background: var(--warning-light); color: #92400e; }
.badge.info { background: var(--info-light); color: #1e40af; }
.badge.danger { background: var(--danger-light); color: #b91c1c; }
.badge.purple { background: var(--purple-light); color: #6d28d9; }
.badge.neutral { background: var(--surface-3); color: var(--text-2); }

/* ===== FORM ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}

.form-control,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-elevated);
    transition: all 0.2s var(--ease);
}

.form-control:focus,
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

textarea { resize: vertical; min-height: 80px; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s var(--ease);
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s var(--ease-spring);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.94) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }

.modal-close {
    background: var(--surface-2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 18px;
    color: var(--text-2);
    display: grid;
    place-items: center;
    transition: all 0.2s var(--ease);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--surface-2);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-3);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--accent);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    animation: toastIn 0.3s var(--ease-spring);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== STAGGERED ANIMATIONS ===== */
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.3s; }

/* ===== UTILITIES ===== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 4px; } .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-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-3); }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: -240px;
        z-index: 50;
        transition: left 0.3s var(--ease);
        width: 240px;
    }
    .sidebar.open { left: 0; }
    .main-content { padding: 20px; }
    .page-title { font-size: 22px; }
}

/* ===== LOGIN PAGE ===== */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.08), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.08), transparent 40%),
        var(--bg);
}

.login-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.5s var(--ease-spring);
}

.login-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    font-size: 24px;
    margin: 0 auto 16px;
    box-shadow: var(--shadow-lg);
}

.login-title {
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
    margin-bottom: 32px;
}

.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 12px;
    margin-bottom: 16px;
    border: 1px solid #fca5a5;
}

.login-hint {
    margin-top: 20px;
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--radius);
    font-size: 11px;
    color: var(--text-2);
    line-height: 1.6;
}

/* ===== MOBILE MENU TOGGLE ===== */
.mobile-toggle {
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .mobile-toggle { display: flex; }
}
