/* ─────────────────────────────────────────────────────
   Leadology — app.css
   Primary brand: #012488 (navy blue)
   CTA / accent:  #EC7961 (coral)
   Dark text:     white
───────────────────────────────────────────────────── */

:root {
  /* Brand */
  --primary:       #012488;
  --primary-dark:  #011a66;
  --primary-light: #e8ecf8;
  --cta:           #EC7961;
  --cta-dark:      #d4614c;
  --cta-light:     #fdecea;

  /* Sidebar */
  --sidebar-bg:          #012488;
  --sidebar-hover:       #011a66;
  --sidebar-active-bg:   #EC7961;
  --sidebar-active-text: #ffffff;
  --sidebar-text:        rgba(255,255,255,.6);
  --sidebar-width:       224px;
  --topbar-h:            56px;

  /* App layout */
  --bg:       #f4f5fa;
  --card-bg:  #ffffff;
  --text:     #1a1a2e;
  --text-muted: #6b7280;
  --border:   #e5e7eb;
  --radius:   10px;
  --shadow:   0 1px 4px rgba(0,0,0,.08);

  /* Status palette */
  --s-created:    #9ca3af;
  --s-started:    #3b82f6;
  --s-completed:  #10b981;
  --s-failed:     #ef4444;
  --s-paused:     #f59e0b;
  --s-dispatched: #8b5cf6;
  --s-queued:     #06b6d4;
}

/* ─── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }

/* ─── HTMX indicator ─────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ─────────────────────────────────────────────────────
   PUBLIC LAYOUT  (landing + auth)
───────────────────────────────────────────────────── */
.pub-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; height: var(--topbar-h);
  background: var(--primary); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.pub-nav-links { display: flex; gap: 1rem; align-items: center; }
