/* ═══════════════════════════════════════════
   FISHBOWL CRM — DESKTOP DASHBOARD
   ═══════════════════════════════════════════ */

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

:root {
    --bg: #030816;
    --bg-sidebar: #0A0F1E;
    --bg-card: rgba(255,255,255,0.03);
    --bg-card-hover: rgba(255,255,255,0.06);
    --bg-input: rgba(255,255,255,0.05);
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.15);
    --text: #FFFFFF;
    --text-secondary: rgba(255,255,255,0.55);
    --text-dim: rgba(255,255,255,0.3);
    --blue: #2A5BFF;
    --blue-hover: #1A4CF0;
    --blue-glow: rgba(42,91,255,0.15);
    --green: #34C759;
    --orange: #FF9500;
    --red: #FF3B30;
    --purple: #AF52DE;
    --cyan: #5AC8FA;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

html, body { height: 100%; overflow: hidden; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
}

/* ─── Scrollbar ────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ═══════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════ */
.login-screen {
    height: 100vh; display: flex; justify-content: center; align-items: center;
    position: relative; overflow: hidden;
}
.login-glow { position: absolute; border-radius: 50%; filter: blur(120px); pointer-events: none; }
.login-glow.g1 { width: 500px; height: 500px; background: var(--blue); top: -10%; left: 20%; opacity: 0.25; animation: drift1 18s ease-in-out infinite; }
.login-glow.g2 { width: 600px; height: 600px; background: #1539A2; bottom: -20%; right: -5%; opacity: 0.2; animation: drift2 22s ease-in-out infinite reverse; }

@keyframes drift1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(80px,60px); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-60px,-40px); } }

.login-card {
    background: rgba(20,20,30,0.7); border: 1px solid var(--border);
    border-radius: 24px; padding: 48px 40px; width: 420px; max-width: 90%;
    backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
    box-shadow: 0 32px 80px rgba(0,0,0,0.6);
    text-align: center; z-index: 1;
    animation: cardIn 0.6s cubic-bezier(0.16,1,0.3,1);
}
@keyframes cardIn { from { opacity:0; transform: translateY(30px) scale(0.96); } to { opacity:1; transform: translateY(0) scale(1); } }

.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 32px; }
.login-logo i { width: 28px; height: 28px; }
.login-logo span { font-size: 20px; font-weight: 800; letter-spacing: 1.5px; }
.login-card h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.5px; }
.login-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 32px; }

.field { text-align: left; margin-bottom: 18px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; letter-spacing: 0.3px; }
.field-input {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.field-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.field-input i { width: 18px; height: 18px; color: var(--text-dim); flex-shrink: 0; }
.field-input input {
    background: transparent; border: none; color: var(--text);
    font-size: 14px; flex: 1; outline: none; font-family: var(--font);
}
.field-input input::placeholder { color: var(--text-dim); }

.btn-login {
    width: 100%; padding: 14px; background: var(--blue); color: white;
    border: none; border-radius: var(--radius-sm); font-size: 15px;
    font-weight: 600; cursor: pointer; font-family: var(--font);
    display: flex; justify-content: center; align-items: center; gap: 8px;
    transition: all var(--transition); margin-top: 8px;
}
.btn-login:hover { background: var(--blue-hover); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(42,91,255,0.35); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,0.2); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-error { color: var(--red); font-size: 13px; margin-top: 14px; min-height: 18px; text-align: center; }

/* ═══════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════ */
.app-shell { display: flex; height: 100vh; }

.titlebar-drag {
    position: fixed; top: 0; left: 0; right: 0; height: 38px;
    -webkit-app-region: drag; z-index: 999; pointer-events: none;
}

/* ─── Sidebar ──────────────────────── */
.sidebar {
    width: var(--sidebar-w); height: 100vh; background: var(--bg-sidebar);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
    padding: 0; flex-shrink: 0; transition: width var(--transition), transform var(--transition);
    z-index: 50;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px; padding: 44px 24px 16px;
    height: 72px; border-bottom: 1px solid var(--border);
    -webkit-app-region: drag;
}
.sidebar-brand i { width: 22px; height: 22px; }
.sidebar-brand span { font-size: 16px; font-weight: 800; letter-spacing: 1.5px; }

.sidebar-nav { flex: 1; padding: 20px 12px; overflow-y: auto; }
.nav-section-label {
    font-size: 10px; font-weight: 700; color: var(--text-dim);
    letter-spacing: 1.5px; padding: 16px 12px 8px; margin-top: 4px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    cursor: pointer; font-size: 14px; font-weight: 500;
    transition: all var(--transition); text-decoration: none; position: relative;
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-card-hover); color: var(--text); }
.nav-item.active { background: var(--blue-glow); color: var(--blue); }
.nav-item i { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
    margin-left: auto; background: var(--blue); color: white;
    font-size: 10px; font-weight: 700; padding: 2px 8px;
    border-radius: 100px; min-width: 24px; text-align: center;
}

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-sm); }
.sidebar-avatar { width: 36px; height: 36px; border-radius: 18px; background: var(--bg-card); object-fit: cover; }
.sidebar-user-name { font-size: 13px; font-weight: 600; }
.sidebar-user-company { font-size: 11px; color: var(--text-dim); }

