/* ─── CRM App — Global Styles ────────────────────────────── */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d28;
    --bg-card: #1e2130;
    --bg-hover: #252838;
    --bg-input: #14161f;
    --border: #2a2d3a;
    --border-focus: #5b6eef;
    --text-primary: #e4e6ed;
    --text-secondary: #8b8fa3;
    --text-muted: #5c6072;
    --accent: #5b6eef;
    --accent-hover: #4a5cd4;
    --accent-subtle: rgba(91, 110, 239, 0.12);
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.12);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    --transition: 150ms ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* ─── Layout ─────────────────────────────────────────────── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.sidebar-logo h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.sidebar-logo span {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav {
    list-style: none;
    padding: 0 8px;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.sidebar-nav li a .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 32px 40px;
    max-width: 1200px;
}

/* ─── Page Header ────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

/* ─── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color var(--transition);
}

.card:hover {
    border-color: var(--border-focus);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ─── Stats Grid ─────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stat-card .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-card .stat-value.accent { color: var(--accent); }
.stat-card .stat-value.success { color: var(--success); }
.stat-card .stat-value.warning { color: var(--warning); }
.stat-card .stat-value.danger { color: var(--danger); }
.stat-card .stat-value.info { color: var(--info); }

/* ─── Tables ─────────────────────────────────────────────── */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-weight: 600;
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-primary);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

/* ─── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-bg);
}

.btn-success {
    background: transparent;
    color: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    background: var(--success-bg);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ─── Forms & Inputs ─────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

input[type="text"],
input[type="email"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

select {
    cursor: pointer;
}

/* ─── Badges ─────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-active { background: var(--success-bg); color: var(--success); }
.badge-unsubscribed { background: var(--danger-bg); color: var(--danger); }
.badge-bounced { background: var(--warning-bg); color: var(--warning); }
.badge-replied { background: var(--info-bg); color: var(--info); }
.badge-in_hubspot { background: var(--accent-subtle); color: var(--accent); }
.badge-completed { background: var(--success-bg); color: var(--success); }
.badge-stopped { background: var(--danger-bg); color: var(--danger); }
.badge-paused { background: var(--warning-bg); color: var(--warning); }

.badge-ceo { background: var(--warning-bg); color: var(--warning); }
.badge-recruiter { background: var(--info-bg); color: var(--info); }
.badge-other { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

/* ─── Pagination ─────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.pagination button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.pagination button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination .page-info {
    font-size: 12px;
    color: var(--text-muted);
}

/* ─── File Upload ────────────────────────────────────────── */

.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-input);
}

.file-upload:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.file-upload p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 8px;
}

.file-upload .upload-icon {
    font-size: 32px;
    color: var(--text-muted);
}

/* ─── Alerts / Toasts ────────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(96, 165, 250, 0.2);
}

/* ─── Toolbar (filters, search) ──────────────────────────── */

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar input[type="text"] {
    max-width: 300px;
}

.toolbar select {
    max-width: 160px;
}

/* ─── Event Timeline ─────────────────────────────────────── */

.timeline {
    list-style: none;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.timeline-dot.sent { background: var(--accent); }
.timeline-dot.opened { background: var(--success); }
.timeline-dot.clicked { background: var(--info); }
.timeline-dot.bounced { background: var(--warning); }
.timeline-dot.unsubscribed { background: var(--danger); }

.timeline-content {
    flex: 1;
}

.timeline-content .event-type {
    font-weight: 600;
    font-size: 13px;
    text-transform: capitalize;
}

.timeline-content .event-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Sequence Steps ─────────────────────────────────────── */

.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 12px;
    position: relative;
}

.step-card .step-number {
    position: absolute;
    top: -10px;
    left: 16px;
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.step-card .step-delay {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.step-card .step-subject {
    font-weight: 600;
    margin-bottom: 8px;
}

.step-card .step-body {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    line-height: 1.6;
    max-height: 120px;
    overflow: hidden;
}

.step-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ─── Modal ──────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ─── Loading Spinner ────────────────────────────────────── */

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ─── Empty State ────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* ─── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-logo h1,
    .sidebar-logo span,
    .sidebar-nav li a span {
        display: none;
    }

    .main-content {
        margin-left: 60px;
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar input[type="text"],
    .toolbar select {
        max-width: 100%;
    }
}
