/* autoreceptionist.ai Admin CSS */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e1e4e8;
    --text: #1a1a2e;
    --text2: #586069;
    --text3: #8b949e;
    --primary: #0366d6;
    --primary-hover: #0256b9;
    --success: #28a745;
    --danger: #d73a49;
    --warning: #e36209;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* Layout */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--text); color: #fff; padding: 20px 0; display: flex; flex-direction: column; position: fixed; height: 100vh; overflow-y: auto; }
.sidebar-brand { padding: 0 16px 20px; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 12px; }
.brand-dot { color: var(--primary); }
.badge-admin { display: inline-block; background: var(--primary); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 3px; margin-left: 6px; vertical-align: middle; }
.sidebar-nav { list-style: none; flex: 1; }
.sidebar-nav li a { display: block; padding: 8px 16px; color: rgba(255,255,255,0.7); text-decoration: none; font-size: 13px; transition: all 0.15s; }
.sidebar-nav li a:hover, .sidebar-nav li a.active { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 12px; }
.sidebar-user { color: rgba(255,255,255,0.6); display: block; margin-bottom: 4px; }
.sidebar-logout { color: rgba(255,255,255,0.4); text-decoration: none; font-size: 11px; }
.sidebar-logout:hover { color: #fff; }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 24px 32px; max-width: 960px; }
.content-header { margin-bottom: 24px; }
.content-header h1 { font-size: 22px; font-weight: 600; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text3); display: block; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; }

