@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --brand:   #1a56db;
  --brand-d: #1245b5;
  --brand-l: #eff6ff;
  --fg:      #1c2133;
  --fg2:     #5a6480;
  --fg3:     #94a3b8;
  --border:  #e2e8f0;
  --surf:    #f8fafc;
  --white:   #ffffff;
  color-scheme: light;
  --ok:      #16a34a;
  --ok-l:    #dcfce7;
  --warn:    #d97706;
  --warn-l:  #fef3c7;
  --err:     #dc2626;
  --err-l:   #fee2e2;
  --radius:  10px;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-m:0 4px 16px rgba(0,0,0,.10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand:   #3b82f6;
    --brand-d: #2563eb;
    --brand-l: #1e3a5f;
    --fg:      #e8ecf4;
    --fg2:     #94a3b8;
    --fg3:     #64748b;
    --border:  #2d3748;
    --surf:    #1a2235;
    --white:   #111827;
    --ok-l:    #14532d;
    --warn-l:  #451a03;
    --err-l:   #450a0a;
  }
}
:root[data-theme="dark"] {
  --brand:   #3b82f6;
  --brand-d: #2563eb;
  --brand-l: #1e3a5f;
  --fg:      #e8ecf4;
  --fg2:     #94a3b8;
  --fg3:     #64748b;
  --border:  #2d3748;
  --surf:    #1a2235;
  --white:   #111827;
  --ok-l:    #14532d;
  --warn-l:  #451a03;
  --err-l:   #450a0a;
}

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

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--surf);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 max(20px, env(safe-area-inset-left, 0px));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.site-header-inner {
  max-width: 760px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.site-logo img { height: 26px; }
.site-logo-sep { width: 1px; height: 18px; background: var(--border); }
.site-logo-label { font-size: 13px; font-weight: 600; color: var(--fg2); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg2);
}
.user-chip strong { color: var(--fg); font-weight: 600; }
.btn-logout {
  font-size: 12px;
  color: var(--fg3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}
.btn-logout:hover { background: var(--surf); color: var(--err); }

/* ── Campana de notificaciones del ciudadano ─────────────────────────────── */
.notif-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg2);
  transition: background .15s;
  flex-shrink: 0;
}
.notif-bell:hover { background: var(--surf); color: var(--fg); }
.notif-bell svg { width: 20px; height: 20px; }
.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--err, #dc2626);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}
.notif-badge[hidden] { display: none !important; }

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 400;
  overflow: hidden;
}
.notif-dropdown-header {
  padding: 14px 16px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notif-dropdown-clear {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.notif-dropdown-clear:hover { background: var(--brand-l); }
.notif-dropdown-list { max-height: 280px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
  color: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surf); }
.notif-item.unread { background: var(--brand-l, #eff6ff); }
.notif-item.unread:hover { background: #dbeafe; }
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 5px;
  flex-shrink: 0;
}
.notif-item:not(.unread) .notif-dot { background: transparent; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--fg); margin-bottom: 2px; }
.notif-item-sub   { font-size: 12px; color: var(--fg3); }
.notif-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--fg3);
}
.notif-bell-wrap {
  position: relative;
}

.page-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px max(20px, env(safe-area-inset-left, 0px));
  flex: 1;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: 13.5px;
  color: var(--fg2);
  margin-bottom: 24px;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 12px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-d); }

.btn-outline {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}
.btn-outline:hover:not(:disabled) { background: var(--brand-l); }

.btn-ghost {
  background: transparent;
  color: var(--fg2);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surf); }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-block { width: 100%; }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--fg);
}
.form-label .req { color: var(--err); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--fg);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: 12px; color: var(--fg3); margin-top: 4px; }

/* ── Status badge ───────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge-recibida  { background: var(--warn-l);  color: var(--warn); }
.badge-en_proceso{ background: var(--brand-l); color: var(--brand); }
.badge-respondida{ background: var(--ok-l);    color: var(--ok); }

/* ── Status tracker (3 pasos) ──────────────────────────────────────────── */

