:root {
    --sidebar-width: 260px;
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-main: #f8fafc;
    --bg-sidebar: #1e293b;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-sidebar: #cbd5e1;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 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);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: white;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.75rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 2rem;
}

.logo-img-sidebar {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    background: white;
    padding: 2px;
}

.logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: white;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-on-sidebar);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

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

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

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main Content Styling */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

.page-title p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Dashboard Modules */
.dashboard-module {
    display: none;
    animation: fadeIn 0.3s ease;
}

.dashboard-module.active {
    display: block;
}

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

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-blue { background: #eff6ff; color: #3b82f6; }
.icon-purple { background: #f5f3ff; color: #8b5cf6; }
.icon-green { background: #ecfdf5; color: #10b981; }
.icon-orange { background: #fff7ed; color: #f59e0b; }

.stat-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

/* Table Area */
.content-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.search-wrapper {
    position: relative;
    max-width: 320px;
}

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

.search-input {
    padding: 0.625rem 2.5rem 0.625rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    width: 300px;
    background: var(--bg-main);
    transition: all 0.2s;
}

.search-clear-btn {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: none; /* Hidden by default */
    border-radius: 4px;
    transition: all 0.15s ease;
}

.search-clear-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--danger);
}

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

/* Shared Table Styles */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 600px; /* ensures horizontal scroll on small screens */
}

th {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td {
    background-color: #f8fafc;
}

/* Badges & Indicators */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-premium { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

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

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

.btn-outline {
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-main);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
}

.btn-icon-only {
    padding: 0.5rem;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Form Elements */
.extension-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    background: white;
    cursor: pointer;
}

/* Plan Select in Table */
.plan-select {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    background-color: #f8fafc;
    cursor: pointer;
}

/* Modal Base */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal.active {
    display: flex;
    animation: modalOverlayFade 0.3s ease;
}

/* Sync Status Indicator */
.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(124, 93, 250, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    margin-left: 15px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.sync-paused .live-dot {
    background: #f59e0b;
    animation: none;
}

@keyframes modalOverlayFade {
    from { background: rgba(0, 0, 0, 0); backdrop-filter: blur(0); }
    to { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: white;
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 300px;
    transform: translateX(120%);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    border-left: 4px solid var(--primary);
}

.toast.active {
    transform: translateX(0);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--primary); }

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Modal & Form Redesign */
.modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    max-width: 600px;
    width: 95%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
}

.modal-header {
    margin-bottom: 2rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.025em;
    margin-bottom: 0.25rem;
}

.modal-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.form-group input, 
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #e1e8f0;
    border-radius: 10px;
    font-size: 0.9375rem;
    color: var(--text-main);
    transition: all 0.2s ease;
    background: #fcfdfe;
}

.form-group input:focus, 
.form-group select:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.preset-banner {
    grid-column: span 2;
    background: linear-gradient(to right, #f8fafc, #f1f5f9);
    padding: 1rem;
    border-radius: 12px;
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.preset-banner label {
    margin-bottom: 0;
    white-space: nowrap;
    color: var(--primary);
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.modal-footer .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 700;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }
    .logo-text, .nav-item span {
        display: none;
    }
    .main-content {
        margin-left: 80px;
    }
}

/* Pagination Controls */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: #ffffff;
}

.pagination-info {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.pagination-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#activityPageIndicator,
#userPageIndicator {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    border-radius: 6px;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.875rem;
    border: 1px solid var(--border);
}

.pagination-actions .btn {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-actions .btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

@media (max-width: 640px) {
    .pagination-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Powered By Footer */
.powered-by-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    border-top: 1px solid var(--border);
    margin-top: auto;
    background: transparent;
}

.powered-by-footer strong {
    color: var(--primary);
}
/* Modal Close Button */
.close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #64748b;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg);
}

/* Leads filter row */
.leads-filter-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}

/* Sortable column headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
th.sortable:hover {
    color: var(--primary);
}
.sort-arrow {
    font-size: 10px;
    color: var(--secondary);
    margin-left: 3px;
}
th.sort-asc .sort-arrow { color: var(--primary); }
th.sort-desc .sort-arrow { color: var(--primary); }
th.sort-asc .sort-arrow::after { content: "▲"; }
th.sort-desc .sort-arrow::after { content: "▼"; }
th.sortable .sort-arrow::after { content: "▲"; }
th.sort-asc .sort-arrow::after { content: "▲"; }
th.sort-desc .sort-arrow::after { content: "▼"; }
th:not(.sortable) .sort-arrow { display: none; }
th.sortable:not(.sort-asc):not(.sort-desc) .sort-arrow { opacity: 0.3; }

/* Remote Config field hints */
.field-hint {
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    margin-bottom: 8px;
    line-height: 1.4;
}
