/* ============================================================
   X Network Customer Portal — CSS
   Design language matching xnetwork.net
   ============================================================ */

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

:root {
  --blue:       #0c2b6f;
  --blue-mid:   #122e7a;
  --blue-dark:  #0b1b47;
  --blue-card:  #0f1c3f;
  --blue-deep:  #081331;
  --green:      #00a74f;
  --amber:      #e8a000;
  --red:        #d63031;
  --text:       #0a0a0a;
  --text-muted: #5f6b76;
  --border:     #dfe6ef;
  --bg-light:   #f6f7f8;
  --bg-faint:   #fafbfc;
  --white:      #ffffff;
  --radius:     8px;
  --shadow-sm:  0 2px 8px rgba(12,43,111,0.08);
  --shadow-md:  0 8px 24px rgba(12,43,111,0.12);
  --shadow-lg:  0 16px 40px rgba(12,43,111,0.18);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-faint);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: 'Archivo Black', sans-serif; line-height: 1.15; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, #fff 0%, #f8faff 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(12,43,111,0.06);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo { height: 48px; display: block; }
.logo-link { display: flex; align-items: center; }

.header-rule {
  height: 4px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--blue-mid) 50%, var(--green) 100%);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.25s;
  border: 2px solid var(--blue);
  background: var(--white);
  color: var(--blue);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn:hover {
  background: var(--blue);
  color: var(--white);
  text-decoration: none;
}

.btn.dark {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

.btn.dark:hover {
  background: var(--blue-mid);
  border-color: var(--blue-mid);
}

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

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


/* ── Container ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Views ── */
.view { flex: 1; }

/* ── Login ── */
#view-login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background:
    linear-gradient(rgba(11,27,71,0.60), rgba(12,43,111,0.70)),
    url('/shaw.jpg') center center / cover no-repeat;
}

.auth-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  font-size: 1.75rem;
  color: var(--blue-dark);
  margin-bottom: 6px;
}

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

.field {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.field input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  color: var(--text);
  background: var(--white);
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(12,43,111,0.1);
}

.field input::placeholder { color: #aab2bc; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Alerts ── */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.alert-error {
  background: #fff0f0;
  border: 1px solid #ffc5c5;
  color: #c0392b;
}

.alert-success {
  background: #f0fff6;
  border: 1px solid #a3e6c0;
  color: #1e7a40;
}

/* ── Dashboard Hero ── */
.dashboard-hero {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
  padding: 48px 0 40px;
  color: var(--white);
  margin-bottom: 32px;
}

.welcome-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.65);
  margin-bottom: 6px;
}

.dashboard-hero h1 {
  font-size: 2.2rem;
  color: var(--white);
  margin-bottom: 6px;
}

.hero-sub {
  color: rgba(255,255,255,0.7);
  font-size: 0.95rem;
}

/* ── Stat Cards ── */
.top-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: rgba(12,43,111,0.08);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.green { background: rgba(0,167,79,0.1); color: var(--green); }
.stat-icon.amber { background: rgba(232,160,0,0.12); color: var(--amber); }
.stat-icon.red   { background: rgba(214,48,49,0.1); color: var(--red); }

.stat-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 1.25rem;
  font-family: 'Archivo Black', sans-serif;
  color: var(--blue-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Dashboard Grid ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  margin-bottom: 48px;
}

/* ── Panel ── */
.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.panel-header h2 {
  font-size: 1rem;
  color: var(--blue-dark);
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(12,43,111,0.08);
  color: var(--blue);
}

.panel-loading,
.panel-empty {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.panel-empty svg { opacity: 0.35; }

.panel-empty p { text-align: center; line-height: 1.7; }
.panel-empty strong { color: var(--text); }

/* ── Spinner ── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Table ── */
#invoice-table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  background: var(--bg-light);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.data-table tbody tr:hover { background: var(--bg-faint); }

/* Invoice status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}

.status-paid    { background: rgba(0,167,79,0.12); color: #0d7a3a; }
.status-unpaid  { background: rgba(232,160,0,0.15); color: #9a6600; }
.status-overdue { background: rgba(214,48,49,0.1); color: #b0291f; }
.status-draft   { background: rgba(95,107,118,0.12); color: var(--text-muted); }
.status-partial { background: rgba(12,43,111,0.1); color: var(--blue); }

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

.view-link {
  color: var(--blue);
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
}

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

/* ── Side Panel ── */
.side-panel { display: flex; flex-direction: column; }

/* ── Quick Links ── */
.quick-links { display: flex; flex-direction: column; }

.quick-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s;
  text-decoration: none;
}

.quick-link:last-child { border-bottom: none; }

.quick-link:hover {
  background: var(--bg-light);
  text-decoration: none;
}

.ql-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: rgba(12,43,111,0.08);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ql-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ql-title { font-size: 0.88rem; font-weight: 700; color: var(--blue-dark); }
.ql-sub   { font-size: 0.78rem; color: var(--text-muted); }
.ql-arrow { color: var(--text-muted); flex-shrink: 0; }

/* ── Info Rows ── */
.info-rows { padding: 4px 0; }

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

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

.info-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.info-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--blue-dark);
  text-align: right;
  word-break: break-all;
}

/* ── Account Selector ── */
#account-selector { margin-bottom: 24px; }

.acct-selector-panel { overflow: visible; }

.acct-selector-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  background: var(--border);
}

.acct-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--white);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  position: relative;
}

.acct-item:hover { background: var(--bg-light); }

.acct-item.checked { background: rgba(12,43,111,0.03); }

