/* ══════════════════════════════════════════════════════════════════════════
   portal.css — Customer portal + auth pages
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Reset / base (portal-scoped overrides) ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: #0A0A0A;
  color: #e5e5e5;
  min-height: 100vh;
}

/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:        #0A0A0A;
  --surface:   #111111;
  --surface-2: #171717;
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.12);
  --accent:    #25D366;
  --accent-dim:#1aad52;
  --text-1:    #f0f0f0;
  --text-2:    #a0a0a0;
  --text-3:    #666666;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --blue:      #3b82f6;
  --radius:    12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
}

/* ── Portal layout ──────────────────────────────────────────────────────── */
.portal-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Hidden by default — only shown as overlay on mobile */
.sidebar-overlay { display: none; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
}

.sidebar-logo-text span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-1);
}

.sidebar-link.active {
  background: rgba(37,211,102,0.12);
  color: var(--accent);
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-link.active svg { opacity: 1; }

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.sidebar-logout:hover {
  background: rgba(239,68,68,0.1);
  color: var(--red);
}

.sidebar-logout svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Hamburger toggle (mobile only) ─────────────────────────────────────── */
.portal-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.portal-ham {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}

.portal-ham span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-1);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── Main content area ──────────────────────────────────────────────────── */
.portal-main {
  padding: 36px 40px;
  max-width: 900px;
}

/* ── Welcome bar ────────────────────────────────────────────────────────── */
.welcome-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.welcome-bar h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin-right: 4px;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-green  { background: rgba(37,211,102,0.15); color: #25D366; }
.badge-amber  { background: rgba(245,158,11,0.15);  color: #f59e0b; }
.badge-red    { background: rgba(239,68,68,0.15);   color: #ef4444; }
.badge-blue   { background: rgba(59,130,246,0.15);  color: #3b82f6; }
.badge-gray   { background: rgba(255,255,255,0.08); color: var(--text-2); }

/* ── Announcement banner ─────────────────────────────────────────────────── */
.announcement-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 14px;
  color: #93c5fd;
}

.announcement-banner .ann-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.announcement-banner .ann-text { flex: 1; line-height: 1.5; }
.announcement-dismiss {
  background: none;
  border: none;
  color: #93c5fd;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  opacity: 0.7;
  flex-shrink: 0;
}
.announcement-dismiss:hover { opacity: 1; }

/* ── Portal cards ───────────────────────────────────────────────────────── */
.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.portal-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-card-title .card-icon { font-size: 18px; }

/* ── Licence cards ──────────────────────────────────────────────────────── */
/* Each licence the customer owns gets its own card inside #licences-container */
.licence-card {
  border-top: 2px solid rgba(37,211,102,0.25);
}

.licence-meta {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-2);
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.licence-meta span strong {
  color: var(--text-1);
  font-weight: 600;
}

/* ── Activation states ──────────────────────────────────────────────────── */

/* State 1: pending_machine_id */
.state-pending-machine-id .state-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 8px;
}

.state-pending-machine-id .state-instruction {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 20px;
  line-height: 1.6;
}

.state-pending-machine-id .state-help {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 10px;
}

/* State 2: pending_activation */
.state-pending-activation {
  text-align: center;
  padding: 8px 0;
}

.state-pending-activation .state-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 12px;
}

.state-pending-activation .state-machine-id {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 16px;
}

.state-pending-activation .state-machine-id code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--text-1);
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

.state-pending-activation .state-message {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 20px;
}

.state-pending-activation .state-timestamp {
  font-size: 12px;
  color: var(--text-3);
}

/* Progress dots animation */
.progress-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 20px 0;
}

.progress-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-pulse 1.4s ease-in-out infinite;
}

.progress-dots span:nth-child(2) { animation-delay: 0.2s; }
.progress-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}

