/* =============================================
   CRM Pro — Complete Stylesheet v3.0
   Theme: Deep Navy / Amber Accent
   Fonts: Sora (headings) + DM Sans (body)
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── CSS Variables ── */
:root {
    --navy:        #0d1b2a;
    --navy-mid:    #1b2d42;
    --navy-light:  #243b55;
    --slate:       #2d4a6e;
    --amber:       #f59e0b;
    --amber-light: #fcd34d;
    --teal:        #0891b2;
    --teal-light:  #22d3ee;
    --success:     #10b981;
    --danger:      #ef4444;
    --warning:     #f59e0b;
    --text-light:  #e2e8f0;
    --text-muted:  #94a3b8;
    --border:      rgba(255,255,255,0.08);
    --card-bg:     rgba(27,45,66,0.97);
    --sidebar-w:   260px;
    --topbar-h:    64px;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--navy);
    color: var(--text-light);
    margin: 0;
    min-height: 100vh;
    font-size: 14.5px;
    line-height: 1.55;
}

/* =============================================
   SIDEBAR
   ============================================= */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--navy-mid);
    border-right: 1px solid var(--border);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
}

/* Brand */
.sidebar-brand {
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--amber), var(--teal));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; color: white; flex-shrink: 0;
}
.sidebar-brand .brand-name {
    font-family: 'Sora', sans-serif;
    font-weight: 700; font-size: 14px;
    color: white; line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand .brand-sub {
    font-size: 10px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 1px;
}

/* Nav */
.sidebar-nav { padding: 10px 0; flex: 1; }
.nav-section-label {
    padding: 14px 22px 5px;
    font-size: 9.5px; text-transform: uppercase;
    letter-spacing: 1.5px; color: var(--text-muted);
    font-weight: 700;
}
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 22px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.18s;
    font-size: 13.5px; font-weight: 500;
    position: relative;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link i { width: 17px; text-align: center; font-size: 14px; }
.sidebar-nav .nav-link:hover { color: white; background: rgba(255,255,255,0.05); }
.sidebar-nav .nav-link.active {
    color: var(--amber);
    background: rgba(245,158,11,0.08);
    border-left-color: var(--amber);
    font-weight: 600;
}

/* Footer */
.sidebar-footer { padding: 14px 22px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user .avatar {
    width: 33px; height: 33px;
    background: linear-gradient(135deg, var(--slate), var(--teal));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: white; flex-shrink: 0;
}
.sidebar-user .user-info .name { font-size: 13px; font-weight: 600; color: white; }
.sidebar-user .user-info .role { font-size: 11px; color: var(--text-muted); }

/* =============================================
   MAIN CONTENT
   ============================================= */
#main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--navy-mid);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 26px;
    position: sticky; top: 0; z-index: 100;
}
.topbar .page-title {
    font-family: 'Sora', sans-serif;
    font-size: 17px; font-weight: 700; color: white;
}
.topbar .topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar .date-badge {
    font-size: 12px; color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 5px 12px; border-radius: 20px;
    border: 1px solid var(--border);
}

/* Page Body */
.page-body { padding: 26px; flex: 1; }

/* =============================================
   CARDS
   ============================================= */
.crm-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    transition: box-shadow 0.2s;
}
.crm-card:hover { box-shadow: 0 6px 28px rgba(0,0,0,0.28); }

