/* ============================================================
   UniCRM Design System
   ============================================================ */

:root {
    /* Colors */
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --secondary: #10B981;
    --secondary-dark: #059669;
    --accent: #F59E0B;
    --danger: #EF4444;
    --info: #0EA5E9;

    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --border: #E2E8F0;

    --sidebar-bg: #1E293B;
    --sidebar-text: #94A3B8;
    --sidebar-active: #4F46E5;
    --sidebar-hover: #334155;

    --text: #1E293B;
    --text-muted: #64748B;
    --text-light: #94A3B8;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

    /* Radius */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    /* Sidebar */
    --sidebar-width: 260px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

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

/* ============ Sidebar ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-header {
    padding: var(--space-5) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.sidebar-brand small { display:block; font-size: 11px; font-weight: 400; color: var(--sidebar-text); }

.sidebar-nav {
    flex: 1;
    padding: var(--space-4) var(--space-3);
    overflow-y: auto;
}

.nav-group-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: var(--space-4) var(--space-3) var(--space-2);
    color: var(--text-light);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.2s;
    position: relative;
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
}
.nav-item .badge {
    margin-left: auto;
}

.sidebar-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid rgba(255,255,255,0.05);
}

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

/* Topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    position: sticky;
    top: 0;
    z-index: 90;
    height: 64px;
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text);
    cursor: pointer;
    padding: var(--space-2);
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

/* Notification bell */
.notif-bell {
    position: relative;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    padding: var(--space-2);
}
.notif-bell:hover { color: var(--text); }
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-weight: 600;
}

/* User dropdown */
.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    position: relative;
}
.user-menu:hover { background: var(--surface-2); }
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}
.user-menu-name { font-weight: 500; font-size: 13px; }
.user-menu-role { font-size: 11px; color: var(--text-muted); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 200;
    display: none;
    overflow: hidden;
}
.dropdown.active .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    color: var(--text);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu .dropdown-divider { border-top: 1px solid var(--border); margin: var(--space-1) 0; }
.dropdown-menu .dropdown-label { padding: var(--space-3) var(--space-4) var(--space-1); font-weight: 600; font-size: 12px; color: var(--text-muted); }

/* Dropdown - Notifications */
.notif-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
}
.notif-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-2, var(--border));
    cursor: pointer;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--primary-light); }
.notif-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.notif-title { font-weight: 600; font-size: 13px; }
.notif-msg { font-size: 12px; color: var(--text-muted); }
.notif-time { font-size: 11px; color: var(--text-light); }

/* Page content */
.page {
    flex: 1;
    padding: var(--space-6);
}

