@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ==========================================
   DESIGN TOKENS
   ========================================== */
:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-50: #dbeafe;

    --success: #10b981;
    --success-light: #d1fae5;
    --success-dark: #047857;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;

    --dark: #111827;
    --dark-secondary: #374151;
    --gray-700: #4b5563;
    --gray-600: #6b7280;
    --gray-500: #9ca3af;
    --gray-400: #d1d5db;
    --gray-300: #e5e7eb;
    --gray-200: #f3f4f6;
    --gray-100: #f9fafb;
    --white: #ffffff;

    --sidebar-w: 260px;
    --topbar-h: 64px;

    --border: #e5e7eb;
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);

    --ease: cubic-bezier(.4,0,.2,1);
}

/* ==========================================
   RESET & BASE
   ========================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--dark-secondary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: fixed;
    left: 0; top: 0;
    padding: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Logo */
.sidebar-header {
    padding: 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--dark);
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
    letter-spacing: -.5px;
    width: 100%;
}

.sidebar-header .logo i {
    font-size: 1.4rem;
    color: var(--primary);
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

.nav-list {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item { list-style: none; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--gray-600);
    font-weight: 500;
    font-size: .875rem;
    transition: all .15s var(--ease);
    text-decoration: none;
}

.nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item.active .nav-link {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active .nav-link i { color: var(--primary); }

.nav-link:hover {
    background: var(--gray-200);
    color: var(--dark);
}

.nav-item.active .nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--gray-600);
    font-weight: 500;
    font-size: .875rem;
    border-radius: var(--radius-md);
    transition: all .15s var(--ease);
}

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

/* ==========================================
   MAIN CONTENT
   ========================================== */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

/* ==========================================
   TOP NAV
   ========================================== */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--topbar-h);
}

/* Page Title (breadcrumb area) */
.top-nav .page-title,
.top-nav .breadcrumb,
.top-nav h5.breadcrumb {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    padding: 0;
}

.top-nav .page-title span,
.top-nav .breadcrumb span,
.top-nav h5.breadcrumb span {
    color: var(--gray-600);
    font-weight: 400;
}

/* Top Nav Stats Badges */
.top-stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: .8rem;
    font-weight: 500;
    color: var(--dark-secondary);
}

.top-stat-badge .value {
    font-weight: 700;
    color: var(--dark);
}

.top-stat-badge.success .value { color: var(--success-dark); }
.top-stat-badge.primary .value { color: var(--primary); }

/* User Profile Badge */
.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-size: .8rem;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.3;
}

.user-role {
    font-size: .7rem;
    font-weight: 500;
    color: var(--gray-500);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gray-200);
}

/* ==========================================
   DASHBOARD CONTENT
   ========================================== */
.dashboard-content {
    padding: 24px 32px 32px;
}

/* ==========================================
   WELCOME BANNER
   ========================================== */
.welcome-banner {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    color: var(--white);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,.08);
    border-radius: 50%;
}

.welcome-banner h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.welcome-banner p {
    opacity: .85;
    font-size: .9rem;
    margin-bottom: 16px;
}

.welcome-banner .btn {
    border-radius: var(--radius-md);
}

/* ==========================================
   CARDS
   ========================================== */
.card-premium {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s var(--ease);
}

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

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--dark);
    margin: 0 0 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i {
    font-size: 1rem;
    color: var(--primary);
}

.card-subtitle {
    font-size: .8rem;
    color: var(--gray-600);
    margin: 0;
}

/* ==========================================
   STAT CARDS
   ========================================== */
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-xs);
    transition: all .2s var(--ease);
}

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

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.bg-primary-light { background: var(--primary-light) !important; }
.bg-success-light { background: var(--success-light) !important; }
.bg-warning-light { background: var(--warning-light) !important; }
.bg-info-light    { background: #e0f2fe !important; }
.text-primary     { color: var(--primary) !important; }
.text-success     { color: var(--success) !important; }
.text-warning     { color: var(--warning) !important; }
.text-info        { color: #0284c7 !important; }

.stat-content { flex: 1; min-width: 0; }

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.stat-label {
    font-size: .78rem;
    font-weight: 500;
    color: var(--gray-600);
    margin: 2px 0 0;
    white-space: nowrap;
}

/* ==========================================
   FORMS
   ========================================== */
.form-label-custom {
    font-size: .8rem;
    font-weight: 500;
    color: var(--dark-secondary);
    margin-bottom: 6px;
    display: block;
}

.form-control,
.form-select {
    font-family: 'Inter', sans-serif !important;
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    padding: 9px 12px !important;
    font-size: .875rem !important;
    color: var(--dark) !important;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease) !important;
    box-shadow: var(--shadow-xs) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12) !important;
    outline: none !important;
}

