/* ========================================
   LeadCRM - Main Stylesheet
   Clean, professional design system
   ======================================== */

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --success: #059669;
    --success-light: #ECFDF5;
    --warning: #D97706;
    --warning-light: #FFFBEB;
    --danger: #DC2626;
    --danger-light: #FEF2F2;
    --info: #0284C7;
    --info-light: #F0F9FF;

    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px 24px;
    font-size: 20px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span { color: var(--primary); }

.sidebar-nav { padding: 16px 0; }

.nav-section {
    padding: 8px 24px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    margin-top: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--gray-300);
    transition: all 0.15s;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.nav-link.active {
    background: rgba(79, 70, 229, 0.15);
    color: #fff;
    border-left-color: var(--primary);
}

.nav-link .icon { width: 20px; text-align: center; font-size: 16px; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

/* Header */
.top-header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .separator { color: var(--gray-300); }

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-500);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: all 0.15s;
}

.header-btn:hover { background: var(--gray-100); color: var(--gray-700); }

.notification-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: background 0.15s;
}

.user-menu:hover { background: var(--gray-100); }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.user-info { line-height: 1.3; }
.user-info .name { font-weight: 600; font-size: 13px; }
.user-info .role { font-size: 11px; color: var(--gray-500); text-transform: capitalize; }

/* Page Content */
.page-content { padding: 24px; }

/* ========== Cards ========== */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

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

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body { padding: 20px; }

/* ========== Stat Cards ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

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

.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: var(--primary-light); color: var(--primary); }

.stat-info h3 { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.stat-info p { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

/* ========== Tables ========== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: var(--gray-50);
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

table tbody tr:hover { background: var(--gray-50); }

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new { background: #DBEAFE; color: #1E40AF; }
.badge-contacted { background: #E0E7FF; color: #3730A3; }
.badge-qualified { background: #D1FAE5; color: #065F46; }
.badge-property_shared { background: #FEF3C7; color: #92400E; }
.badge-site_visit_scheduled { background: #CFFAFE; color: #155E75; }
.badge-follow_up { background: #FDE68A; color: #92400E; }
.badge-negotiation { background: #FCE7F3; color: #9D174D; }
.badge-booking_done { background: #D1FAE5; color: #065F46; }
.badge-closed_deal { background: #059669; color: #fff; }
.badge-suspected_junk,
.badge-not_reachable,
.badge-fake_details,
.badge-duplicate,
.badge-broker,
.badge-not_interested,
.badge-spam { background: var(--gray-200); color: var(--gray-600); }

.badge-pending { background: #FEF3C7; color: #92400E; }
.badge-in_progress { background: #DBEAFE; color: #1E40AF; }
.badge-completed { background: #D1FAE5; color: #065F46; }
.badge-cancelled { background: var(--gray-200); color: var(--gray-600); }

.badge-low { background: var(--gray-100); color: var(--gray-600); }
.badge-medium { background: #FEF3C7; color: #92400E; }
.badge-high { background: #FED7AA; color: #C2410C; }
.badge-urgent { background: #FECACA; color: #991B1B; }

.badge-admin { background: var(--primary-light); color: var(--primary); }
.badge-sales_manager { background: #D1FAE5; color: #065F46; }
.badge-sales_agent { background: #DBEAFE; color: #1E40AF; }
.badge-telecaller { background: #FEF3C7; color: #92400E; }

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    color: var(--gray-800);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-row .form-group { margin-bottom: 0; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #B45309; color: #fff; }

.btn-outline {
    background: #fff;
    border-color: var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-50); }

.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ========== Modals ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

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

.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover { color: var(--gray-700); }

.modal-body { padding: 20px; }

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ========== Pipeline Board ========== */
.pipeline-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}

.pipeline-column {
    min-width: 280px;
    max-width: 320px;
    background: var(--gray-100);
    border-radius: var(--radius);
    flex-shrink: 0;
}

.pipeline-column-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--primary);
}

.pipeline-column-header .count {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.pipeline-cards { padding: 12px; display: flex; flex-direction: column; gap: 8px; }

.pipeline-card {
    background: #fff;
    border-radius: 6px;
    padding: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow 0.15s;
    border-left: 3px solid var(--primary);
}

.pipeline-card:hover { box-shadow: var(--shadow-md); }
.pipeline-card .lead-name { font-weight: 600; font-size: 14px; }
.pipeline-card .lead-meta { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.pipeline-card .lead-score { float: right; font-weight: 700; font-size: 13px; color: var(--primary); }

/* ========== Timeline ========== */
.timeline { position: relative; padding-left: 24px; }

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item .time {
    font-size: 12px;
    color: var(--gray-400);
    margin-bottom: 4px;
}

.timeline-item .content {
    font-size: 14px;
    color: var(--gray-700);
}

.timeline-item .user {
    font-weight: 600;
    color: var(--gray-800);
}

/* ========== Alerts ========== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #A7F3D0; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #FECACA; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #FDE68A; }
.alert-info { background: var(--info-light); color: var(--info); border: 1px solid #BAE6FD; }

/* ========== Pagination ========== */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    justify-content: center;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    transition: all 0.15s;
}

.pagination a:hover { background: var(--gray-100); color: var(--gray-800); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: 0.5; pointer-events: none; }

/* ========== Filters ========== */
.filters-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 16px;
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.filter-input {
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    min-width: 150px;
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========== Notification Dropdown ========== */
.notification-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 360px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    z-index: 60;
    max-height: 400px;
    overflow-y: auto;
}

.notification-dropdown.active { display: block; }

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.15s;
}

.notification-item:hover { background: var(--gray-50); }
.notification-item.unread { background: var(--primary-light); }
.notification-item .title { font-weight: 600; font-size: 13px; }
.notification-item .message { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.notification-item .time { font-size: 11px; color: var(--gray-400); margin-top: 4px; }

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}

.login-card p {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 32px;
}

.login-card .form-control { padding: 10px 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }

/* ========== Utilities ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.font-bold { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
.w-full { width: 100%; }

.score-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.hot-indicator { color: var(--danger); font-weight: 700; }

/* ========== Responsive ========== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-600);
    cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .pipeline-board { flex-direction: column; }
    .pipeline-column { min-width: auto; max-width: none; }
}

/* ========== Loading ========== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-400);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--gray-600); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }
