/* ─── Google Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:           #f4f6fb;
  --surface:      #ffffff;
  --sidebar-bg:   #1a2340;
  --sidebar-text: #c8d0e7;
  --sidebar-hover:#253058;
  --sidebar-active:#2e3d6e;
  --primary:      #2e3d6e;
  --primary-light:#3d52a0;
  --accent:       #4f6ef7;
  --text:         #1a2340;
  --text-muted:   #6b7a99;
  --border:       #e2e8f0;
  --input-bg:     #f8fafc;
  --success:      #059669;
  --success-bg:   #ecfdf5;
  --danger:       #dc2626;
  --danger-bg:    #fef2f2;
  --warning:      #d97706;
  --warning-bg:   #fffbeb;
  --info:         #2563eb;
  --info-bg:      #eff6ff;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

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

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}
.sidebar-logo p {
  font-size: .75rem;
  color: var(--sidebar-text);
  margin-top: 2px;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-section { padding: 8px 16px 4px; font-size: .68rem; font-weight: 600; color: rgba(200,208,231,.45); text-transform: uppercase; letter-spacing: .08em; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--accent); }
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: .8rem; font-weight: 600; color: #fff; truncate; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .7rem; color: var(--sidebar-text); }
.btn-logout {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 7px 10px;
  background: rgba(255,255,255,.06);
  border: none; border-radius: var(--radius);
  color: var(--sidebar-text); font-size: .8rem; cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ─── Main Content ──────────────────────────────────────────────────────────── */
