/* ====================================================
   Portal de Clientes — Zonlin Dominicana
   Mobile-first, PWA-ready
   ==================================================== */

:root {
  --accent:       #1a56db;
  --accent-dark:  #1e429f;
  --bg:           #f0f4f8;
  --surface:      #ffffff;
  --text:         #1a202c;
  --text-muted:   #718096;
  --border:       #e2e8f0;
  --green:        #38a169;
  --red:          #e53e3e;
  --yellow:       #d69e2e;
  --radius:       14px;
  --header-h:     56px;
  --nav-h:        62px;
  --shadow:       0 1px 4px rgba(0,0,0,.10);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── AUTH ── */
.auth-body {
  background: linear-gradient(160deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.auth-wrap {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
  color: #fff;
}
.auth-logo img { max-height: 60px; margin-bottom: 10px; }
.auth-title  { font-size: 1.35rem; font-weight: 700; }
.auth-sub    { font-size: .9rem; opacity: .85; margin-top: 4px; }

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}

.step-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.step-hint  { font-size: .88rem; color: var(--text-muted); margin-bottom: 20px; }

.auth-note {
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 16px;
}

/* Phone flag input */
.phone-input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.phone-flag {
  padding: 0 12px;
  font-size: .9rem;
  background: #f7fafc;
  border-right: 1.5px solid var(--border);
  line-height: 46px;
  white-space: nowrap;
  color: var(--text-muted);
}
.phone-input-wrap input {
  border: none;
  outline: none;
  padding: 12px 14px;
  font-size: 1rem;
  width: 100%;
  background: transparent;
}

/* OTP digit inputs */
.otp-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}
.otp-digit {
  width: 46px;
  height: 54px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s;
}
.otp-digit:focus { border-color: var(--accent); }

.otp-timer {
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
  margin: 8px 0;
  min-height: 18px;
}

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.label-opt { font-weight: 400; color: var(--text-muted); font-size: .82rem; }
.form-group input,
.form-group textarea,
.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
  font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-select:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; cursor: pointer; }

.pass-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.pass-wrap input { border: none; outline: none; padding: 12px 14px; flex: 1; background: transparent; }
.btn-eye {
  background: none;
  border: none;
  padding: 0 14px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 46px;
}

/* ── BUTTONS ── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .08s;
  margin-top: 8px;
  font-family: inherit;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  display: block;
  width: 100%;
  padding: 11px;
  background: none;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
}

/* ── ALERTS ── */
.alert-success {
  background: #f0fff4;
  border: 1.5px solid #9ae6b4;
  color: #276749;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .9rem;
  margin-bottom: 12px;
}
.alert-error {
  background: #fff5f5;
  border: 1.5px solid #feb2b2;
  color: #c53030;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .9rem;
  margin-bottom: 12px;
}

/* ── APP LAYOUT ── */
.app-body {
  background: var(--bg);
  padding-top: var(--header-h);
  padding-bottom: var(--nav-h);
  min-height: 100vh;
}

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--accent);
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-logo  { height: 28px; }
.header-company { color: #fff; font-weight: 700; font-size: .95rem; }
.header-logout, .header-refresh {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: 1.3rem;
  cursor: pointer;
  background: none; border: none;
}
.header-back  {
  color: #fff;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
}
.header-title {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}

.page-wrap {
  max-width: 500px;
  margin: 0 auto;
  padding: 16px 14px 24px;
}

/* ── GREETING ── */
.greeting-wrap { margin-bottom: 16px; }
.greeting { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.customer-code { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

/* ── STATUS CARD ── */
.status-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border-left: 4px solid var(--border);
}
.status-card--green { border-left-color: var(--green); }
.status-card--red   { border-left-color: var(--red); }
.status-left { display: flex; align-items: center; gap: 12px; }
.status-dot  { width: 12px; height: 12px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.status-dot--green  { background: var(--green); box-shadow: 0 0 0 3px rgba(56,161,105,.2); }
.status-dot--red    { background: var(--red);   box-shadow: 0 0 0 3px rgba(229,62,62,.2); }
.status-dot--gray   { background: #a0aec0; }
.status-label { font-weight: 700; font-size: 1rem; }
.status-plan  { font-size: .83rem; color: var(--text-muted); }
.status-price { font-size: 1.05rem; font-weight: 700; color: var(--accent); }

/* ── INVOICE CARD ── */
.invoice-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 6px;
  border: 1.5px solid var(--border);
}
.invoice-card--overdue { border-color: #fc8181; background: #fff5f5; }
.invoice-icon  { font-size: 1.6rem; flex-shrink: 0; }
.invoice-info  { flex: 1; }
.invoice-title { font-weight: 700; font-size: .95rem; }
.invoice-period { font-size: .82rem; color: var(--text-muted); }
.invoice-amount { font-size: 1.1rem; font-weight: 700; color: var(--red); white-space: nowrap; }
.pay-info { font-size: .82rem; color: var(--text-muted); margin-bottom: 14px; text-align: center; }

/* ── QUICK MENU ── */
.quick-menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 12px;
  margin: 20px 0 16px;
}
.quick-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .1s;
}
.quick-item:active { transform: scale(.96); }
.quick-icon { font-size: 1.7rem; }
.quick-logout { color: var(--text-muted); }

/* ── TICKET ALERT ── */
.ticket-alert {
  display: block;
  background: #fffbeb;
  border: 1.5px solid #f6e05e;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .9rem;
  font-weight: 600;
  color: #744210;
  text-decoration: none;
  margin-bottom: 14px;
}

/* ── SECTION CARD ── */
.section-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.section-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 14px;
  color: var(--text);
}
.section-note {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.section-note-block {
  font-size: .85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0 8px;
}

/* ── CURRENT SSID ── */
.current-ssid {
  display: flex;
  align-items: center;
  gap: 14px;
}
.wifi-icon { font-size: 2rem; }
.ssid-name { font-size: 1.1rem; font-weight: 700; }
.ssid-sub  { font-size: .8rem; color: var(--text-muted); }

/* ── DEVICE CARDS ── */
.dev-count-label {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.device-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  border-left: 3px solid var(--border);
}
.device-card--active  { border-left-color: var(--green); }
.device-card--offline { border-left-color: #cbd5e0; opacity: .7; }
.device-icon  { font-size: 1.7rem; flex-shrink: 0; }
.device-info  { flex: 1; min-width: 0; }
.device-name  { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-meta  { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.device-status { font-size: .8rem; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.device-status--on  { color: var(--green); }
.device-status--off { color: #a0aec0; }

/* ── TICKET LIST ── */
.ticket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row-info { flex: 1; min-width: 0; }
.ticket-row-subject {
  font-size: .92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-row-meta { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.ticket-row-status { font-size: .8rem; white-space: nowrap; }

/* ── LOADING ── */
.loading-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: .95rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 20px;
  font-size: .9rem;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,.07);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  transition: color .15s;
  padding-bottom: 4px;
}
.nav-item span:first-child { font-size: 1.35rem; }
.nav-item.active { color: var(--accent); }

/* ── PWA safe areas ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .app-body   { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

/* ── Responsive ── */
@media (min-width: 500px) {
  .quick-menu { grid-template-columns: repeat(4, 1fr); }
}