/* ============ Cards ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}
.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}
.card-body { padding: var(--space-5); }
.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

/* ============ Stats Cards ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: var(--space-4);
}
.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}
.stat-card .stat-change {
    font-size: 12px;
    font-weight: 600;
    margin-top: var(--space-2);
}
.stat-change.up { color: var(--secondary); }
.stat-change.down { color: var(--danger); }

/* Icon backgrounds */
.icon-primary { background: var(--primary-light); color: var(--primary); }
.icon-secondary { background: #ECFDF5; color: var(--secondary); }
.icon-accent { background: #FFFBEB; color: var(--accent); }
.icon-info { background: #F0F9FF; color: var(--info); }
.icon-danger { background: #FEF2F2; color: var(--danger); }
.icon-dark { background: #F1F5F9; color: var(--sidebar-bg); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
}
.table thead th {
    background: var(--surface-2);
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

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

/* ============ Badges ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-secondary { background: var(--surface-2); color: var(--text-muted); }
.badge-success { background: #D1FAE5; color: #047857; }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-danger { background: #FEE2E2; color: #B91C1C; }
.badge-info { background: #E0F2FE; color: #0369A1; }
.badge-dark { background: #334155; color: #fff; }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.4;
    white-space: nowrap;
}
.btn i { font-size: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-outline-primary { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: #FEF2F2; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============ Forms ============ */
.form-group { margin-bottom: var(--space-4); }
.form-label {
    display: block;
    font-weight: 500;
    font-size: 13px;
    margin-bottom: var(--space-2);
    color: var(--text);
}
.form-label .required { color: var(--danger); }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,..."); cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}
.form-textarea-lg { min-height: 200px; }

/* Search input */
.search-input { position: relative; }
.search-input i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 14px;
}
.search-input input {
    padding-left: 36px;
}

/* ============ Alerts ============ */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.alert i { font-size: 16px; }
.alert-success { background: #D1FAE5; color: #047857; }
.alert-error, .alert-danger { background: #FEE2E2; color: #B91C1C; }
.alert-warning { background: #FEF3C7; color: #B45309; }
.alert-info { background: #E0F2FE; color: #0369A1; }

/* ============ Pagination ============ */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    justify-content: center;
    padding: var(--space-4);
}
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    background: var(--surface);
}
.pagination a:hover { background: var(--surface-2); }
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ Page Header ============ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }

/* ============ Toolbar / Filters ============ */
.toolbar {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}
.toolbar .form-control { width: auto; min-width: 160px; }

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; color: var(--text-light); margin-bottom: var(--space-4); }
.empty-state h3 { color: var(--text); margin-bottom: var(--space-2); }
.empty-state p { max-width: 400px; margin: 0 auto var(--space-4); }
.empty-state .btn { margin-top: var(--space-2); }

/* ============ Auth Pages ============ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
}
.auth-wrapper::before,
.auth-wrapper::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
}
.auth-wrapper::before { width: 400px; height: 400px; top: -100px; left: -100px; }
.auth-wrapper::after { width: 500px; height: 500px; bottom: -150px; right: -100px; }

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-8);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}
.auth-card-wide { max-width: 520px; }
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}
.auth-logo .sidebar-logo { width: 48px; height: 48px; font-size: 22px; }
.auth-logo .auth-brand { font-size: 24px; font-weight: 700; color: var(--text); }

.auth-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: var(--space-6); }

.auth-footer {
    text-align: center;
    margin-top: var(--space-5);
    font-size: 13px;
    color: var(--text-muted);
}

.auth-alert { margin-bottom: var(--space-4); }

/* Password strength */
.password-strength {
    height: 4px;
    background: var(--surface-2);
    border-radius: 999px;
    margin-top: var(--space-2);
    overflow: hidden;
}
.password-strength-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    transition: width 0.3s, background 0.3s;
}
.password-strength-fill.weak { width: 33%; background: var(--danger); }
.password-strength-fill.medium { width: 66%; background: var(--accent); }
.password-strength-fill.strong { width: 100%; background: var(--secondary); }

/* ============ Detail Views ============ */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-5);
}
.detail-list { list-style: none; }
.detail-list li {
    display: flex;
    justify-content: space-between;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
    gap: var(--space-4);
}
.detail-list li:last-child { border-bottom: none; }
.detail-list .label { color: var(--text-muted); font-weight: 500; font-size: 13px; }
.detail-list .value { font-weight: 500; text-align: right; word-break: break-word; }

/* Definition grid */
.def-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}
.def-item { background: var(--surface-2); border-radius: var(--radius); padding: var(--space-4); }
.def-item .def-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.def-item .def-value { font-weight: 600; font-size: 14px; }