/* Stat Cards */
.stat-card { display: flex; align-items: center; gap: 16px; }
.stat-icon {
    width: 52px; height: 52px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 21px; flex-shrink: 0;
}
.stat-icon.amber  { background: rgba(245,158,11,0.14); color: var(--amber); }
.stat-icon.teal   { background: rgba(8,145,178,0.14);  color: var(--teal-light); }
.stat-icon.success{ background: rgba(16,185,129,0.14); color: var(--success); }
.stat-icon.danger { background: rgba(239,68,68,0.14);  color: var(--danger); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 3px; }
.stat-value { font-family: 'Sora', sans-serif; font-size: 27px; font-weight: 800; color: white; line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* =============================================
   TABLES
   ============================================= */
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table thead tr { background: rgba(255,255,255,0.035); }
.crm-table thead th {
    padding: 11px 15px;
    font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.9px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.crm-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.13s; }
.crm-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.crm-table tbody td { padding: 12px 15px; color: var(--text-light); vertical-align: middle; }
.crm-table tbody tr:last-child { border-bottom: none; }
.crm-table tfoot tr { background: rgba(245,158,11,0.07); }
.crm-table tfoot td { padding: 12px 15px; }

/* =============================================
   BADGES
   ============================================= */
.badge-crm {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
    white-space: nowrap;
}

/* Lead statuses */
.badge-new       { background: rgba(8,145,178,0.14);   color: var(--teal-light); }
.badge-contacted { background: rgba(245,158,11,0.14);  color: var(--amber); }
.badge-sent      { background: rgba(139,92,246,0.14);  color: #a78bfa; }
.badge-approved  { background: rgba(16,185,129,0.14);  color: var(--success); }
.badge-closed    { background: rgba(107,114,128,0.14); color: #9ca3af; }

/* Quotation statuses */
.badge-draft    { background: rgba(107,114,128,0.14); color: #9ca3af; }
.badge-rejected { background: rgba(239,68,68,0.14);   color: var(--danger); }

/* Invoice statuses */
.badge-pending  { background: rgba(245,158,11,0.14);  color: var(--amber); }
.badge-paid     { background: rgba(16,185,129,0.14);  color: var(--success); }
.badge-partial  { background: rgba(252,211,77,0.14);  color: var(--amber-light); }
.badge-overdue  { background: rgba(239,68,68,0.14);   color: var(--danger); }

/* Standalone .badge (Bootstrap override for settings page) */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }

/* =============================================
   BUTTONS
   ============================================= */
.btn-crm {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 17px; border-radius: 8px;
    font-size: 13px; font-weight: 600;
    cursor: pointer; border: none;
    transition: all 0.18s;
    text-decoration: none;
    font-family: 'DM Sans', sans-serif;
    white-space: nowrap;
    vertical-align: middle;
}
.btn-crm:focus { outline: none; }

.btn-crm-primary { background: var(--amber); color: #0d1b2a; }
.btn-crm-primary:hover { background: var(--amber-light); color: #0d1b2a; transform: translateY(-1px); }

.btn-crm-teal { background: var(--teal); color: white; }
.btn-crm-teal:hover { background: #0e7490; color: white; }

.btn-crm-success { background: rgba(16,185,129,0.14); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.btn-crm-success:hover { background: var(--success); color: white; }

.btn-crm-danger { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.28); }
.btn-crm-danger:hover { background: var(--danger); color: white; }

.btn-crm-ghost { background: rgba(255,255,255,0.06); color: var(--text-light); border: 1px solid var(--border); }
.btn-crm-ghost:hover { background: rgba(255,255,255,0.11); color: white; }

.btn-crm-info { background: rgba(8,145,178,0.14); color: var(--teal-light); border: 1px solid rgba(8,145,178,0.28); }
.btn-crm-info:hover { background: var(--teal); color: white; }

.btn-sm-crm { padding: 5px 11px; font-size: 11.5px; gap: 5px; }
.w-100 { width: 100% !important; }

/* =============================================
   FORMS
   ============================================= */
.crm-form-group { margin-bottom: 18px; }
.crm-label {
    display: block; font-size: 11.5px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.7px; margin-bottom: 6px;
}
.crm-input,
.crm-select,
.crm-textarea {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 8px; padding: 9px 13px;
    color: white; font-family: 'DM Sans', sans-serif;
    font-size: 13.5px; outline: none;
    transition: border-color 0.18s, background 0.18s;
}
.crm-input:focus,
.crm-select:focus,
.crm-textarea:focus { border-color: var(--amber); background: rgba(245,158,11,0.04); }
.crm-input::placeholder,
.crm-textarea::placeholder { color: var(--text-muted); }
.crm-input[readonly] { opacity: 0.7; cursor: not-allowed; }
.crm-select { cursor: pointer; }
.crm-select option { background: var(--navy-mid); color: white; }
.crm-textarea { resize: vertical; min-height: 88px; }

/* =============================================
   ALERTS
   ============================================= */
.crm-alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 13px 16px; border-radius: 10px;
    margin-bottom: 18px; font-size: 13.5px;
    border-left: 4px solid; line-height: 1.5;
}
.crm-alert-success { background: rgba(16,185,129,0.1); border-color: var(--success); color: #6ee7b7; }
.crm-alert-error   { background: rgba(239,68,68,0.1);  border-color: var(--danger);  color: #fca5a5; }
.crm-alert-info    { background: rgba(8,145,178,0.1);  border-color: var(--teal);    color: var(--teal-light); }
.crm-alert-warning { background: rgba(245,158,11,0.1); border-color: var(--amber);   color: var(--amber-light); }

/* =============================================
   SECTION HEADER
   ============================================= */
.section-header {
    display: flex; align-items: center;
    justify-content: space-between; flex-wrap: wrap; gap: 10px;
    margin-bottom: 18px;
}
.section-title {
    font-family: 'Sora', sans-serif;
    font-size: 16px; font-weight: 700; color: white; margin: 0;
}

/* =============================================
   SEARCH BAR
   ============================================= */
.search-bar {
    display: flex; gap: 10px;
    align-items: center; flex-wrap: wrap;
}
.search-input-wrap {
    position: relative; flex: 1; min-width: 180px;
}
.search-input-wrap i {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted); font-size: 13px; pointer-events: none;
}
.search-input-wrap input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 8px; padding: 9px 13px 9px 34px;
    color: white; font-family: 'DM Sans', sans-serif; font-size: 13px;
    outline: none; transition: border-color 0.18s;
}
.search-input-wrap input:focus { border-color: var(--amber); }
.search-input-wrap input::placeholder { color: var(--text-muted); }

/* =============================================
   PAGINATION
   ============================================= */
.crm-pagination {
    display: flex; gap: 5px;
    align-items: center; justify-content: center; flex-wrap: wrap;
}
.crm-pagination a,
.crm-pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; border-radius: 8px;
    font-size: 13px; font-weight: 600; text-decoration: none;
    padding: 0 8px; transition: all 0.18s;
}
.crm-pagination a { background: rgba(255,255,255,0.06); color: var(--text-light); border: 1px solid var(--border); }
.crm-pagination a:hover { background: var(--amber); color: var(--navy); border-color: var(--amber); }
.crm-pagination span { background: var(--amber); color: var(--navy); border: 1px solid var(--amber); }
.crm-pagination .dots { color: var(--text-muted); border: none; background: none; cursor: default; }

/* =============================================
   MODALS
   ============================================= */
.crm-modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.72);
    z-index: 9000; align-items: center; justify-content: center;
    padding: 20px;
}
.crm-modal-overlay.active { display: flex; }
.crm-modal {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: 16px; padding: 28px;
    max-width: 440px; width: 100%;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(0.95); } to { opacity:1; transform: scale(1); } }
.crm-modal-icon {
    width: 58px; height: 58px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px; font-size: 22px;
}
.crm-modal-icon.danger { background: rgba(239,68,68,0.14); color: var(--danger); }
.crm-modal-icon.warning { background: rgba(245,158,11,0.14); color: var(--amber); }
.crm-modal h5 { font-family: 'Sora',sans-serif; font-size: 16px; font-weight: 700; color: white; margin: 0 0 8px; text-align: center; }
.crm-modal p  { color: var(--text-muted); font-size: 13.5px; text-align: center; margin: 0 0 22px; line-height: 1.6; }
.crm-modal-actions { display: flex; gap: 12px; justify-content: center; }

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-wrap {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: var(--navy); padding: 20px;
}
.login-card {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: 20px; padding: 44px 38px;
    width: 100%; max-width: 420px;
}
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo .icon {
    width: 58px; height: 58px;
    background: linear-gradient(135deg, var(--amber), var(--teal));
    border-radius: 15px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 24px; color: white; margin-bottom: 12px;
}
.login-logo h1 { font-family: 'Sora',sans-serif; font-size: 21px; font-weight: 800; color: white; margin: 0; }
.login-logo p  { color: var(--text-muted); font-size: 13px; margin: 5px 0 0; }

/* =============================================
   MISC UTILITIES
   ============================================= */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.text-amber   { color: var(--amber) !important; }
.text-teal    { color: var(--teal-light) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-muted-crm { color: var(--text-muted) !important; }
.fw-sora      { font-family: 'Sora', sans-serif; }
.mb-3         { margin-bottom: 1rem !important; }
.mb-4         { margin-bottom: 1.5rem !important; }
.mt-3         { margin-top: 1rem !important; }
.gap-2        { gap: 8px !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--navy); }
::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 3px; }

/* =============================================
   RESPONSIVE — MOBILE
   ============================================= */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,0.5); }
    #main-content { margin-left: 0; }
    .page-body { padding: 14px; }
    .topbar { padding: 0 14px; }
    .stat-value { font-size: 22px; }
    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar .crm-select,
    .search-bar button,
    .search-bar a { width: 100%; justify-content: center; }
    .crm-table thead th, .crm-table tbody td { padding: 9px 10px; font-size: 12px; }
}

/* Sidebar overlay on mobile */
#sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 150;
}
#sidebar-overlay.active { display: block; }