/* Flash Messages */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.flash-success { background: #dcffe4; border: 1px solid var(--success); color: #165c26; }
.flash-error { background: #ffeef0; border: 1px solid var(--danger); color: #86181d; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; font-size: 13px; font-weight: 500; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; transition: all 0.15s; line-height: 1.4; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--surface); color: var(--text); font-family: inherit; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(3,102,214,0.15); }
.form-group textarea { resize: vertical; }
.input-readonly { background: var(--bg) !important; color: var(--text3) !important; }
.input-password-wrap { display: flex; gap: 6px; }
.input-password-wrap input { flex: 1; }
.btn-toggle-password { flex-shrink: 0; }

/* Source badges */
.source-badge { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 500; margin-left: 6px; }
.source-env { background: #e1e4e8; color: var(--text3); }
.source-database { background: #dcffe4; color: #165c26; }

/* Settings nav */
.settings-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; background: var(--surface); padding: 6px; border-radius: var(--radius); border: 1px solid var(--border); }
.settings-nav-item { padding: 6px 12px; font-size: 12px; font-weight: 500; text-decoration: none; color: var(--text2); border-radius: 4px; transition: all 0.15s; }
.settings-nav-item:hover { background: var(--bg); color: var(--text); }
.settings-section { scroll-margin-top: 20px; }

/* Table */
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.table-count { font-size: 13px; color: var(--text3); }
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { font-size: 11px; font-weight: 600; color: var(--text3); text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); }
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border: none; }
.empty-state { text-align: center; padding: 40px; color: var(--text3); }

/* Badges */
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.badge-trial { background: #fff8c5; color: #735c0f; }
.badge-starter { background: #e1e4e8; color: var(--text2); }
.badge-pro { background: #dbedff; color: #0366d6; }
.badge-enterprise { background: #f1e5ff; color: #6f42c1; }

/* Status dots */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.status-active { background: var(--success); }
.status-inactive { background: var(--text3); }

/* Setup checklist */
.setup-checklist { display: flex; flex-direction: column; gap: 8px; }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13px; }
.checklist-item.done .checklist-icon { color: var(--success); }
.checklist-item.pending .checklist-icon { color: var(--text3); }
.checklist-icon { font-size: 16px; width: 20px; text-align: center; }

/* Quick links */
.quick-links { display: flex; gap: 8px; flex-wrap: wrap; }

/* Wizard */
.wizard-progress { display: flex; align-items: center; justify-content: center; gap: 0; margin-bottom: 24px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.wizard-step { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wizard-step-num { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: var(--bg); color: var(--text3); border: 2px solid var(--border); }
.wizard-step.active .wizard-step-num { background: var(--primary); color: #fff; border-color: var(--primary); }
.wizard-step.done .wizard-step-num { background: var(--success); color: #fff; border-color: var(--success); }
.wizard-step-label { font-size: 11px; color: var(--text3); }
.wizard-step.active .wizard-step-label { color: var(--primary); font-weight: 600; }
.wizard-step.done .wizard-step-label { color: var(--success); }
.wizard-line { width: 40px; height: 2px; background: var(--border); margin: 0 8px; margin-bottom: 18px; }
.wizard-status { font-size: 12px; margin-left: 10px; }
.wizard-status.loading { color: var(--text3); }
.wizard-status.success { color: var(--success); }
.wizard-status.error { color: var(--danger); }

/* Plan preview */
.plan-preview { margin: 12px 0; padding-left: 20px; }
.plan-preview li { margin-bottom: 4px; font-size: 13px; }

/* Copy field */
.copy-field { display: flex; align-items: center; gap: 8px; margin: 8px 0; background: var(--bg); padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border); }
.copy-field code { flex: 1; font-size: 12px; word-break: break-all; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--text3); margin-bottom: 20px; }

/* Sidebar sections */
.sidebar-divider { border-top: 1px solid rgba(255,255,255,0.08); margin: 8px 0; list-style: none; }
.sidebar-section { padding: 4px 16px 2px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.35); list-style: none; }

/* Outreach sub-nav */
.outreach-nav { display: flex; gap: 4px; margin-bottom: 20px; background: var(--surface); padding: 6px; border-radius: var(--radius); border: 1px solid var(--border); }
.outreach-nav a { padding: 6px 14px; font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text2); border-radius: 4px; transition: all 0.15s; }
.outreach-nav a:hover { background: var(--bg); color: var(--text); }
.outreach-nav a.active { background: var(--primary); color: #fff; }

/* 5-column stats grid */
.stats-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }

/* Card header with flex layout */
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-header h3 { margin: 0; font-size: 15px; font-weight: 600; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

/* Form rows */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form-control { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--surface); color: var(--text); font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(3,102,214,0.15); }

/* Checkbox rows */
.checkbox-row { display: flex; gap: 12px; flex-wrap: wrap; padding: 6px 0; }
.checkbox-label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.checkbox-label input[type="checkbox"] { cursor: pointer; }

/* Code textarea */
.code-textarea { font-family: 'Menlo', 'Consolas', 'Courier New', monospace; font-size: 12px; line-height: 1.6; min-height: 200px; resize: vertical; white-space: pre-wrap; }

/* Clickable table rows */
.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: var(--bg); }

/* Table scroll wrapper */
.table-scroll { overflow-x: auto; }

/* Scripts grid */
.scripts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.script-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.script-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.script-desc { font-size: 13px; color: var(--text2); margin-bottom: 10px; }
.script-preview { background: var(--bg); padding: 10px; border-radius: 4px; font-size: 12px; color: var(--text2); margin-bottom: 10px; max-height: 80px; overflow: hidden; white-space: pre-wrap; }
.script-meta { font-size: 11px; color: var(--text3); margin-bottom: 10px; }
.script-actions { display: flex; gap: 6px; margin-top: auto; }

/* Mapping grid (CSV import) */
.mapping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 14px 0; }
.mapping-item { display: flex; flex-direction: column; gap: 4px; }
.mapping-item label { font-size: 12px; font-weight: 600; color: var(--text2); }
.mapping-item select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }

/* Extra badge variants */
.badge-lg { font-size: 13px; padding: 4px 12px; }
.badge-draft { background: #e1e4e8; color: var(--text2); }
.badge-active { background: #dcffe4; color: #165c26; }
.badge-paused { background: #fff8c5; color: #735c0f; }
.badge-completed { background: #dbedff; color: #0366d6; }
.badge-new { background: #dbedff; color: #0366d6; }
.badge-queued { background: #e1e4e8; color: var(--text2); }
.badge-calling { background: #fff8c5; color: #735c0f; }
.badge-no_answer { background: #ffeef0; color: #86181d; }
.badge-voicemail { background: #fff8c5; color: #735c0f; }
.badge-interested { background: #dcffe4; color: #165c26; }
.badge-booked { background: #dcffe4; color: #165c26; }
.badge-declined { background: #ffeef0; color: #86181d; }
.badge-do_not_call { background: #86181d; color: #fff; }
.badge-pending { background: #e1e4e8; color: var(--text2); }
.badge-error { background: #ffeef0; color: #86181d; }
.badge-read { background: #e1e4e8; color: var(--text2); }
.badge-replied { background: #dcffe4; color: #165c26; }
.badge-archived { background: #f6f8fa; color: var(--text3); }

/* Button variants */
.btn-warning { background: #e36209; color: #fff; border-color: #e36209; }
.btn-warning:hover { background: #cb5908; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c82333; }

/* Nowrap utility */
.nowrap { white-space: nowrap; }

/* Pagination */
.pagination { display: flex; gap: 4px; margin-top: 16px; justify-content: center; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px; font-size: 13px; border: 1px solid var(--border); border-radius: 4px; text-decoration: none; color: var(--text2); background: var(--surface); transition: all 0.15s; }
.page-link:hover { background: var(--bg); color: var(--text); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Status filters */
.status-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.status-filter { padding: 4px 10px; font-size: 12px; font-weight: 500; text-decoration: none; color: var(--text2); border-radius: 4px; border: 1px solid var(--border); transition: all 0.15s; }
.status-filter:hover { background: var(--bg); }
.status-filter.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Bar chart (CSS-only) */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 20px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; transition: height 0.3s; }
.bar-value { font-size: 10px; color: var(--text3); }
.bar-label { font-size: 10px; color: var(--text3); margin-top: 4px; }

/* Delta indicators */
.delta { font-size: 12px; font-weight: 500; margin-left: 6px; }
.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.detail-value { font-size: 14px; color: var(--text); }
.detail-value code { font-size: 12px; background: var(--bg); padding: 2px 6px; border-radius: 3px; }
.detail-nav { margin-bottom: 16px; }

/* Action buttons row */
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 8px; }
.activity-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-action { font-weight: 600; white-space: nowrap; font-size: 12px; }
.activity-detail { flex: 1; color: var(--text2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-time { color: var(--text3); font-size: 11px; white-space: nowrap; }

/* Audit log details column */
.audit-details { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text2); }

/* Toggle switch */
.toggle-switch { position:relative; display:inline-block; width:44px; height:24px; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider { position:absolute; cursor:pointer; top:0; left:0; right:0; bottom:0; background:var(--border); border-radius:24px; transition:0.2s; }
.toggle-slider::before { content:''; position:absolute; height:18px; width:18px; left:3px; bottom:3px; background:#fff; border-radius:50%; transition:0.2s; }
.toggle-switch input:checked + .toggle-slider { background:var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform:translateX(20px); }

/* Badge inactive */
.badge-inactive { background:#e1e4e8; color:var(--text2); }

/* Stats grid 6 col */
.stats-grid-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1024px) { .stats-grid-6 { grid-template-columns: repeat(3, 1fr); } }
.dashboard-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .dashboard-two-col { grid-template-columns: 1fr; } }

/* Pagination */
.page-ellipsis { padding: 4px 8px; color: var(--text3); }

/* Responsive */
.admin-hamburger { display: none; background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; padding: 0 16px; line-height: 1; }

@media (max-width: 768px) {
    .sidebar { position: fixed; width: 240px; height: 100vh; transform: translateX(-100%); transition: transform 0.2s ease; z-index: 100; }
    .sidebar.open { transform: translateX(0); }
    .admin-hamburger { display: block; position: fixed; top: 12px; left: 12px; z-index: 101; background: var(--text); border-radius: 6px; padding: 6px 10px; }
    .main-content { margin-left: 0; padding: 16px; padding-top: 52px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-5 { grid-template-columns: repeat(2, 1fr); }
    .settings-nav { flex-direction: column; }
    .outreach-nav { flex-wrap: wrap; }
    .scripts-grid { grid-template-columns: 1fr; }
    .mapping-grid { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: flex-start; }
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .admin-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
    .sidebar.open ~ .admin-overlay { display: block; }
}
