/* =====================================================
   BUDDY CRM - Design System
   ===================================================== */
:root {
    --primary: #6C5CE7;
    --primary-dark: #5847D0;
    --primary-light: #EDE9FE;
    --secondary: #00CEC9;
    --success: #00B894;
    --warning: #FDCB6E;
    --danger: #FF6B6B;
    --dark: #2D3436;
    --gray-100: #F7F8FC;
    --gray-200: #EEF0F7;
    --gray-300: #DFE3EE;
    --gray-500: #8A8FA3;
    --gray-700: #4A4E63;
    --sidebar-width: 260px;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(41, 45, 66, 0.06);
    --shadow-hover: 0 8px 30px rgba(41, 45, 66, 0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-100);
    color: var(--dark);
    margin: 0;
}

a { text-decoration: none; }

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #1B1A2E;
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    padding: 24px 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px 24px;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 16px;
}
.sidebar-brand span { color: var(--secondary); }
.sidebar-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.35);
    padding: 16px 24px 8px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 24px;
    color: rgba(255,255,255,.7);
    font-size: 14.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .18s ease;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-nav a.active {
    background: rgba(108,92,231,.18);
    color: #fff;
    border-left-color: var(--secondary);
}
.sidebar-nav a i { width: 18px; text-align: center; }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 0;
    width: calc(100% - var(--sidebar-width));
}

.topbar {
    background: #fff;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h4 { margin: 0; font-weight: 700; font-size: 19px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.avatar-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; cursor: pointer;
}

.page-body { padding: 28px; }

/* ---------- Cards ---------- */
.card-modern {
    background: #fff;
    border-radius: var(--radius);
    border: none;
    box-shadow: var(--shadow);
    padding: 22px;
    transition: box-shadow .2s ease;
}
.card-modern:hover { box-shadow: var(--shadow-hover); }

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: var(--radius);
    padding: 20px;
    background: #fff;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.stat-value { font-size: 24px; font-weight: 800; margin: 0; }
.stat-label { font-size: 13px; color: var(--gray-500); margin: 0; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn-primary-modern {
    background: var(--primary);
    border: none;
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    transition: all .18s ease;
}
.btn-primary-modern:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }

.btn-soft-success { background: #E4F9F1; color: var(--success); border: none; padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.btn-soft-danger { background: #FFECEC; color: var(--danger); border: none; padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.btn-soft-primary { background: var(--primary-light); color: var(--primary); border: none; padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; }

/* ---------- Tables ---------- */
.table-modern { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-modern thead th {
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 13px 16px;
    border: none;
    font-weight: 700;
}
.table-modern tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
    vertical-align: middle;
}
.table-modern tbody tr:hover { background: var(--gray-100); }

/* ---------- Badges ---------- */
.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-new { background: #E8EAFF; color: #5B6EFF; }
.badge-contacted { background: #FFF4D9; color: #B8860B; }
.badge-qualified { background: #E0F7FA; color: #00838F; }
.badge-won, .badge-active, .badge-paid { background: #E4F9F1; color: var(--success); }
.badge-lost, .badge-suspended, .badge-overdue, .badge-cancelled { background: #FFECEC; color: var(--danger); }
.badge-trial, .badge-sent, .badge-partially_paid { background: #F3E8FF; color: #8B5CF6; }
.badge-draft { background: #EEF0F7; color: var(--gray-700); }

/* ---------- Forms ---------- */
.form-control-modern, .form-select-modern {
    border: 1.5px solid var(--gray-300);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    width: 100%;
    transition: border-color .15s ease;
}
.form-control-modern:focus, .form-select-modern:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-label-modern { font-size: 13.5px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; display: block; }

/* ---------- Auth Pages ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6C5CE7 0%, #00CEC9 100%);
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.auth-logo { text-align: center; font-size: 26px; font-weight: 800; margin-bottom: 4px; color: var(--dark); }
.auth-logo span { color: var(--primary); }
.auth-sub { text-align: center; color: var(--gray-500); font-size: 14px; margin-bottom: 28px; }

/* ---------- Checkbox bulk-select bar ---------- */
.bulk-action-bar {
    display: none;
    align-items: center;
    gap: 14px;
    background: var(--primary-light);
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 14px;
}
.bulk-action-bar.show { display: flex; }
.bulk-action-bar .count { font-weight: 700; color: var(--primary); }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; }
}

/* ---------- Dark Mode ---------- */
body.dark-mode {
    background: #14131F;
    color: #E8E9F0;
}
body.dark-mode .topbar,
body.dark-mode .card-modern,
body.dark-mode .stat-card,
body.dark-mode .auth-card {
    background: #1E1D2E;
    color: #E8E9F0;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
body.dark-mode .table-modern thead th { background: #262536; color: #A9ACC0; }
body.dark-mode .table-modern tbody td { border-bottom-color: #2E2D42; }
body.dark-mode .table-modern tbody tr:hover { background: #262536; }
body.dark-mode .form-control-modern,
body.dark-mode .form-select-modern { background: #262536; border-color: #383754; color: #E8E9F0; }
body.dark-mode .page-body { background: #14131F; }
body.dark-mode .sidebar-brand { color: #fff; }
