/* ============================================================
   REDENES Portal — Global Stylesheet
   Theme: Dark Navy  |  Font: Inter
   ============================================================ */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --bg:            #0D1B2A;
  --card:          #142236;
  --card-hover:    #1A2D45;
  --primary:       #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: rgba(37, 99, 235, .12);
  --text:          #E2E8F0;
  --text-secondary:#94A3B8;
  --border:        #1E3A5F;
  --error:         #DC2626;
  --error-bg:      rgba(220, 38, 38, .1);
  --success:       #059669;
  --success-bg:    rgba(5, 150, 105, .1);
  --warning:       #D97706;
  --warning-bg:    rgba(217, 119, 6, .1);
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,.35);
  --transition:    .2s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ---------- Typography ---------- */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }

/* ---------- Logo ---------- */
.logo {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  user-select: none;
}
.logo-sm { font-size: 1.25rem; }

/* ---------- Auth Layout (centered card) ---------- */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  padding: 2.5rem 2rem;
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 2rem;
  display: block;
}

.auth-card h2 {
  text-align: center;
  margin-bottom: .5rem;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: .9rem;
  margin-bottom: 1.5rem;
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 1.125rem;
}

.form-group label {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: .375rem;
  letter-spacing: .02em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .625rem .875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-secondary);
  opacity: .6;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input.invalid,
.form-group select.invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-bg);
}

.form-group .field-error {
  font-size: .75rem;
  color: var(--error);
  margin-top: .25rem;
  min-height: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Phone input with prefix */
.phone-group {
  display: flex;
  gap: .5rem;
}
.phone-group .prefix {
  flex: 0 0 60px;
  text-align: center;
}

/* Checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}
.checkbox-row label {
  font-size: .875rem;
  color: var(--text);
  cursor: pointer;
  margin: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  outline: none;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 2px 12px rgba(37,99,235,.35);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--card-hover);
  border-color: var(--text-secondary);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-block { width: 100%; }

.btn-sm { padding: .375rem 1rem; font-size: .8125rem; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; }

/* ---------- Links inside auth card ---------- */
.auth-links {
  text-align: center;
  margin-top: 1.25rem;
  font-size: .875rem;
  color: var(--text-secondary);
}
.auth-links a { margin: 0 .25rem; }

.forgot-link {
  display: block;
  text-align: right;
  font-size: .8125rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}
.forgot-link:hover { color: var(--primary); }

/* ---------- Alerts / Inline Messages ---------- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show { display: block; }
.alert-error   { background: var(--error-bg);   color: #FCA5A5; border: 1px solid rgba(220,38,38,.25); }
.alert-success { background: var(--success-bg); color: #6EE7B7; border: 1px solid rgba(5,150,105,.25); }
.alert-warning { background: var(--warning-bg); color: #FCD34D; border: 1px solid rgba(217,119,6,.25); }

/* ---------- Toast Notification ---------- */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.toast {
  padding: .875rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  min-width: 280px;
  max-width: 420px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  animation: toastIn .3s ease;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.toast-error   { background: #7F1D1D; color: #FCA5A5; }
.toast-success { background: #064E3B; color: #6EE7B7; }
.toast-info    { background: #1E3A5F; color: #93C5FD; }
.toast.removing { animation: toastOut .3s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ---------- Spinner ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  display: none;
}
.loading-overlay.show { display: flex; }

/* ---------- Navbar ---------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 2rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .logo { font-size: 1.25rem; }
.nav-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.nav-user {
  color: var(--text-secondary);
  font-size: .875rem;
}
.nav-user strong { color: var(--text); font-weight: 600; }

/* ---------- Main Content ---------- */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ---------- Dashboard Cards ---------- */
.org-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.org-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.org-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.org-card h3 { margin-bottom: .25rem; }
.org-card .org-abbr {
  color: var(--text-secondary);
  font-size: .8125rem;
  margin-bottom: .75rem;
}
.org-card .org-type {
  display: inline-block;
  padding: .2rem .6rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .75rem;
  font-weight: 600;
  border-radius: 4px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: .4;
}
.empty-state h2 { margin-bottom: .5rem; }
.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Multi-Step Form ---------- */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.step-dot.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.step-dot.completed {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}
.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  max-width: 60px;
  transition: background var(--transition);
}
.step-line.completed { background: var(--success); }

.step-panel { display: none; }
.step-panel.active { display: block; }

.step-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.step-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ---------- Entitlement Cards ---------- */
.entitlement-list {
  display: grid;
  gap: .75rem;
  margin-top: .75rem;
}
.entitlement-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.entitlement-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}
.entitlement-item input[type="checkbox"] {
  margin-top: .125rem;
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.entitlement-info { flex: 1; }
.entitlement-info .name { font-weight: 600; font-size: .9375rem; }
.entitlement-info .desc { color: var(--text-secondary); font-size: .8125rem; margin-top: .125rem; }
.entitlement-price {
  font-weight: 700;
  color: var(--primary);
  font-size: .9375rem;
  white-space: nowrap;
}

/* ---------- OTP Input ---------- */
.otp-group {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin: 1.5rem 0;
}
.otp-group input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.otp-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.otp-timer {
  text-align: center;
  color: var(--text-secondary);
  font-size: .875rem;
  margin-bottom: 1rem;
}
.otp-timer .timer-value {
  color: var(--warning);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Success Screen ---------- */
.success-screen {
  text-align: center;
  padding: 2rem 1rem;
}
.success-screen .checkmark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}
.success-screen .checkmark svg { width: 32px; height: 32px; }
.success-screen h2 { margin-bottom: .5rem; }
.success-screen p { color: var(--text-secondary); }

/* ---------- Password Strength ---------- */
.pw-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: .375rem;
  overflow: hidden;
}
.pw-strength .bar {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width .3s, background .3s;
}
.pw-strength .bar.weak   { width: 33%; background: var(--error); }
.pw-strength .bar.medium { width: 66%; background: var(--warning); }
.pw-strength .bar.strong { width: 100%; background: var(--success); }

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.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; }
.hidden { display: none !important; }

/* ---------- Wide card for multi-step ---------- */
.auth-card.wide {
  max-width: 560px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .auth-card { padding: 2rem 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
  .navbar { padding: .75rem 1rem; }
  .main-content { padding: 1.25rem 1rem; }
  .step-indicator { gap: 0; }
  .step-line { max-width: 36px; }
  .otp-group input { width: 40px; height: 48px; font-size: 1.25rem; }
  h1 { font-size: 1.375rem; }
}

@media (max-width: 400px) {
  .auth-card { padding: 1.5rem 1rem; }
  .logo { font-size: 1.375rem; }
  .step-dot { width: 28px; height: 28px; font-size: .6875rem; }
}