.form-control::placeholder {
    color: var(--gray-500) !important;
    font-weight: 400;
}

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

.form-text {
    font-size: .75rem;
    color: var(--gray-600);
    margin-top: 4px;
}

/* Input with icon */
.input-group-custom {
    position: relative;
}

.input-group-custom i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    font-size: .95rem;
    z-index: 5;
    pointer-events: none;
}

.input-group-custom .form-control {
    padding-left: 36px !important;
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: .875rem;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    transition: all .15s var(--ease);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    box-shadow: 0 1px 2px rgba(59,130,246,.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 2px 4px rgba(59,130,246,.35);
    color: var(--white);
}

.btn-primary:active {
    background: var(--primary-dark);
    transform: translateY(0);
}

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

.btn-outline-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-hover);
}

.btn-outline-dark {
    color: var(--dark-secondary);
    border-color: var(--border);
    background: var(--white);
}

.btn-outline-dark:hover {
    background: var(--gray-200);
    color: var(--dark);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: var(--success-dark);
    border-color: var(--success-dark);
    color: var(--white);
}

.btn-light {
    background: var(--gray-200);
    border-color: var(--gray-200);
    color: var(--dark-secondary);
}

.btn-light:hover {
    background: var(--gray-300);
    color: var(--dark);
}

/* Sizes */
.btn-sm {
    padding: 5px 10px;
    font-size: .8rem;
}

.btn-lg, .btn.py-3 {
    padding: 12px 20px;
    font-size: .9rem;
}

/* ==========================================
   TABLES
   ========================================== */
.table-responsive {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--white);
}

