/* ============================================
   FMCSA Sales Portal — Premium CSS
   ============================================ */

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

:root {
  --bg: #0a0d14;
  --bg-card: #111827;
  --bg-card2: #1a2234;
  --bg-hover: #1e2d45;
  --border: rgba(255,255,255,0.08);
  --border-active: rgba(99,179,237,0.4);
  --text: #e2e8f0;
  --text-muted: #718096;
  --text-dim: #4a5568;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59,130,246,0.25);
  --success: #10b981;
  --success-bg: rgba(16,185,129,0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.15);
  --info: #06b6d4;
  --info-bg: rgba(6,182,212,0.15);
  --purple: #8b5cf6;
  --purple-bg: rgba(139,92,246,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }

/* ── Pages ── */
.page { display: none; }
.page.active { display: block; }
.hidden { display: none !important; }

/* ── AUTH ── */
.auth-bg {
  position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
}
.auth-orb {
  position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.35;
  animation: float 8s ease-in-out infinite;
}
.orb-1 { width: 600px; height: 600px; background: radial-gradient(circle, #3b82f6, transparent); top: -200px; left: -200px; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, #8b5cf6, transparent); bottom: -150px; right: -100px; animation-delay: 3s; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(circle, #06b6d4, transparent); top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: 6s; }

@keyframes float {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

.auth-container {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}

.auth-card {
  background: rgba(17,24,39,0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%; max-width: 440px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  animation: cardIn 0.5s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo { text-align: center; margin-bottom: 36px; }
.logo-icon { font-size: 48px; display: block; margin-bottom: 12px; animation: bounce 2s infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.auth-form h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.form-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: 'Inter', sans-serif; font-size: 14px;
  transition: var(--transition); outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  background: rgba(59,130,246,0.05);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group input::placeholder { color: var(--text-dim); }
.form-group select option { background: #1a2234; }
.form-group textarea { resize: vertical; min-height: 80px; }

.hint { font-size: 11px; color: var(--text-dim); font-weight: 400; }

.error-msg { color: #fc8181; font-size: 13px; margin-bottom: 12px; min-height: 16px; }
.msg-box { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; display: none; }
.msg-box.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.3); display: block; }
.msg-box.error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); display: block; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: var(--radius-sm); font-size: 14px;
  font-weight: 600; font-family: 'Inter', sans-serif; cursor: pointer;
  border: none; transition: all var(--transition); text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #2563eb, #1d4ed8); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(59,130,246,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: rgba(255,255,255,0.05); border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.auth-switch { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 20px; }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

/* ── LAYOUT ── */
#admin-page, #agent-page {
  display: flex; min-height: 100vh;
}
#admin-page.active, #agent-page.active { display: flex; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 24px; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--text); }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  text-decoration: none; transition: var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: var(--primary-glow); color: var(--primary); border: 1px solid rgba(59,130,246,0.2); }
.nav-icon { font-size: 16px; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.user-pill {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  padding: 10px; background: var(--bg-card2); border-radius: var(--radius-sm);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
  width: 100%; padding: 8px; background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted); font-size: 13px;
  cursor: pointer; transition: var(--transition); font-family: 'Inter', sans-serif;
}
.btn-logout:hover { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,0.3); }

/* ── MAIN CONTENT ── */
.main-content { flex: 1; overflow-y: auto; padding: 32px; background: var(--bg); }
.section { display: block; }
.section.hidden { display: none; }

.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-muted); font-size: 14px; }

/* ── STATS GRID ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; display: flex; align-items: center; gap: 16px;
  transition: var(--transition); cursor: default;
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.stat-card.accent-green { border-color: rgba(16,185,129,0.2); }
.stat-card.accent-green:hover { border-color: var(--success); }
.stat-card.accent-orange { border-color: rgba(245,158,11,0.2); }
.stat-card.accent-blue { border-color: rgba(6,182,212,0.2); }
.stat-icon { font-size: 28px; flex-shrink: 0; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── AGENTS OVERVIEW ── */
.agents-overview { margin-top: 8px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h3 { font-size: 16px; font-weight: 600; }
.agents-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.agent-overview-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; transition: var(--transition);
}
.agent-overview-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.agent-ov-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.agent-ov-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #8b5cf6); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0; }
.agent-ov-name { font-weight: 600; font-size: 14px; }
.agent-ov-email { font-size: 12px; color: var(--text-muted); }
.agent-ov-count { display: flex; align-items: center; justify-content: space-between; }
.count-badge { background: var(--primary-glow); color: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.agent-ov-actions { display: flex; gap: 6px; }

/* ── TABLE ── */
.table-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-toolbar {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.table-toolbar input { flex: 1; min-width: 200px; padding: 9px 16px; background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: 'Inter', sans-serif; font-size: 13px; outline: none; }
.table-toolbar input:focus { border-color: var(--primary); }
.table-toolbar select { padding: 9px 16px; background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: 'Inter', sans-serif; font-size: 13px; outline: none; cursor: pointer; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th { background: var(--bg-card2); color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: var(--transition); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table td { padding: 12px 16px; vertical-align: middle; }
.data-table td:last-child { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--danger-bg); color: var(--danger); }
.badge-not-contacted { background: rgba(113,128,150,0.2); color: #718096; }
.badge-contacted { background: var(--success-bg); color: var(--success); }
.badge-follow-up { background: var(--warning-bg); color: var(--warning); }
.badge-not-interested { background: var(--danger-bg); color: var(--danger); }
.badge-converted { background: var(--purple-bg); color: var(--purple); }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 13px; }
.pagination-info { color: var(--text-muted); }
.pagination-btns { display: flex; gap: 6px; }
.page-btn { padding: 6px 12px; background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); cursor: pointer; font-size: 12px; transition: var(--transition); font-family: 'Inter', sans-serif; }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── ASSIGN LAYOUT ── */
.assign-layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; }
.assign-form-card, .agent-assignments-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px;
}
.assign-form-card h3, .agent-assignments-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 20px; }
.assignments-list { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow-y: auto; }
.assignment-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card2); border-radius: var(--radius-sm); padding: 14px 16px;
  border: 1px solid var(--border);
}
.assignment-info { flex: 1; }
.assignment-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.assignment-meta { font-size: 12px; color: var(--text-muted); }
.empty-state { color: var(--text-muted); font-size: 13px; text-align: center; padding: 32px; }

