/* ============================================================
   CALLAXY CLIENT PORTAL — portal.css
   Uses design tokens from theme.css (:root variables).
   ============================================================ */

/* ── Auth pages ─────────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 440px;
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 36px;
}

.auth-logo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -1px;
}

.auth-tagline {
  font-size: 0.78rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.auth-sub {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-bottom: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--fg-muted);
}

.form-group input,
.form-group select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-group select option {
  background: var(--bg-card);
}

.btn-primary {
  background: var(--accent);
  color: #000;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 13px 24px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.98); }
.btn-full { width: 100%; margin-top: 4px; }

.auth-links {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.auth-links a { color: var(--accent); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* Alerts */
.alert {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 18px;
  line-height: 1.5;
}

.alert-error {
  background: var(--red-soft);
  border: 1px solid rgba(255,77,106,0.25);
  color: #ff7a8a;
}

.alert-success {
  background: var(--accent-soft);
  border: 1px solid rgba(0,212,170,0.2);
  color: var(--accent);
}

.alert-success a { color: var(--accent); }

/* ── Portal layout ──────────────────────────────────────────── */
.portal-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  overflow-x: hidden;
}

/* Sidebar */
.portal-sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.sidebar-plan-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 100px;
  text-transform: uppercase;
}

.sidebar-plan-badge.plan-pro {
  background: rgba(124, 58, 237, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(124, 58, 237, 0.25);
}

.sidebar-plan-badge.plan-starter {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.2);
}

.sidebar-nav {
  padding: 20px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: var(--bg-card);
  color: var(--fg);
}

.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-link svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 16px 24px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid rgba(0,212,170,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.75rem;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.82rem;
  padding: 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.sidebar-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

.sidebar-overlay.visible { display: block; }

/* Main content area */
.portal-main {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar (mobile only) */
.portal-topbar {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--fg);
}

.portal-content {
  padding: 40px 48px;
  flex: 1;
  max-width: 1100px;
  width: 100%;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-sub {
  font-size: 0.9rem;
  color: var(--fg-muted);
}

.plan-chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 100px;
  white-space: nowrap;
  align-self: center;
}

.plan-chip.plan-pro {
  background: rgba(124, 58, 237, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(124, 58, 237, 0.25);
}

.plan-chip.plan-starter {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.2);
}

/* ── Stats grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-green { background: rgba(0, 212, 170, 0.12); color: var(--accent); }
.stat-icon-blue  { background: rgba(96, 165, 250, 0.12); color: #60a5fa; }
.stat-icon-yellow { background: rgba(251, 191, 36, 0.12); color: #fbbf24; }
.stat-icon-purple { background: rgba(167, 139, 250, 0.12); color: #a78bfa; }

.stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--fg-muted);
  line-height: 1.3;
}

/* ── Two-column layout ──────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── Panel ──────────────────────────────────────────────────── */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
}

.panel-link {
  font-size: 0.82rem;
  color: var(--accent);
  text-decoration: none;
}

.panel-link:hover { text-decoration: underline; }

/* ── Automation list (dashboard widget) ─────────────────────── */
.automation-list { padding: 8px 0; }

.automation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

.automation-row:last-child { border-bottom: none; }

.automation-name {
  font-size: 0.88rem;
  color: var(--fg);
  font-weight: 500;
}

/* ── Status badges ──────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 100px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-on {
  background: rgba(0, 212, 170, 0.1);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.2);
}

.status-on .status-dot { background: var(--accent); }

.status-off {
  background: rgba(255,255,255,0.04);
  color: var(--fg-dim);
  border: 1px solid var(--border);
}

.status-off .status-dot { background: var(--fg-dim); }

.status-paid {
  background: rgba(0, 212, 170, 0.1);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.2);
}

.status-paid .status-dot { background: var(--accent); }

/* ── Activity list ──────────────────────────────────────────── */
.activity-list { padding: 8px 0; }

.activity-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

.activity-row:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.event-call { background: var(--accent); }
.event-text { background: #60a5fa; }
.event-review { background: #fbbf24; }
.event-appointment { background: #a78bfa; }

.activity-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.activity-desc {
  font-size: 0.87rem;
  color: var(--fg);
  line-height: 1.4;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--fg-dim);
}

/* ── Automations grid (full page) ───────────────────────────── */
.automations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.automation-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}

.automation-card:hover { border-color: rgba(0,212,170,0.25); }

.automation-card-body {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 22px 16px;
}

.automation-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.automation-details { flex: 1; }

.automation-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}

.automation-desc {
  font-size: 0.82rem;
  color: var(--fg-muted);
  line-height: 1.4;
}

.automation-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}

.toggle-btn {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: opacity 0.15s;
  border: none;
}

.toggle-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.toggle-on {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(255,77,106,0.2);
}

.toggle-off {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(0,212,170,0.2);
}

/* ── Invoice table ──────────────────────────────────────────── */
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.invoice-table th {
  text-align: left;
  padding: 14px 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.invoice-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

.invoice-table tr:last-child td { border-bottom: none; }

.invoice-id {
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.invoice-amount {
  font-weight: 600;
  color: #fff;
}

.billing-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.billing-note a { color: var(--accent); text-decoration: none; }
.billing-note svg { flex-shrink: 0; }

/* ── Support ────────────────────────────────────────────────── */
.support-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.support-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.support-card-highlight {
  border-color: rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.05);
}

.support-icon {
  color: var(--accent);
  margin-bottom: 16px;
}

.support-card h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
}

.support-card p {
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.support-contact-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.support-contact-link:hover { text-decoration: underline; }

/* FAQ */
.faq-list { padding: 8px 0; }

.faq-item {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.faq-item:last-child { border-bottom: none; }

.faq-item h4 {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
}

.faq-item p {
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.5;
}

/* ── Misc ───────────────────────────────────────────────────── */
.empty-state {
  font-size: 0.88rem;
  color: var(--fg-muted);
  text-align: center;
  padding: 28px;
}

.empty-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--fg-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }

  .portal-main {
    margin-left: 0;
  }

  .portal-topbar {
    display: flex;
  }

  .portal-content {
    padding: 24px 20px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 32px 24px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