.pub-nav-links a { color: rgba(255,255,255,.75); font-size: .9rem; transition: color .15s; }
.pub-nav-links a:hover { color: #fff; }

/* ─── Hero ───────────────────────────────────────── */
.hero {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 6rem 2rem 4rem;
  background: linear-gradient(160deg, #011a66 0%, #012488 50%, #023090 100%);
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; color: #fff; margin: 0 0 1rem; line-height: 1.15; }
.hero h1 span { color: var(--cta); }
.hero p { font-size: 1.15rem; color: rgba(255,255,255,.7); max-width: 520px; margin: 0 auto 2.5rem; line-height: 1.6; }

/* ─── Buttons ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.2rem; border-radius: 8px; font-size: .9rem; font-weight: 500; cursor: pointer; transition: all .15s; border: none; }
.btn-primary  { background: var(--cta);    color: #fff; }
.btn-primary:hover  { background: var(--cta-dark); }
.btn-secondary { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.2); }
.btn-secondary:hover { background: rgba(255,255,255,.18); }
.btn-sm   { padding: .35rem .8rem; font-size: .82rem; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost  { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover  { background: #f3f4f6; color: var(--text); }
.btn-outline-primary { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* ─── Pricing section ─────────────────────────────── */
.pricing-section { padding: 5rem 2rem; background: #f8f9fd; }
.pricing-section h2 { text-align: center; font-size: 1.8rem; font-weight: 700; margin-bottom: .5rem; color: var(--primary); }
.pricing-section .sub { text-align: center; color: var(--text-muted); margin-bottom: 3.5rem; }

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
  padding-top: 20px;    /* room above the absolutely-positioned "Most popular" badge */
  align-items: stretch; /* equal card heights; flex:1 on p pushes buttons to bottom */
}

.pricing-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s, border-color .2s, transform .2s;
  cursor: pointer;
  position: relative;
}
.pricing-card:hover {
  box-shadow: 0 8px 32px rgba(1,36,136,.12);
  border-color: var(--primary);
  transform: translateY(-3px);
}
.pricing-card.featured {
  border-color: var(--cta);
  box-shadow: 0 4px 24px rgba(236,121,97,.2);
}
.pricing-card.featured:hover {
  box-shadow: 0 10px 36px rgba(236,121,97,.3);
  border-color: var(--cta-dark);
  transform: translateY(-5px);
}

/* Badge sits on top of the featured card border — position:absolute so it
   does NOT push card content down. The grid padding-top:20px gives it room. */
.pricing-badge {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cta);
  color: #fff;
  padding: .25rem .85rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .03em;
}

.pricing-card h3 { font-size: 1.25rem; font-weight: 700; margin: 0 0 .25rem; color: var(--primary); }
.pricing-card .price { font-size: 2.6rem; font-weight: 800; color: var(--text); margin: .75rem 0; }
.pricing-card .price span { font-size: 1rem; font-weight: 400; color: var(--text-muted); }
.pricing-card .calls-count { font-size: 1rem; color: var(--cta); font-weight: 700; margin-bottom: 1rem; }
.pricing-card p { color: var(--text-muted); font-size: .9rem; flex: 1; margin-bottom: 1.5rem; line-height: 1.5; }
.pricing-card .btn { width: 100%; justify-content: center; }

/* ─────────────────────────────────────────────────────
   AUTH LAYOUT
───────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 1rem; }
.auth-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo img { height: 44px; }
.auth-card h2 { font-size: 1.2rem; font-weight: 600; margin: 0 0 .25rem; text-align: center; color: var(--primary); }
.auth-card .sub { text-align: center; color: var(--text-muted); font-size: .87rem; margin-bottom: 1.75rem; }

/* ─── Forms ──────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .83rem; font-weight: 500; margin-bottom: .35rem; color: var(--text-muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem; background: #fff; color: var(--text); transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.alert { padding: .65rem 1rem; border-radius: 8px; font-size: .87rem; margin-bottom: 1rem; }
.alert-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.alert-info    { background: var(--primary-light); color: var(--primary); border: 1px solid #c3cbe3; }
.alert-warning { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }

/* ─────────────────────────────────────────────────────
   APP LAYOUT  (sidebar + content)
───────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--sidebar-bg); display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; overflow-y: auto;
}
.sidebar-logo { padding: 1.25rem 1.25rem .75rem; }
.sidebar-logo a { display: flex; align-items: center; }
.sidebar-logo img { height: 32px; }

.sidebar-nav { padding: .5rem .75rem; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem; border-radius: 8px; margin-bottom: 2px;
  font-size: .88rem; color: var(--sidebar-text); font-weight: 500; transition: all .15s;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: rgba(255,255,255,.9); }
.sidebar-nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-nav .nav-section {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: rgba(255,255,255,.3); padding: .75rem .75rem .25rem; font-weight: 600;
}

.sidebar-footer { padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: .6rem; }
.sidebar-user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--cta);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user-name { font-size: .82rem; color: rgba(255,255,255,.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-content { margin-left: var(--sidebar-width); flex: 1; min-width: 0; }
.app-topbar {
  height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.75rem; background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.app-topbar h1 { font-size: 1rem; font-weight: 600; margin: 0; color: var(--primary); }
.page-body { padding: 1.75rem; }

/* ─── Credits badge ──────────────────────────────── */
.credits-widget { display: flex; align-items: center; gap: .5rem; background: var(--cta-light); border-radius: 20px; padding: .3rem .9rem; }
.credits-widget .number { font-size: 1rem; font-weight: 700; color: var(--cta-dark); }
.credits-widget .label  { font-size: .78rem; color: var(--cta-dark); font-weight: 500; }

/* ─── Cards ──────────────────────────────────────── */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.card-title  { font-size: .95rem; font-weight: 600; margin: 0; color: var(--primary); }

/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card .stat-value.green  { color: #10b981; }
.stat-card .stat-value.red    { color: #ef4444; }
.stat-card .stat-value.blue   { color: #3b82f6; }
.stat-card .stat-value.purple { color: var(--primary); }

/* Campaign grid */
.campaign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.campaign-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: box-shadow .2s; }
.campaign-card:hover { box-shadow: 0 4px 16px rgba(1,36,136,.1); }
.campaign-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .75rem; }
.campaign-card-title  { font-size: .95rem; font-weight: 600; margin: 0; color: var(--primary); }
.campaign-card-date   { font-size: .78rem; color: var(--text-muted); margin: .25rem 0 0; }
.campaign-card-counts { display: flex; gap: .5rem; flex-wrap: wrap; margin: .75rem 0; }
.campaign-card-counts span { font-size: .78rem; padding: .15rem .5rem; border-radius: 4px; }
.count-total { background: #f3f4f6; color: #6b7280; }
.count-done  { background: #d1fae5; color: #065f46; }
.count-fail  { background: #fee2e2; color: #991b1b; }
.count-pend  { background: #dbeafe; color: #1e40af; }
.campaign-card-footer { margin-top: auto; padding-top: .75rem; display: flex; justify-content: space-between; align-items: center; }

/* ─── Status badges ──────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-created    { background: #f3f4f6; color: var(--s-created); }
.badge-started    { background: #eff6ff; color: var(--s-started); }
.badge-completed  { background: #ecfdf5; color: var(--s-completed); }
.badge-failed     { background: #fef2f2; color: var(--s-failed); }
.badge-paused     { background: #fffbeb; color: var(--s-paused); }
.badge-dispatched { background: #f5f3ff; color: var(--s-dispatched); }
.badge-queued     { background: #ecfeff; color: var(--s-queued); }

/* ─── Table ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th { background: var(--primary-light); padding: .65rem 1rem; text-align: left; font-size: .75rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
tbody td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
td.muted { color: var(--text-muted); font-size: .82rem; }

/* ─── Search filters ─────────────────────────────── */
.search-filters { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.search-filters .filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; }
.search-filters .filter-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; flex-wrap: wrap; gap: .5rem; }

/* Toggle */
.toggle-wrap { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-muted); cursor: pointer; }
.toggle { position: relative; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; border-radius: 20px; background: #d1d5db; transition: background .2s; }
.toggle-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; justify-content: center; }
.pagination a, .pagination span { padding: .35rem .7rem; border-radius: 6px; font-size: .85rem; border: 1px solid var(--border); color: var(--text); }
.pagination a:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Modal ──────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--card-bg); border-radius: 14px; padding: 2rem; width: 100%; max-width: 540px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; color: var(--primary); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; padding: .25rem; border-radius: 6px; }
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-footer { margin-top: 1.5rem; display: flex; gap: .75rem; justify-content: flex-end; }

/* ─── Info tooltip ───────────────────────────────── */
.info-btn { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-size: .7rem; font-weight: 700; cursor: help; border: 1px solid rgba(1,36,136,.2); flex-shrink: 0; transition: background .15s; }
.info-btn:hover { background: #c3cbe3; }
.info-wrap { position: relative; display: inline-flex; }
.info-tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; font-size: .78rem; line-height: 1.5; padding: .6rem .85rem; border-radius: 8px; white-space: normal; width: 260px; z-index: 300; box-shadow: 0 4px 16px rgba(0,0,0,.3); pointer-events: none; }
.info-tip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--primary); }
.info-wrap:hover .info-tip { display: block; }

/* ─── OTP input ──────────────────────────────────── */
.otp-inputs { display: flex; gap: .75rem; justify-content: center; margin: 1.5rem 0; }
.otp-inputs input { width: 48px; height: 56px; text-align: center; font-size: 1.5rem; font-weight: 700; border: 2px solid var(--border); border-radius: 10px; color: var(--primary); transition: border-color .15s; }
.otp-inputs input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ─── Spinner ────────────────────────────────────── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--cta); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Utilities ──────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-sm       { gap: .5rem; }
.gap-md       { gap: 1rem; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.text-muted   { color: var(--text-muted); font-size: .85rem; }
.text-right   { text-align: right; }
.w-full       { width: 100%; }
.empty-state  { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state p { margin: .5rem 0 1.25rem; }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .app-content { margin-left: 0; }
  .field-row { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
}