/* State 3: active */
.state-active .state-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.activation-code-box {
  background: rgba(37,211,102,0.07);
  border: 1.5px solid rgba(37,211,102,0.3);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.activation-code-value {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  word-break: break-all;
}

.copy-btn {
  background: rgba(37,211,102,0.15);
  border: 1px solid rgba(37,211,102,0.3);
  color: var(--accent);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.copy-btn:hover { background: rgba(37,211,102,0.25); }
.copy-btn.copied { background: rgba(37,211,102,0.3); }

.state-active .state-activated-date {
  font-size: 13px;
  color: var(--text-3);
}

/* State 4: expired */
.state-expired {
  border-color: rgba(245,158,11,0.3);
  background: rgba(245,158,11,0.04);
}

.state-expired .state-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.state-expired .state-message {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* State 5: suspended */
.state-suspended {
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.04);
}

.state-suspended .state-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.state-suspended .state-message {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ── Subscription details grid ───────────────────────────────────────────── */
.sub-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.sub-detail-item label {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.sub-detail-item .sub-value {
  font-size: 14px;
  color: var(--text-1);
  font-weight: 500;
}

/* ── Download section ────────────────────────────────────────────────────── */
.download-section { }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #000;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
  margin-bottom: 14px;
}

.btn-download:hover { background: var(--accent-dim); }

.install-toggle {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  padding: 0;
  transition: color 0.15s;
}

.install-toggle:hover { color: var(--text-2); }

.install-steps {
  display: none;
  margin-top: 14px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.install-steps.open { display: block; }

.install-steps ol {
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 2;
}

.install-steps ol li { padding-left: 4px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-1);
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-3); }
.form-input.error { border-color: var(--red); }

textarea.form-input { resize: vertical; min-height: 100px; }

.form-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 5px;
  display: block;
}

.form-help {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 5px;
  display: block;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-secondary:hover { background: rgba(255,255,255,0.05); color: var(--text-1); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-danger:hover { background: rgba(239,68,68,0.08); }

/* ── Inline feedback messages ───────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.alert.visible { display: block; }

.alert-success {
  background: rgba(37,211,102,0.1);
  border: 1px solid rgba(37,211,102,0.25);
  color: #6ee7a0;
}

.alert-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
}

.alert-info {
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.25);
  color: #93c5fd;
}

/* ── Support / complaints ───────────────────────────────────────────────── */
.complaint-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.complaint-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.complaint-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.complaint-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}

.complaint-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}

.complaint-message {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 10px;
}

.complaint-reply {
  background: rgba(37,211,102,0.06);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin-top: 10px;
}

.complaint-reply .reply-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.complaint-reply .reply-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

.no-complaints,
.no-data {
  text-align: center;
  padding: 32px;
  color: var(--text-3);
  font-size: 14px;
}

/* ── Payment history ────────────────────────────────────────────────────── */
.payment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

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

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

.payment-plan {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}

.payment-date {
  font-size: 12px;
  color: var(--text-3);
}

.payment-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* ── Settings page ──────────────────────────────────────────────────────── */
.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ── Auth layout (login, forgot, reset) ─────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  text-decoration: none;
}

.auth-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.auth-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
}

.auth-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 6px;
}

.auth-subtext {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.5;
}

.auth-footer-links {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  font-size: 13px;
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
}

.auth-link:hover { opacity: 0.8; }

.auth-link-muted {
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.15s;
}

.auth-link-muted:hover { color: var(--text-2); }

/* ── Payment success banner ─────────────────────────────────────────────── */
.payment-success {
  display: none;
  align-items: center;
  gap: 12px;
  background: rgba(37,211,102,0.1);
  border: 1px solid rgba(37,211,102,0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 14px;
  color: #6ee7a0;
}

.payment-success.visible { display: flex; }
.payment-success .success-icon { font-size: 20px; flex-shrink: 0; }

/* ── Page title ─────────────────────────────────────────────────────────── */
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.5;
}

/* ── Loading spinner ─────────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100%;
    width: 260px;
    z-index: 200;
    transition: left 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .sidebar.open { left: 0; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 199;
  }

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

  .portal-mobile-header {
    display: flex;
    grid-column: 1;
  }

  .portal-main {
    padding: 24px 20px;
    grid-column: 1;
  }

  .sub-details-grid {
    grid-template-columns: 1fr;
  }

  .activation-code-box {
    flex-direction: column;
    text-align: center;
  }

  .copy-btn { width: 100%; justify-content: center; }

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