/* ============ Platform Cards ============ */
.platform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-5);
}
.platform-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}
.platform-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}
.platform-logo {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700;
}
.platform-wp { background: #F0F6FC; color: #21759B; }
.platform-shopify { background: #E7F9EF; color: #008060; }
.platform-name { font-weight: 600; font-size: 15px; }
.platform-url { font-size: 12px; color: var(--text-muted); }

/* ============ Connect Wizard ============ */
.wizard-container {
    max-width: 760px;
    margin: 0 auto;
    padding: var(--space-4) 0;
}
/* Step indicator — horizontal bar */
.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: var(--space-8);
    padding: var(--space-5) var(--space-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.wizard-steps .step-dot {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; flex-shrink: 0;
    background: var(--surface-2); color: var(--text-muted);
    border: 2px solid var(--border);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}
.wizard-steps .step-dot.active {
    background: var(--primary); color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79,70,229,0.18);
}
.wizard-steps .step-dot.done {
    background: var(--success); color: #fff;
    border-color: var(--success);
}
.wizard-steps .step-line {
    height: 3px; width: 80px;
    background: var(--border);
    transition: background 0.4s ease;
    flex-shrink: 0;
    margin: 0 -2px;
}
.wizard-steps .step-line.done { background: var(--success); }

/* Step content */
.wizard-step { display: none; animation: fadeUp 0.35s ease; }
.wizard-step.active { display: block; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.wizard-step h2 {
    font-size: 26px; font-weight: 800;
    margin-bottom: var(--space-2);
    color: var(--text);
    letter-spacing: -0.3px;
}
.wizard-step .step-subtitle {
    color: var(--text-muted); margin-bottom: var(--space-6);
    font-size: 15px; line-height: 1.5;
}

/* Choice cards — premium large clickable */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.choice-card {
    border: 2px solid var(--border); border-radius: var(--radius-lg);
    padding: var(--space-7) var(--space-6); text-align: center;
    cursor: pointer; transition: all 0.3s ease;
    background: var(--surface);
    position: relative;
    box-shadow: var(--shadow-sm);
    min-height: 200px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.choice-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 25px -5px rgba(79,70,229,0.18), 0 4px 10px -3px rgba(0,0,0,0.06);
    transform: translateY(-4px);
}
.choice-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(79,70,229,0.04), rgba(79,70,229,0.08));
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15), 0 8px 20px -4px rgba(79,70,229,0.12);
}
.choice-card .card-icon {
    font-size: 52px; margin-bottom: var(--space-4); display: block;
    width: 80px; height: 80px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto var(--space-4);
}
.choice-card:nth-child(1) .card-icon { background: rgba(33,117,155,0.08); }
.choice-card:nth-child(2) .card-icon { background: rgba(94,142,62,0.08); }
.choice-card h4 {
    font-size: 18px; font-weight: 700;
    margin-bottom: var(--space-2);
}
.choice-card p {
    font-size: 13px; color: var(--text-muted); line-height: 1.6; margin: 0;
}
.choice-card .check-badge {
    position: absolute; top: 14px; right: 14px;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 12px;
    display: none; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(79,70,229,0.3);
}
.choice-card.selected .check-badge { display: flex; }

/* Plugin grid — 2×2 for WP forms */
.plugin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.plugin-card {
    border: 2px solid var(--border); border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-5); cursor: pointer;
    transition: all 0.3s ease;
    background: var(--surface); text-align: center;
    box-shadow: var(--shadow-sm);
}
.plugin-card:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 16px -4px rgba(79,70,229,0.15);
    transform: translateY(-2px);
}
.plugin-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(79,70,229,0.03), rgba(79,70,229,0.07));
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.plugin-card .plugin-icon {
    font-size: 36px; margin-bottom: var(--space-3); display: block;
    width: 64px; height: 64px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto var(--space-3);
    background: var(--surface-2);
}
.plugin-card h5 { font-size: 15px; font-weight: 700; margin-bottom: var(--space-2); }
.plugin-card p { font-size: 12px; color: var(--text-muted); margin: 0; line-height: 1.5; }