.main-content { margin-left: 240px; flex: 1; min-height: 100vh; }
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.page-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.page-header p { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.page-body { padding: 28px 32px; }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-header { padding: 18px 20px 0; }
.card-header h3 { font-size: .95rem; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* ─── Stat Cards ────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; align-items: flex-start; justify-content: space-between;
  box-shadow: var(--shadow);
}
.stat-card-info p { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-card-info h3 { font-size: 1.9rem; font-weight: 700; color: var(--text); margin-top: 4px; }
.stat-card-info small { font-size: .72rem; color: var(--text-muted); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #ecfdf5; color: #059669; }
.stat-icon.violet { background: #f5f3ff; color: #7c3aed; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .85rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all .15s; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: #3d5ce6; border-color: #3d5ce6; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #047857; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-lg { padding: 11px 22px; font-size: .95rem; }
.btn-icon { padding: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Status Buttons (Call Record Form) ─────────────────────────────────────── */
.status-btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
.status-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: .82rem; font-weight: 500;
  cursor: pointer; border: 1.5px solid;
  transition: all .15s;
  background: #fff;
}
.status-btn.agreed        { color: var(--success); border-color: #a7f3d0; }
.status-btn.agreed.active { background: var(--success); color: #fff; border-color: var(--success); }
.status-btn.not_interested        { color: var(--danger); border-color: #fecaca; }
.status-btn.not_interested.active { background: var(--danger); color: #fff; border-color: var(--danger); }
.status-btn.pending        { color: var(--warning); border-color: #fde68a; }
.status-btn.pending.active { background: var(--warning); color: #fff; border-color: var(--warning); }
.status-btn.answered        { color: var(--success); border-color: #a7f3d0; }
.status-btn.answered.active { background: var(--success); color: #fff; border-color: var(--success); }
.status-btn.busy        { color: #ea580c; border-color: #fed7aa; }
.status-btn.busy.active { background: #ea580c; color: #fff; border-color: #ea580c; }
.status-btn.not_answered        { color: var(--text-muted); border-color: var(--border); }
.status-btn.not_answered.active { background: #64748b; color: #fff; border-color: #64748b; }
.status-btn.callback        { color: var(--info); border-color: #bfdbfe; }
.status-btn.callback.active { background: var(--info); color: #fff; border-color: var(--info); }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem; font-weight: 600;
  border: 1px solid;
}
.badge-agreed       { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.badge-not_interested { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.badge-pending      { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.badge-answered     { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.badge-busy         { background: #fff7ed; color: #ea580c; border-color: #fed7aa; }
.badge-not_answered { background: #f8fafc; color: #64748b; border-color: var(--border); }
.badge-callback     { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }
.badge-admin        { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
.badge-user         { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }
.badge-active       { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.badge-inactive     { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.form-control {
  display: block; width: 100%;
  padding: 9px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,110,247,.12); }
.form-control::placeholder { color: #b0bac9; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-span-2 { grid-column: span 2; }

/* ─── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .72rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: .875rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }

/* ─── Customer Row Card ─────────────────────────────────────────────────────── */
.customer-list { display: flex; flex-direction: column; gap: 10px; }
.customer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
}
.customer-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); text-decoration: none; }
.customer-avatar {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.customer-info { flex: 1; min-width: 0; }
.customer-name { font-weight: 600; font-size: .9rem; color: var(--text); }
.customer-meta { display: flex; align-items: center; gap: 14px; margin-top: 3px; flex-wrap: wrap; }
.customer-meta span { font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.customer-right { text-align: right; flex-shrink: 0; }
.customer-amount { font-size: .95rem; font-weight: 700; color: var(--text); }
.customer-rate { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Info Card (Customer Detail) ───────────────────────────────────────────── */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.info-field label { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.info-field p { font-size: .875rem; font-weight: 500; color: var(--text); }
.info-field p.empty { color: #b0bac9; }

/* ─── Call Record ───────────────────────────────────────────────────────────── */
.call-record {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.call-record-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.call-record-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.call-record-date { font-size: .75rem; color: var(--text-muted); }
.call-record-notes { margin-top: 8px; padding: 8px 10px; background: #f8fafc; border-radius: 6px; font-size: .82rem; color: var(--text); }
.call-record-next { margin-top: 6px; font-size: .75rem; color: var(--info); display: flex; align-items: center; gap: 4px; }

/* ─── Search Bar ────────────────────────────────────────────────────────────── */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; pointer-events: none; }

/* ─── Toolbar ───────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(10,15,30,.45);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(-8px); } to { opacity: 1; transform: none; } }
.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 12px 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ─── Alert ─────────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: .85rem; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 8px; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #bfdbfe; }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .85rem;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s ease;
  min-width: 240px; max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ─── Login Page ────────────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a2340 0%, #2e3d6e 50%, #1a2340 100%); }
.login-box { background: var(--surface); border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { width: 56px; height: 56px; background: linear-gradient(135deg, var(--primary-light), var(--accent)); border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.login-logo p { font-size: .82rem; color: var(--text-muted); margin-top: 4px; }
.login-box .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: .9rem; }

/* ─── Transfer Page ─────────────────────────────────────────────────────────── */
.transfer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.user-select-list { display: flex; flex-direction: column; gap: 8px; }
.user-select-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.user-select-item:hover { border-color: var(--accent); background: #fafbff; }
.user-select-item.selected-from { border-color: var(--primary); background: #f0f3ff; }
.user-select-item.selected-to { border-color: var(--success); background: #f0fdf4; }
.user-select-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-select-name { font-size: .85rem; font-weight: 500; }
.user-select-role { font-size: .72rem; color: var(--text-muted); }

/* ─── Checkbox List ─────────────────────────────────────────────────────────── */
.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.checkbox-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.checkbox-item:hover { border-color: var(--accent); background: #fafbff; }
.checkbox-item.checked { border-color: var(--primary); background: #f0f3ff; }
.checkbox-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ─── Empty State ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state svg { width: 48px; height: 48px; color: #cbd5e1; margin: 0 auto 12px; }
.empty-state p { color: var(--text-muted); font-size: .9rem; }

/* ─── Back Link ─────────────────────────────────────────────────────────────── */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-muted); margin-bottom: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ─── Divider ───────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ─── Utilities ─────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .72rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; height: auto; }
  .main-content { margin-left: 0; }
  .app-layout { flex-direction: column; }
  .page-body { padding: 16px; }
  .form-grid, .form-grid-3, .transfer-grid { grid-template-columns: 1fr; }
  .form-span-2 { grid-column: span 1; }
}