/* ─── Main Content ─────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
    height: var(--topbar-h); padding: 0 32px; display: flex;
    justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border); flex-shrink: 0;
    -webkit-app-region: drag;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-menu-btn {
    display: none; background: none; border: 1px solid var(--border);
    color: var(--text); padding: 8px; border-radius: var(--radius-xs);
    cursor: pointer; -webkit-app-region: no-drag;
}
.topbar-menu-btn i { width: 18px; height: 18px; }
.topbar-title { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }

.topbar-right { display: flex; align-items: center; gap: 12px; -webkit-app-region: no-drag; }
.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 100px; padding: 8px 16px; width: 220px;
    transition: border-color var(--transition), width var(--transition);
}
.search-box:focus-within { border-color: var(--blue); width: 280px; }
.search-box i { width: 16px; height: 16px; color: var(--text-dim); }
.search-box input { background: transparent; border: none; color: var(--text); font-size: 13px; outline: none; flex: 1; font-family: var(--font); }
.search-box input::placeholder { color: var(--text-dim); }

.topbar-icon-btn {
    width: 36px; height: 36px; border-radius: var(--radius-xs);
    background: none; border: 1px solid var(--border); color: var(--text-secondary);
    cursor: pointer; display: flex; justify-content: center; align-items: center;
    transition: all var(--transition);
}
.topbar-icon-btn:hover { background: var(--bg-card-hover); color: var(--text); border-color: var(--border-hover); }
.topbar-icon-btn i { width: 16px; height: 16px; }

.page-content {
    flex: 1; overflow-y: auto; padding: 32px;
    animation: pageIn 0.3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════
   SHARED COMPONENTS
   ═══════════════════════════════════════ */