/* Single setup card (WooCommerce / Shopify) */
.setup-card {
    border: 2px solid var(--primary); border-radius: var(--radius-lg);
    padding: var(--space-7) var(--space-6);
    background: linear-gradient(135deg, rgba(79,70,229,0.02), rgba(79,70,229,0.06));
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.setup-card .setup-icon {
    font-size: 56px; margin-bottom: var(--space-4); display: block;
    width: 96px; height: 96px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto var(--space-4);
    background: rgba(124,58,237,0.08);
}
.setup-card h4 { font-size: 19px; font-weight: 700; margin-bottom: var(--space-3); }
.setup-card p { font-size: 14px; color: var(--text-muted); line-height: 1.7; margin: 0; }

/* Test connection result */
.test-result {
    display: none; padding: var(--space-3) var(--space-4);
    border-radius: var(--radius); font-size: 14px; font-weight: 500;
    margin-top: var(--space-3); align-items: center; gap: var(--space-2);
}
.test-result.show { display: flex; }
.test-result.success { background: rgba(16,185,129,0.1); color: #047857; border: 1px solid rgba(16,185,129,0.2); }
.test-result.error { background: rgba(239,68,68,0.1); color: #b91c1c; border: 1px solid rgba(239,68,68,0.2); }

/* Wizard nav buttons */
.wizard-nav { display: flex; gap: var(--space-3); margin-top: var(--space-6); justify-content: space-between; }

/* Success page enhancements */
.success-hero {
    text-align: center; padding: var(--space-6) 0 var(--space-4);
    background: linear-gradient(135deg, rgba(16,185,129,0.03), rgba(16,185,129,0.08));
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
}
.success-hero .hero-icon { font-size: 72px; display: block; margin-bottom: var(--space-3); }
.success-hero h1 { font-size: 28px; font-weight: 800; margin-bottom: var(--space-2); }
.success-hero p { color: var(--text-muted); font-size: 15px; }
.instruction-step {
    display: flex; gap: var(--space-4); padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border);
}
.instruction-step:last-child { border-bottom: none; }
.instruction-step .step-num {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 14px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(79,70,229,0.25);
}
.instruction-step .step-content h4 { font-size: 15px; font-weight: 600; margin-bottom: var(--space-1); }
.instruction-step .step-content p { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin: 0; }
.instruction-step .step-content code {
    background: var(--sidebar-bg); color: #A5F3FC; padding: 2px 6px;
    border-radius: 4px; font-size: 12px;
}

@media (max-width: 640px) {
    .choice-grid, .plugin-grid { grid-template-columns: 1fr; }
    .wizard-steps .step-line { width: 40px; }
    .wizard-steps .step-dot { width: 38px; height: 38px; font-size: 14px; }
    .wizard-step h2 { font-size: 22px; }
    .choice-card { min-height: 160px; padding: var(--space-6) var(--space-4); }
    .connect-options { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .def-grid { grid-template-columns: 1fr; }
    .platform-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-actions { width: 100%; }
    .modal-card { width: 95%; max-height: 90vh; overflow-y: auto; padding: var(--space-4); }
    .contact-actions { gap: var(--space-2); }
    .contact-btn { padding: 8px 14px; font-size: 13px; }
    .detail-list li { flex-direction: column; gap: var(--space-1); }
    .detail-list .value { text-align: left; }
    .card-body { padding: var(--space-4); }
    .card-header { padding: var(--space-3) var(--space-4); }
    .topbar { padding: var(--space-3) var(--space-4); }
    .topbar-title { font-size: 16px; }
    .page { padding: var(--space-4); }
    .wizard-nav { flex-direction: column; }
    .wizard-nav .btn { width: 100%; }
}

/* Connect option cards */
.connect-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}
.connect-option {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
}
.connect-option:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.connect-option.selected { border-color: var(--primary); background: var(--primary-light); }
.connect-option i { font-size: 40px; margin-bottom: var(--space-4); }
.connect-option h4 { margin-bottom: var(--space-2); }
.connect-option p { font-size: 12px; color: var(--text-muted); }

/* Webhook URL box */
.code-box {
    background: var(--sidebar-bg);
    color: #A5F3FC;
    padding: var(--space-4);
    border-radius: var(--radius);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

/* Steps */
.steps {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
    align-items: center;
}
.step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}
.step-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 2px solid var(--border);
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.step.active .step-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.active { color: var(--text); }

/* ============ Chart containers ============ */
.chart-box {
    position: relative;
    height: 300px;
}
.chart-box-sm { height: 220px; }
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-5);
}

/* ============ Tabs ============ */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: var(--space-5);
    overflow-x: auto;
}
.tab {
    padding: var(--space-3) var(--space-5);
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font);
    font-size: 14px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============ Misc ============ */
.text-muted { color: var(--text-muted); }
.text-light { color: var(--text-light); }
.text-danger { color: var(--danger); }
.text-success { color: var(--secondary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.toast {
    background: var(--surface);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: var(--space-4);
    min-width: 280px;
    max-width: 360px;
    animation: toast-in 0.3s ease;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.toast.success { border-left-color: var(--secondary); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--accent); }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   Contact Lead / Customer — Modal & Contact Card
   ============================================================ */

/* Modal Overlay */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    animation: modal-fade-in 0.2s ease;
}
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-6);
    width: 90%; max-width: 480px;
    animation: modal-slide-up 0.25s ease;
}
@keyframes modal-slide-up { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-card h3 {
    margin: 0 0 var(--space-5);
    font-size: 18px; font-weight: 600;
}

/* Contact Card */
.contact-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    background: var(--surface);
}
.contact-card h3 {
    margin: 0 0 var(--space-4);
    font-size: 16px; font-weight: 600;
}
.contact-actions {
    display: flex; gap: var(--space-3); flex-wrap: wrap;
}
.contact-btn {
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
}
.contact-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.contact-btn.email-btn i { color: var(--primary); }
.contact-btn.whatsapp-btn:hover { background: #DCF8C6; border-color: #25D366; color: #128C7E; }
.contact-btn.whatsapp-btn i { color: #25D366; }
.contact-btn.tele-btn:hover { background: #FEF3C7; border-color: var(--accent); color: #92400E; }
.contact-btn.tele-btn i { color: var(--accent); }

/* Email result inside modal */
#emailResult.success-msg {
    background: #DCF8C6; color: #065F46; border: 1px solid #25D366;
    padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: var(--space-3);
    font-size: 14px;
}
#emailResult.error-msg {
    background: #FEE2E2; color: #991B1B; border: 1px solid var(--danger);
    padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: var(--space-3);
    font-size: 14px;
}
#customerEmailResult.success-msg {
    background: #DCF8C6; color: #065F46; border: 1px solid #25D366;
    padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: var(--space-3);
    font-size: 14px;
}
#customerEmailResult.error-msg {
    background: #FEE2E2; color: #991B1B; border: 1px solid var(--danger);
    padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: var(--space-3);
    font-size: 14px;
}

