/* ================================================================
   QuejasSalud · Design System
   Azul corporativo, mobile-first, white-label via CSS vars
   ================================================================ */

/* ── Reset & Root ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary:       #1A6FC4;
  --color-primary-dark:  #0D4F8B;
  --color-primary-light: #EAF2FF;
  --color-primary-mid:   #4A90D9;

  --color-bg:        #F4F7FC;
  --color-surface:   #FFFFFF;
  --color-border:    #DDE4EF;
  --color-text:      #1A2035;
  --color-text-muted:#6B7A99;

  --color-success:   #10A96E;
  --color-warning:   #F5A623;
  --color-danger:    #E5393B;
  --color-info:      #0EA5D4;
  --color-purple:    #7C3AED;

  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow-sm:  0 1px 4px rgba(26,111,196,.08);
  --shadow-md:  0 4px 20px rgba(26,111,196,.13);
  --transition: 250ms ease;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--color-primary-dark);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo   { max-height: 44px; max-width: 160px; object-fit: contain; }
.sidebar-brand-text {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .3px;
}

.sidebar-nav {
  list-style: none;
  padding: 12px 12px;
  flex: 1;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.sidebar-nav li a svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: rgba(255,255,255,.14);
  color: #fff;
}
.sidebar-nav li a.active { background: var(--color-primary); }

.nav-section {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  padding: 16px 14px 4px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}
.user-name  { color: #fff; font-size: .8rem; font-weight: 600; }
.user-role  { color: rgba(255,255,255,.5); font-size: .7rem; }
.btn-logout {
  margin-left: auto;
  color: rgba(255,255,255,.5);
  transition: color var(--transition);
  display: flex;
}
.btn-logout:hover { color: var(--color-danger); }
.btn-logout svg { width: 20px; height: 20px; fill: currentColor; }

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
  transition: left var(--transition);
}
.topbar-title { font-weight: 600; font-size: 1rem; flex: 1; }
.topbar-inst  { font-size: .8rem; color: var(--color-text-muted); }
.menu-toggle  { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.menu-toggle svg { width: 24px; height: 24px; fill: var(--color-text); display: block; }

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px 28px 60px;
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left var(--transition);
}

/* ── Overlay (mobile) ─────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 190;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  border: 1px solid var(--color-border);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title { font-size: 1rem; font-weight: 700; }

/* ── Stats grid ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; fill: #fff; }
.stat-icon.blue   { background: var(--color-primary); }
.stat-icon.orange { background: var(--color-warning); }
.stat-icon.red    { background: var(--color-danger); }
.stat-icon.green  { background: var(--color-success); }
.stat-icon.purple { background: var(--color-purple); }
.stat-icon.info   { background: var(--color-info); }

.stat-number { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label  { font-size: .78rem; color: var(--color-text-muted); margin-top: 2px; }

/* ── Table ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
th {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 700;
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-primary-light); }

/* ── Semáforo filas ───────────────────────────────────────────── */
tr.semaforo-rojo    td { border-left: 4px solid var(--color-danger); }
tr.semaforo-amarillo td { border-left: 4px solid var(--color-warning); }
tr.semaforo-verde   td { border-left: 4px solid var(--color-success); }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-primary  { background: #DBEAFE; color: #1e40af; }
.badge-warning  { background: #FEF3C7; color: #92400e; }
.badge-danger   { background: #FEE2E2; color: #991b1b; }
.badge-success  { background: #D1FAE5; color: #065f46; }
.badge-info     { background: #E0F2FE; color: #075985; }
.badge-dark     { background: #E5E7EB; color: #374151; }
.badge-purple   { background: #EDE9FE; color: #5b21b6; }
.badge-secondary{ background: #F3F4F6; color: #6B7280; }

/* ── Semáforo dots ────────────────────────────────────────────── */
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot-green  { background: var(--color-success); }
.dot-yellow { background: var(--color-warning); }
.dot-red    { background: var(--color-danger); }
.dot-gray   { background: var(--color-border); }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-row   { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
label       { display: block; font-size: .82rem; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.required::after { content: ' *'; color: var(--color-danger); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,111,196,.12);
}
textarea { resize: vertical; min-height: 100px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%236B7A99' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px;
  padding-right: 36px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .875rem;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }

.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-primary-light); border-color: var(--color-primary); }

.btn-success   { background: var(--color-success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }

.btn-danger    { background: var(--color-danger); color: #fff; }
.btn-danger:hover  { filter: brightness(.9); }

.btn-warning   { background: var(--color-warning); color: #fff; }
.btn-sm  { padding: 6px 12px; font-size: .78rem; }
.btn-icon { padding: 8px; }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .875rem;
  position: relative;
}
.alert-close {
  position: absolute; right: 12px; top: 10px;
  background: none; border: none; cursor: pointer; font-size: 1.2rem;
  line-height: 1; color: inherit; opacity: .6;
}
.alert-success { background: #D1FAE5; color: #065f46; border-left: 4px solid var(--color-success); }
.alert-error   { background: #FEE2E2; color: #991b1b; border-left: 4px solid var(--color-danger); }
.alert-warning { background: #FEF3C7; color: #92400e; border-left: 4px solid var(--color-warning); }
.alert-info    { background: #E0F2FE; color: #075985; border-left: 4px solid var(--color-info); }

/* ── Page header ──────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; }
.page-header p  { font-size: .85rem; color: var(--color-text-muted); margin-top: 2px; }

/* ── Section title divider ────────────────────────────────────── */
.section-divider {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-muted);
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

/* ── Pagination ───────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 20px; }
.pagination a, .pagination span {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  transition: all var(--transition);
}
.pagination a:hover   { border-color: var(--color-primary); color: var(--color-primary); }
.pagination .current  { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ── Timeline historial ───────────────────────────────────────── */
.timeline { list-style: none; padding-left: 0; }
.timeline-item { display: flex; gap: 14px; padding: 10px 0; position: relative; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: 17px; top: 36px; bottom: 0;
  width: 2px;
  background: var(--color-border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-primary-light);
  border: 2px solid var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.timeline-dot svg { width: 16px; height: 16px; fill: var(--color-primary); }
.timeline-body { flex: 1; }
.timeline-title { font-weight: 600; font-size: .85rem; }
.timeline-meta  { font-size: .75rem; color: var(--color-text-muted); margin-top: 2px; }
.timeline-text  { font-size: .83rem; margin-top: 4px; color: var(--color-text); }

/* ── Login page ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  background: var(--color-bg);
}
.login-left {
  flex: 0 0 440px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 48px;
}
.login-logo { font-size: 1.3rem; font-weight: 800; color: var(--color-primary); margin-bottom: 40px; display: flex; align-items: center; gap: 10px; }
.login-logo svg { width: 32px; height: 32px; }
.login-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.login-sub   { color: var(--color-text-muted); font-size: .9rem; margin-bottom: 32px; }
.login-right {
  flex: 1;
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 60%, var(--color-primary-mid) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-right::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -150px; right: -150px;
}
.login-right::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  bottom: -80px; left: -80px;
}
.login-hero-text { color: #fff; text-align: center; position: relative; z-index: 1; }
.login-hero-text h2 { font-size: 2.2rem; font-weight: 800; line-height: 1.2; margin-bottom: 16px; }
.login-hero-text p  { opacity: .8; font-size: 1rem; }
.login-pills { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 28px; }
.login-pill {
  background: rgba(255,255,255,.15);
  color: #fff;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: .78rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

/* ── Documento respuesta preview ──────────────────────────────── */
.doc-preview {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 760px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
}
.doc-header-membrete { margin-bottom: 32px; }
.doc-header-membrete img { max-height: 80px; }
.doc-numero { font-size: .8rem; color: var(--color-text-muted); margin-bottom: 4px; }
.doc-title  { font-size: 1.25rem; font-weight: 700; margin-bottom: 24px; }
.doc-field  { margin-bottom: 12px; font-size: .875rem; }
.doc-field strong { display: inline-block; min-width: 160px; }
.doc-body   { margin-top: 24px; border-top: 1px solid var(--color-border); padding-top: 20px; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
}

@media (max-width: 600px) {
  .login-left  { flex: 1; padding: 32px 24px; }
  .login-right { display: none; }
  .main-content { padding: 16px 16px 60px; }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .form-row    { grid-template-columns: 1fr; }
  .doc-preview { padding: 20px 16px; }
  table { font-size: .78rem; }
  th, td { padding: 10px 10px; }
}

/* ── Utility ──────────────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-0   { margin-bottom: 0; }
.mb-16  { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