/* Cards */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-title { font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
.card-value { font-size: 32px; font-weight: 700; letter-spacing: -1px; }
.card-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card { padding: 24px; }
.stat-icon { width: 44px; height: 44px; border-radius: 14px; display: flex; justify-content: center; align-items: center; margin-bottom: 16px; }
.stat-icon i { width: 22px; height: 22px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; font-size: 11px; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 1px; padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
tbody tr { transition: background var(--transition); cursor: default; }
tbody tr:hover { background: var(--bg-card-hover); }
tbody td { padding: 14px 16px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.03); }

.status-badge {
    display: inline-block; padding: 4px 12px; border-radius: 100px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.status-cold { background: rgba(90,200,250,0.12); color: var(--cyan); }
.status-warm { background: rgba(255,149,0,0.12); color: var(--orange); }
.status-hot { background: rgba(255,59,48,0.12); color: var(--red); }
.status-won { background: rgba(52,199,89,0.12); color: var(--green); }

/* Buttons */
.btn {
    padding: 10px 20px; border-radius: var(--radius-sm); font-size: 13px;
    font-weight: 600; cursor: pointer; border: none; font-family: var(--font);
    display: inline-flex; align-items: center; gap: 8px;
    transition: all var(--transition);
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(42,91,255,0.3); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text); }
.btn-danger { background: rgba(255,59,48,0.1); color: var(--red); border: 1px solid rgba(255,59,48,0.2); }
.btn-danger:hover { background: rgba(255,59,48,0.2); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn i { width: 16px; height: 16px; }

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state i { width: 48px; height: 48px; color: var(--text-dim); margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 13px; color: var(--text-secondary); }

/* Page Header (title + action) */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.page-header h2 { font-size: 28px; font-weight: 300; letter-spacing: -1px; }

/* Flex/Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.flex-row { display: flex; gap: 16px; align-items: center; }
.mt-24 { margin-top: 24px; }
.mb-24 { margin-bottom: 24px; }

/* Chart */
.chart-area { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 20px; }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar { width: 100%; border-radius: 6px 6px 0 0; background: rgba(255,255,255,0.06); transition: height 0.5s ease; min-height: 4px; }
.chart-bar.active { background: var(--blue); }
.chart-bar-label { font-size: 10px; color: var(--text-dim); font-weight: 600; }
.chart-bar-value { font-size: 10px; color: var(--text-secondary); font-weight: 600; }

/* Insight Card */
.insight-card {
    background: linear-gradient(135deg, rgba(42,91,255,0.08) 0%, rgba(28,28,30,0.4) 100%);
    border: 1px solid rgba(42,91,255,0.15); border-radius: var(--radius); padding: 24px;
}
.insight-card .insight-tag { font-size: 11px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.insight-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.insight-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }

/* Team Grid */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.team-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; text-align: center;
    transition: all var(--transition); cursor: pointer;
}
.team-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.team-card img { width: 56px; height: 56px; border-radius: 28px; margin-bottom: 12px; object-fit: cover; background: var(--bg-input); }
.team-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.team-card p { font-size: 12px; color: var(--text-secondary); }

/* Rule Card */
.rule-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; display: flex;
    align-items: center; gap: 16px; transition: all var(--transition);
}
.rule-card:hover { border-color: var(--border-hover); }
.rule-icon { width: 44px; height: 44px; border-radius: 14px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.rule-icon i { width: 20px; height: 20px; }
.rule-info { flex: 1; }
.rule-info h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.rule-info p { font-size: 12px; color: var(--text-secondary); }

/* File row */
.file-row {
    display: flex; align-items: center; gap: 16px; padding: 14px 16px;
    border-radius: var(--radius-sm); transition: background var(--transition);
}
.file-row:hover { background: var(--bg-card-hover); }
.file-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--blue-glow); display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.file-icon i { width: 18px; height: 18px; color: var(--blue); }
.file-info { flex: 1; }
.file-info h4 { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.file-info p { font-size: 12px; color: var(--text-dim); }

/* Progress bar */
.progress-bg { height: 6px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 3px; transition: width 0.4s ease; }

/* ═══════════════════════════════════════
   MODAL
   ═══════════════════════════════════════ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center; z-index: 200;
}
.modal-card {
    background: #141420; border: 1px solid var(--border);
    border-radius: 20px; padding: 32px; width: 460px; max-width: 90%;
    box-shadow: 0 32px 80px rgba(0,0,0,0.6);
    animation: modalIn 0.3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 20px; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px; border-radius: var(--radius-xs);
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer; display: flex;
    justify-content: center; align-items: center; transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text); }
.modal-close i { width: 16px; height: 16px; }

.modal-field { margin-bottom: 16px; }
.modal-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.modal-field input, .modal-field select, .modal-field textarea {
    width: 100%; padding: 12px 14px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-size: 14px; outline: none; font-family: var(--font);
    transition: border-color var(--transition);
}
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus { border-color: var(--blue); }
.modal-field select { cursor: pointer; }
.modal-field select option { background: #141420; }
.modal-field textarea { resize: vertical; min-height: 80px; }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* Settings specific */
.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.settings-row-label { font-size: 14px; font-weight: 500; }
.settings-row-value { font-size: 14px; color: var(--text-secondary); }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); z-index: 100; }
    .sidebar.open { transform: translateX(0); }
    .topbar-menu-btn { display: flex; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .team-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .page-content { padding: 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .team-grid { grid-template-columns: 1fr; }
    .search-box { display: none; }
}
