/* Modern SaaS CRM Styling */
:root {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --border: #e2e8f0;
    --text-heading: #0f172a;
    --text-body: #334155;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-body);
    line-height: 1.5;
    font-size: 14px;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.brand-text h2 {
    color: white;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.badge-ai {
    font-size: 10px;
    background-color: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-menu {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
}

.nav-badge {
    margin-left: auto;
    background-color: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
}

.groq-status {
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-search {
    position: relative;
    width: 400px;
}

.topbar-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.topbar-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.2s;
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.content-body {
    padding: 32px;
    flex: 1;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-heading);
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 2px;
}

/* Cards & Surfaces */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

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

.bg-blue { background: #eff6ff; color: #2563eb; }
.bg-green { background: #f0fdf4; color: #16a34a; }
.bg-amber { background: #fffbeb; color: #d97706; }
.bg-red { background: #fef2f2; color: #dc2626; }
.bg-purple { background: #faf5ff; color: #9333ea; }

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header a {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.panel-body {
    padding: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-secondary { background-color: white; border-color: var(--border); color: var(--text-body); }
.btn-secondary:hover { background-color: var(--bg-main); }

.btn-success { background-color: var(--success); color: white; }
.btn-success:hover { background-color: #15803d; }

.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { background-color: #b91c1c; }

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

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

/* Forms */
.form-control, .form-select {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background-color: white;
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-heading);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.col-span-2 { grid-column: span 2; }

/* Filter Toolbar */
.filter-toolbar {
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-group { flex-shrink: 0; }
.flex-grow { flex: 1; min-width: 240px; }

/* Business Card Item Layout (Grid & List) */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.cards-list-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.2s;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.card-item-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-heading);
}

.card-item-title {
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
}

.card-item-company {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.star-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.2s;
}

.star-btn.favorite, .star-btn:hover {
    color: #f59e0b;
}

.card-item-contacts {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.contact-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-body);
    word-break: break-all;
}

.contact-row i {
    width: 16px;
    color: var(--text-muted);
}

.tag-badge {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-right: 4px;
    margin-bottom: 4px;
}

/* Upload & Review Layout */
.upload-card {
    padding: 40px;
    text-align: center;
}

.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 60px 40px;
    background-color: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.upload-icon {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 16px;
}

.upload-hint {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.file-formats {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* Progress */
.extraction-progress {
    padding: 40px 20px;
    text-align: center;
}

.spinner {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 16px;
}

.progress-bar-bg {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    max-width: 400px;
    margin: 16px auto;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    transition: width 0.4s ease;
}

.progress-steps {
    font-size: 12px;
    color: var(--text-muted);
}

/* Review Side-by-Side */
.review-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
}

.preview-img-box {
    width: 100%;
    height: 240px;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: 12px;
}

.preview-img-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.form-preview-panel {
    padding: 24px;
}

.edit-form {
    margin-top: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Followup Buckets */
.followup-buckets {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.bucket {
    padding: 0;
}

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

.bucket-header h3 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.bucket-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bucket-red .bucket-header { background-color: #fef2f2; color: #dc2626; }
.bucket-amber .bucket-header { background-color: #fffbeb; color: #d97706; }
.bucket-blue .bucket-header { background-color: #eff6ff; color: #2563eb; }
.bucket-green .bucket-header { background-color: #f0fdf4; color: #16a34a; }
.bucket-purple .bucket-header { background-color: #faf5ff; color: #9333ea; }

.badge-red { background: #fee2e2; color: #dc2626; }
.badge-amber { background: #fef3c7; color: #d97706; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-purple { background: #f3e8ff; color: #9333ea; }

.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-dialog {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-heading);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 24px;
}

/* Timeline notes */
.notes-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.note-item {
    background: var(--bg-main);
    border-left: 3px solid var(--primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.note-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 110;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: #0f172a;
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Utilities & Responsive */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.flex-align-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.p-4 { padding: 16px; }
.cursor-pointer { cursor: pointer; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }

@media (max-width: 900px) {
    .sidebar { width: 70px; }
    .sidebar .brand-text, .sidebar span, .sidebar-footer { display: none; }
    .main-content { margin-left: 70px; }
    .review-layout, .dashboard-grid, .grid-2 { grid-template-columns: 1fr; }
}