.acct-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}

.acct-item-check {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 2px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  color: transparent;
}

.acct-item.checked .acct-item-check {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

.acct-item input:disabled ~ .acct-item-check {
  opacity: 0.5;
  cursor: not-allowed;
}

.acct-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.acct-item-num {
  font-family: 'Archivo Black', sans-serif;
  font-size: 0.9rem;
  color: var(--blue-dark);
}

.acct-item-addr {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Service alert banner ── */
#service-banner {
  padding: 0 0 4px;
}

.service-banner-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin: 16px 0 4px;
}

.banner-suspended .service-banner-inner {
  background: rgba(214,48,49,0.08);
  border: 1.5px solid rgba(214,48,49,0.3);
  color: #9b1c1c;
}

.banner-collections .service-banner-inner {
  background: rgba(232,160,0,0.1);
  border: 1.5px solid rgba(232,160,0,0.4);
  color: #7a4f00;
}

.banner-suspended svg,
.banner-collections svg { flex-shrink: 0; margin-top: 2px; }

.service-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.service-banner-text strong { font-size: 0.95rem; }
.service-banner-text span   { font-size: 0.88rem; opacity: 0.85; }

.service-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

.banner-btn {
  font-size: 0.8rem;
  padding: 7px 12px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.banner-suspended .banner-btn {
  border-color: rgba(214,48,49,0.5);
  color: #9b1c1c;
  background: rgba(214,48,49,0.08);
}

.banner-suspended .banner-btn:hover {
  background: rgba(214,48,49,0.18);
  color: #7f1d1d;
}

.banner-collections .banner-btn {
  border-color: rgba(232,160,0,0.5);
  color: #7a4f00;
  background: rgba(232,160,0,0.1);
}

.banner-collections .banner-btn:hover {
  background: rgba(232,160,0,0.22);
}

/* ── Footer ── */
#site-footer {
  background: var(--blue);
  color: rgba(255,255,255,0.75);
  padding: 18px 0;
  margin-top: auto;
  /* Safe area for iPhone home bar */
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

#site-footer a { color: rgba(255,255,255,0.85); }
#site-footer a:hover { color: var(--white); text-decoration: underline; }

/* ── Viewing accounts label ── */
.invoice-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.viewing-label {
  font-size: 0.78rem;
  color: var(--blue);
  font-weight: 700;
  background: rgba(12,43,111,0.07);
  padding: 2px 8px;
  border-radius: 999px;
  width: fit-content;
}

/* ── Bottom nav (mobile only) ── */
#mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 200;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(12,43,111,0.10);
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

.mobile-nav-btn svg { transition: color 0.15s; }

.mobile-nav-btn.active {
  color: var(--blue);
}

.mobile-nav-btn.active svg {
  color: var(--blue);
}

/* ── Support drawer ── */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11,27,71,0.45);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.25s;
}

.drawer-backdrop.open {
  display: block;
  opacity: 1;
}

.support-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 400;
  background: var(--white);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px rgba(12,43,111,0.18);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.support-drawer.open {
  transform: translateY(0);
}

.drawer-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title {
  font-family: 'Archivo Black', sans-serif;
  font-size: 1rem;
  color: var(--blue-dark);
}

.drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-close:hover { background: var(--bg-light); color: var(--text); }

.drawer-body {
  overflow-y: auto;
  padding: 16px 0 8px;
  flex: 1;
}

.drawer-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 20px 8px;
}

.drawer-links { display: flex; flex-direction: column; }

.drawer-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}

.drawer-link:last-child { border-bottom: none; }
.drawer-link:hover { background: var(--bg-light); }

.drawer-info-rows { padding: 0; }
.drawer-info-rows .info-row { padding: 12px 20px; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .top-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-panel { order: -1; }
}

@media (max-width: 768px) {
  #site-header { padding-top: env(safe-area-inset-top); }
  .header-inner { height: 60px; padding: 0 16px; }
  .logo { height: 38px; }
  /* Hide sign out from header on mobile — it's in the drawer */
  #btn-logout { display: none !important; }

  /* Hero */
  .dashboard-hero { padding: 24px 0 20px; }
  .dashboard-hero h1 { font-size: 1.4rem; }
  .hero-sub { font-size: 0.85rem; }

  /* Stats */
  .top-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; }
  .stat-value { font-size: 0.95rem; }

  /* Main grid: single column, hide side panel (it's in the drawer) */
  .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
  .side-panel { display: none; }

  /* Auth card */
  .auth-card { padding: 28px 18px; margin: 0 4px; }

  .container { padding: 0 14px; }
  /* Extra bottom padding for bottom nav */
  .dashboard-body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* Service banner */
  .service-banner-inner { flex-wrap: wrap; gap: 10px; }
  .service-banner-actions { width: 100%; justify-content: flex-start; }

  /* Invoice table → card rows */
  #invoice-table-wrap { overflow-x: visible; }
  .data-table thead { display: none; }
  .data-table tbody tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .data-table tbody tr:last-child { border-bottom: none; }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border: none;
    font-size: 0.88rem;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: 12px;
  }
  .data-table td[data-label=""] { justify-content: flex-end; padding-top: 8px; }

  /* Account selector grid → single col */
  .acct-selector-list { grid-template-columns: 1fr; }

  /* Footer hidden on mobile (nav replaces it) */
  #site-footer { display: none; }

  .footer-inner { flex-direction: column; gap: 6px; text-align: center; }
}

@media (max-width: 420px) {
  .stat-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stat-icon { width: 34px; height: 34px; }
}