.status-track {
  display: flex;
  align-items: center;
  margin: 20px 0;
  gap: 0;
}
.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  text-align: center;
}
.status-step::before {
  content: '';
  position: absolute;
  top: 14px;
  left: calc(-50% + 14px);
  right: calc(50% + 14px);
  height: 2px;
  background: var(--border);
}
.status-step:first-child::before { display: none; }

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--fg3);
  position: relative;
  z-index: 1;
}
.status-step.done .step-dot {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.status-step.active .step-dot {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.status-step.done::before,
.status-step.active::before {
  background: var(--ok);
}
.step-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg3);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.status-step.done .step-label,
.status-step.active .step-label { color: var(--fg); }

.step-date {
  font-size: 10px;
  color: var(--fg3);
  margin-top: 3px;
  line-height: 1.3;
  text-align: center;
}
.status-step.done .step-date,
.status-step.active .step-date { color: var(--fg2); }

/* ── Solicitud card ─────────────────────────────────────────────────────── */

.solicitud-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s;
  box-shadow: var(--shadow);
}
.solicitud-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-m);
}
.sol-code { font-size: 12px; color: var(--fg3); font-weight: 600; grid-column: 1; }
.sol-badge { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.sol-asunto { font-size: 15px; font-weight: 700; grid-column: 1; }
.sol-tipo { font-size: 12.5px; color: var(--fg2); grid-column: 1; }
.sol-date { font-size: 12px; color: var(--fg3); grid-column: 1; }

/* ── Upload zone ────────────────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--brand);
  background: var(--brand-l);
}
.upload-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-zone-icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone-label { font-size: 14px; font-weight: 600; color: var(--fg2); }
.upload-zone-hint { font-size: 12px; color: var(--fg3); margin-top: 4px; }

.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; background: var(--surf); border-radius: 6px;
  font-size: 13px;
}
.file-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { color: var(--fg3); font-size: 12px; white-space: nowrap; }
.file-item-remove { background: none; border: none; cursor: pointer; color: var(--fg3); font-size: 16px; padding: 0 4px; }
.file-item-remove:hover { color: var(--err); }

/* ── Alerts ─────────────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.alert-ok   { background: var(--ok-l);   color: var(--ok); }
.alert-warn { background: var(--warn-l); color: var(--warn); }
.alert-err  { background: var(--err-l);  color: var(--err); }
.alert-info { background: var(--brand-l); color: var(--brand); }

/* ── Misc ───────────────────────────────────────────────────────────────── */

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

.text-muted { color: var(--fg3); font-size: 13px; }
.text-sm    { font-size: 13px; }

.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.spinner-dark {
  border-color: rgba(26,86,219,.2);
  border-top-color: var(--brand);
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--fg2);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--fg); }
.empty-state-text  { font-size: 14px; }

@media (max-width: 480px) {
  .page-wrap { padding: 20px max(16px, env(safe-area-inset-left, 0px)); }
  .site-header-inner { height: 52px; }
  .page-title { font-size: 19px; }
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.site-footer {
  background: var(--brand-d, #0f2560);
  color: rgba(255,255,255,.85);
  margin-top: auto;
  padding: 36px max(24px, env(safe-area-inset-left, 0px));
  font-size: 13px;
  line-height: 1.6;
}

.site-footer a {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  transition: color .15s;
}
.site-footer a:hover { color: #fff; }

.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 40px;
}

.footer-col-name {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 10px;
}

.footer-col-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  margin-bottom: 10px;
}

.footer-info-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 7px;
  color: rgba(255,255,255,.8);
}
.footer-info-row svg { flex-shrink: 0; margin-top: 2px; opacity: .7; }

.footer-social {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.footer-social-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,.25);
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.footer-social-btn:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.5);
  color: #fff;
}

.footer-bottom {
  max-width: 900px;
  margin: 24px auto 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: rgba(255,255,255,.45);
}

@media (max-width: 600px) {
  .footer-inner { grid-template-columns: 1fr; gap: 20px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
}
