/* ============================================================
   TramitamosUnie Monitor — Stylesheet
   ============================================================ */

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

:root {
  --bg:           #080e1a;
  --bg-2:         #0d1526;
  --bg-3:         #111e35;
  --bg-card:      #0f1a2e;
  --border:       #1a2840;
  --border-hover: #253a5e;
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --text-dim:     #334155;
  --blue:         #3b82f6;
  --blue-dark:    #2563eb;
  --blue-glow:    rgba(59,130,246,.2);
  --green:        #10b981;
  --amber:        #f59e0b;
  --red:          #ef4444;
  --purple:       #8b5cf6;
  --teal:         #14b8a6;
  --sidebar-w:    260px;
  --topbar-h:     64px;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
  --shadow-card:  0 2px 12px rgba(0,0,0,.3);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  font-size: 1.75rem;
  filter: drop-shadow(0 0 8px rgba(59,130,246,.5));
}
.brand-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  color: #f1f5f9;
}
.brand-sub { font-size: .7rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 1.25rem .75rem; overflow-y: auto; }
.nav-section {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--text-dim);
  padding: .5rem .6rem;
  margin-top: .25rem;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: .1rem;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,.15); color: var(--blue); }
.nav-item.active .nav-icon { color: var(--blue); }
.nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }
.nav-item.sub { font-size: .8rem; padding-left: 2.5rem; }
.nav-item.urgente-link { color: #fbbf24; }
.nav-item.urgente-link:hover { color: #f59e0b; background: rgba(245,158,11,.1); }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.dot.nuevo    { background: #60a5fa; }
.dot.proceso  { background: var(--green); }
.dot.pendoc   { background: var(--amber); }
.dot.pencita  { background: var(--purple); }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-dark), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem; flex-shrink: 0;
}
.user-name { font-size: .8rem; font-weight: 600; color: #cbd5e1; }
.user-role { font-size: .7rem; color: var(--text-muted); }
.logout-btn {
  margin-left: auto;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 1.1rem;
  padding: .3rem;
  border-radius: 6px;
  transition: all .2s;
}
.logout-btn:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ---- MAIN WRAPPER ---- */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; color: #f1f5f9; }
.topbar-date { font-size: .8rem; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }

.main-content { flex: 1; padding: 2rem; }

/* ---- CARDS ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
}
.card-subtitle { font-size: .8rem; color: var(--text-muted); margin-top: .1rem; }

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .2s;
  cursor: default;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat-card.blue::before   { background: var(--blue); }
.stat-card.green::before  { background: var(--green); }
.stat-card.amber::before  { background: var(--amber); }
.stat-card.red::before    { background: var(--red); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.teal::before   { background: var(--teal); }

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: .75rem;
  display: block;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1;
  margin-bottom: .25rem;
}
.stat-label { font-size: .8rem; color: var(--text-muted); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid rgba(26,40,64,.6);
  transition: background .15s;
}
tbody tr:hover { background: rgba(59,130,246,.04); }
tbody td { padding: .875rem 1rem; color: #cbd5e1; vertical-align: middle; }
tbody td:first-child { font-weight: 600; color: #f1f5f9; }
.ref-code {
  font-family: monospace;
  font-size: .8rem;
  color: var(--blue);
  background: rgba(59,130,246,.1);
  padding: .2rem .5rem;
  border-radius: 4px;
}

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .25rem .65rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-nuevo     { background: rgba(96,165,250,.12); color: #93c5fd; border: 1px solid rgba(96,165,250,.2); }
.badge-proceso   { background: rgba(16,185,129,.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,.2); }
.badge-pendoc    { background: rgba(245,158,11,.12); color: #fcd34d; border: 1px solid rgba(245,158,11,.2); }
.badge-pencita   { background: rgba(139,92,246,.12); color: #c4b5fd; border: 1px solid rgba(139,92,246,.2); }
.badge-resuelto  { background: rgba(20,184,166,.12); color: #5eead4; border: 1px solid rgba(20,184,166,.2); }
.badge-archivado { background: rgba(100,116,139,.12); color: #94a3b8; border: 1px solid rgba(100,116,139,.2); }
.badge-cancelado { background: rgba(239,68,68,.12);  color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }

.prio-baja    { background: rgba(100,116,139,.12); color: #94a3b8; border: 1px solid rgba(100,116,139,.2); }
.prio-normal  { background: rgba(59,130,246,.1);   color: #93c5fd; border: 1px solid rgba(59,130,246,.2); }
.prio-alta    { background: rgba(245,158,11,.12);  color: #fcd34d; border: 1px solid rgba(245,158,11,.2); }
.prio-urgente { background: rgba(239,68,68,.12);   color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  border: none;
}
.btn-primary { background: var(--blue-dark); color: white; }
.btn-primary:hover { background: var(--blue); box-shadow: 0 4px 14px rgba(37,99,235,.4); }
.btn-secondary { background: var(--bg-3); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-success { background: rgba(16,185,129,.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,.2); }
.btn-success:hover { background: rgba(16,185,129,.25); }
.btn-sm { padding: .35rem .75rem; font-size: .78rem; }

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}
.form-control {
  padding: .7rem .9rem;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
  font-family: 'Outfit', sans-serif;
  transition: all .2s;
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.form-control::placeholder { color: var(--text-dim); }
select.form-control option { background: #0f1a2e; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ---- FILTER BAR ---- */
.filter-bar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-wrap::before {
  content: '⌕';
  position: absolute;
  left: .875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: .65rem .9rem .65rem 2.5rem;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .875rem;
  font-family: 'Outfit', sans-serif;
  transition: all .2s;
}
.search-input:focus { outline: none; border-color: var(--blue); }
.filter-select {
  padding: .65rem .9rem;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .875rem;
  font-family: 'Outfit', sans-serif;
  min-width: 160px;
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--blue); }

/* ---- DETAIL VIEW ---- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.detail-field { margin-bottom: 1rem; }
.detail-field-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .25rem; }
.detail-field-value { font-size: .9rem; color: #e2e8f0; }

.timeline { list-style: none; position: relative; padding-left: 1.75rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 1.25rem; font-size: .83rem; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.375rem;
  top: .35rem;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--bg);
}
.timeline-date { font-size: .72rem; color: var(--text-muted); margin-bottom: .2rem; }
.timeline-text { color: #cbd5e1; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: #f1f5f9; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.4rem; cursor: pointer; line-height: 1;
  padding: .2rem; border-radius: 4px;
  transition: color .2s;
}
.modal-close:hover { color: var(--text); }

/* ---- PAGINATION ---- */
.paginacion { display: flex; gap: .5rem; margin-top: 1.5rem; justify-content: center; }
.pag-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: .875rem;
  transition: all .15s;
}
.pag-btn:hover { border-color: var(--blue); color: var(--blue); }
.pag-btn.active { background: var(--blue-dark); border-color: var(--blue-dark); color: white; }

/* ---- ALERT / TOAST ---- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  padding: .875rem 1.25rem;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast-success { background: rgba(16,185,129,.85); color: #ecfdf5; }
.toast-error   { background: rgba(239,68,68,.85);  color: #fff1f2; }
.toast-info    { background: rgba(59,130,246,.85); color: #eff6ff; }

/* ---- UTILITIES ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); font-size: .85rem; }
.text-sm { font-size: .85rem; }
.text-right { text-align: right; }
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; color: #475569; margin-bottom: .5rem; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
}