/* ── PROGRESS ── */
.progress-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-top: 24px;
}
.progress-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.progress-bar-wrap { background: var(--bg-card2); border-radius: 20px; height: 12px; overflow: hidden; margin-bottom: 10px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #3b82f6, #8b5cf6); border-radius: 20px; transition: width 0.8s ease; }
.progress-label { font-size: 13px; color: var(--text-muted); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto;
  padding: 32px; position: relative; animation: modalIn 0.25s ease;
}
@keyframes modalIn { from{opacity:0;transform:scale(0.93)} to{opacity:1;transform:scale(1)} }
.modal-close {
  position: absolute; top: 18px; right: 18px; background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: 50%; width: 30px; height: 30px; cursor: pointer; color: var(--text-muted);
  font-size: 14px; display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.carrier-detail-header { margin-bottom: 24px; }
.carrier-detail-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.carrier-detail-header p { color: var(--text-muted); font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.detail-item label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 3px; }
.detail-item span { font-size: 14px; font-weight: 500; }
.detail-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── LOADING ── */
.spinner {
  display: flex; justify-content: center; align-items: center; padding: 60px;
}
.spinner::after {
  content: ''; width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { text-align: center; color: var(--text-muted); padding: 40px; font-size: 14px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .assign-layout { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .sidebar { display: none; }
  .main-content { padding: 20px; }
}