.table,
.table-premium {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.table th,
.table-premium th {
    background: var(--gray-100);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-600);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td,
.table-premium td {
    padding: 12px 16px;
    font-size: .85rem;
    color: var(--dark-secondary);
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

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

.table tbody tr:hover td,
.table-premium tbody tr:hover td {
    background: var(--gray-100);
}

/* ==========================================
   BADGES
   ========================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-weight: 500;
    font-size: .75rem;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    line-height: 1.4;
}

.badge.bg-success-light { background: var(--success-light) !important; color: var(--success-dark) !important; border-color: #a7f3d0; }
.badge.bg-warning-light { background: var(--warning-light) !important; color: #92400e !important; border-color: #fde68a; }
.badge.bg-danger-light  { background: var(--danger-light) !important; color: #991b1b !important; border-color: #fecaca; }
.badge.bg-primary-light { background: var(--primary-light) !important; color: var(--primary) !important; border-color: #bfdbfe; }

/* CRM Badges */
.badge-crm { cursor: pointer; transition: transform 0.2s; }
.badge-crm:hover { transform: scale(1.05); }
.badge-new { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-contacted { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-interested { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-sold { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-uninterested { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ==========================================
   ALERTS
   ========================================== */
.alert {
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: .875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
}

.alert i { font-size: 1rem; flex-shrink: 0; }

.alert-success {
    background: var(--success-light);
    border-color: #a7f3d0;
    color: var(--success-dark);
}

.alert-danger {
    background: var(--danger-light);
    border-color: #fecaca;
    color: #991b1b;
}

.alert-warning {
    background: var(--warning-light);
    border-color: #fde68a;
    color: #92400e;
}

/* ==========================================
   TIP / INFO CARDS
   ========================================== */
.tip-card {
    background: var(--primary-light);
    border: 1px solid var(--primary-50);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}

.tip-card.success {
    background: var(--success-light);
    border-color: #a7f3d0;
}

.tip-card h5 {
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.tip-card p {
    font-size: .8rem;
    color: var(--gray-700);
    margin: 0;
    line-height: 1.5;
}

/* ==========================================
   STATUS INDICATOR
   ========================================== */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--gray-400); }
.status-dot.danger { background: var(--danger); }

/* ==========================================
   SECTION HEADERS
   ========================================== */
.section-header {
    margin-bottom: 20px;
}

.section-header h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--dark);
    margin: 0 0 4px;
}

.section-header p {
    font-size: .85rem;
    color: var(--gray-600);
    margin: 0;
}

/* ==========================================
   ICON BOX (for table rows etc.)
   ========================================== */
.icon-box {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.icon-box.primary { background: var(--primary-light); color: var(--primary); }
.icon-box.success { background: var(--success-light); color: var(--success); }
.icon-box.warning { background: var(--warning-light); color: var(--warning); }

/* ==========================================
   DIVIDER
   ========================================== */
.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
    border: none;
}

/* ==========================================
   EMPTY STATE
   ========================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state i {
    font-size: 2.5rem;
    color: var(--gray-400);
    margin-bottom: 12px;
}

.empty-state h5 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark-secondary);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: .85rem;
    color: var(--gray-600);
}

/* ==========================================
   CHART CONTAINER
   ========================================== */
.chart-container {
    position: relative;
    height: 320px;
    width: 100%;
}

/* ==========================================
   PROGRESS BAR (Circular)
   ========================================== */
.progress-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.progress-ring .value {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s var(--ease);
    }
    .sidebar.show { transform: translateX(0); }

    .main-content {
        margin-left: 0;
    }

    .top-nav {
        padding: 12px 16px;
    }

    .dashboard-content {
        padding: 16px;
    }
}

@media (max-width: 767.98px) {
    .stat-card {
        padding: 14px 16px;
    }

    .stat-value {
        font-size: 1.15rem;
    }

    .card-premium {
        padding: 16px;
    }
}

/* Radar Scanner Loading - Redesigned for UX */
.loading-overlay-modern {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    margin: 40px 0;
}

.loading-card-premium {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 500px;
}

.loading-content-group {
    margin-top: 30px;
    width: 100%;
}

.radar-scanner-container { 
    position: relative; 
    width: 140px; 
    height: 140px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

.radar-core { 
    width: 50px; 
    height: 50px; 
    background: #2563eb; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 10; 
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.6); 
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.radar-pulse { 
    position: absolute; 
    border: 1px solid #2563eb; 
    width: 100%; 
    height: 100%; 
    border-radius: 50%; 
    opacity: 0; 
    animation: radar-pulse-anim 3s infinite linear; 
}

.radar-pulse.delay-1 { animation-delay: 1s; }
.radar-pulse.delay-2 { animation-delay: 2s; }

.radar-line { 
    position: absolute; 
    width: 50%; 
    height: 3px; 
    background: linear-gradient(to right, transparent, #2563eb); 
    top: 50%; 
    left: 50%; 
    transform-origin: left center; 
    animation: radar-rotate 2s infinite linear; 
    z-index: 5; 
    filter: blur(1px);
}

.status-dot-pulse { 
    width: 10px; 
    height: 10px; 
    background: #25D366; 
    border-radius: 50%; 
    box-shadow: 0 0 0 rgba(37, 211, 102, 0.4); 
    animation: dot-pulse 1.5s infinite; 
}

.progress-wrapper {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
}

.progress-container-mini { 
    width: 100%; 
    height: 6px; 
    background: #f1f5f9; 
    border-radius: 10px; 
    overflow: hidden; 
}

.progress-bar-infinite { 
    width: 40%; 
    height: 100%; 
    background: linear-gradient(90deg, #2563eb, #60a5fa); 
    border-radius: 10px; 
    animation: progress-infinite 1.8s infinite ease-in-out; 
}

.text-muted-extra-small {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

@keyframes radar-pulse-anim {
    0% { transform: scale(0.4); opacity: 0.8; }
    100% { transform: scale(1.3); opacity: 0; }
}
@keyframes radar-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes dot-pulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}
@keyframes progress-infinite {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}