/* ============================================================
   Chat Drawer (Lead / Customer conversation)
   ============================================================ */
.chat-backdrop {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0; visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 1200;
}
.chat-backdrop.show { opacity: 1; visibility: visible; }

.chat-drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 400px; max-width: 96vw;
    background: var(--surface);
    box-shadow: -12px 0 40px rgba(15, 23, 42, 0.18);
    z-index: 1300;
    display: flex; flex-direction: column;
    transform: translateX(105%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    border-left: 1px solid var(--border);
}
.chat-drawer.open { transform: translateX(0); }

/* Header */
.chat-header {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    background: var(--primary);
    color: #fff;
}
.chat-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(255,255,255,0.22); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.chat-head-info { flex: 1; min-width: 0; }
.chat-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-close {
    background: none; border: none; color: #fff; font-size: 26px;
    line-height: 1; cursor: pointer; padding: 0 4px; opacity: 0.85;
}
.chat-close:hover { opacity: 1; }

/* Tabs */
.chat-tabs {
    display: flex; gap: 4px; padding: var(--space-3) var(--space-5) 0;
    border-bottom: 1px solid var(--border);
}
.chat-tab {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 12px; border: none; border-bottom: 2px solid transparent;
    background: none; cursor: pointer; font-size: 14px; font-weight: 500;
    color: var(--text-muted, #64748B);
}
.chat-tab i { font-size: 15px; }
.chat-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.chat-tab.active i { color: var(--primary); }

/* Thread */
.chat-body {
    flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-4);
    background: #F1F5F9;
    display: flex; flex-direction: column; gap: 10px;
}
.chat-loading { color: var(--text-muted, #64748B); text-align: center; font-size: 13px; padding: 12px 0; }

.chat-bubble {
    max-width: 82%; padding: 10px 14px; border-radius: 16px;
    font-size: 14px; line-height: 1.5; word-break: break-word;
}
.chat-bubble.in {
    align-self: flex-start;
    background: #fff; border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-bubble.out {
    align-self: flex-end;
    background: var(--primary); color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble.out[data-wa] { background: #25D366; color: #075E54; font-weight: 500; }
.chat-meta {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; margin-bottom: 5px; opacity: 0.9;
}
.chat-bubble.out .chat-meta { color: #E0E7FF; }
.chat-meta .chat-subj { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta .chat-time { margin-left: auto; }
.chat-text { white-space: pre-wrap; }

/* Composer */
.chat-composer {
    border-top: 1px solid var(--border);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
}
.chat-subject {
    width: 100%; box-sizing: border-box;
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit; margin-bottom: 6px;
}
.chat-subject:focus { outline: none; border-color: var(--primary); }
.chat-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-input {
    flex: 1; resize: none; box-sizing: border-box;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px; font-family: inherit; line-height: 1.4; min-height: 44px;
}
.chat-input:focus { outline: none; border-color: var(--primary); }
.chat-send {
    width: 44px; height: 44px; flex-shrink: 0;
    border: none; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 16px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.chat-send:hover { background: var(--primary-dark); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-note { font-size: 11px; color: var(--text-muted, #64748B); margin-top: 6px; }
.chat-result { font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); margin-bottom: 6px; }
.chat-result.ok { background: #DCF8C6; color: #065F46; border: 1px solid #25D366; }
.chat-result.err { background: #FEE2E2; color: #991B1B; border: 1px solid var(--danger); }

@media (max-width: 640px) {
    .chat-drawer { width: 100%; max-width: 100vw; }
    .chat-bubble { max-width: 88%; }
}
