/* ── Masigas Design Tokens ─────────────────────────────────── */
:root {
  --bg:        #060B18;
  --bg-2:      #0A1428;
  --bg-3:      #0F1D38;
  --accent:    #00C8FF;
  --accent-dk: #00A4D6;
  --accent-2:  #FF8C42;
  --accent-2dk:#E87530;
  --text:      #FFFFFF;
  --text-2:    rgba(255,255,255,.6);
  --text-3:    rgba(255,255,255,.35);
  --border:    rgba(255,255,255,.08);
  --success:   #22c55e;
  --error:     #ef4444;
  --warning:   #f59e0b;
  --r-sm:      6px;
  --r-md:      12px;
  --r-lg:      20px;
  --r-pill:    999px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

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

body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .brand {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: .5px;
}

.sidebar-logo .sub {
  font-size: .75rem;
  color: var(--text-3);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: .875rem;
  transition: background .15s, color .15s;
  cursor: pointer;
}

.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: rgba(0,200,255,.12); color: var(--accent); }

.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: .75rem;
  color: var(--text-3);
}

/* ── Main content ───────────────────────────────────────────── */
.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { font-size: 1.25rem; font-weight: 600; }
.topbar .date { font-size: .8rem; color: var(--text-3); }

.content { padding: 32px; flex: 1; }

/* ── Cards de proyectos ─────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: border-color .2s, transform .15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  background: var(--bg-3);
}

.card-title { font-size: 1rem; font-weight: 600; }
.card-desc  { font-size: .8rem; color: var(--text-2); line-height: 1.5; }

.card-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .75rem;
  color: var(--text-3);
}

.card-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--bg);
  font-size: .8rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  margin-top: 4px;
  width: fit-content;
}

.card-btn:hover { background: var(--accent-dk); }

/* ── Historial reciente ─────────────────────────────────────── */
.section-title {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.history-panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 24px;
  margin-top: 32px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.history-item:last-child { border-bottom: none; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.history-info { flex: 1; }
.history-time { color: var(--text-3); font-size: .75rem; }

/* ── Página de proyecto (2 paneles) ─────────────────────────── */
.project-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .project-layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Formulario ─────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: .6rem 1rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s;
  outline: none;
}

.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-3); }

select.form-control option {
  background: var(--bg-2);
  color: var(--text);
}

/* ── Botones ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: .7rem 1.75rem;
  border-radius: var(--r-pill);
  font-size: .875rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--accent);   color: var(--bg); }
.btn-primary:hover:not(:disabled)  { background: var(--accent-dk); }
.btn-secondary { background: var(--accent-2); color: var(--bg); }
.btn-secondary:hover:not(:disabled) { background: var(--accent-2dk); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-3); color: var(--text); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ── Lista de PDFs generados ────────────────────────────────── */
.pdf-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.pdf-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .85rem;
  gap: 8px;
}

.pdf-item .pdf-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-item .pdf-size { color: var(--text-3); font-size: .75rem; flex-shrink: 0; }

/* ── Toast / notificaciones ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
  max-width: 340px;
}

.toast.success { background: #14532d; border: 1px solid var(--success); color: var(--success); }
.toast.error   { background: #450a0a; border: 1px solid var(--error);   color: var(--error);   }
.toast.info    { background: #0c1f3d; border: 1px solid var(--accent);  color: var(--accent);  }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Progress bar ───────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-3);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: 12px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  transition: width .3s ease;
}

/* ── Badge de estado ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: .7rem;
  font-weight: 600;
}
.badge-success { background: rgba(34,197,94,.15); color: var(--success); }
.badge-error   { background: rgba(239,68,68,.15);  color: var(--error); }
.badge-pending { background: rgba(0,200,255,.12);  color: var(--accent); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }

/* ── Spinner ────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabla de suministros ───────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

th {
  background: var(--bg-3);
  color: var(--text-2);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
  font-size: .9rem;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ── Slots de fotos DDJJ ────────────────────────────────────── */
.foto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.foto-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.slot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.overlay-ctrl {
  font-size: .68rem;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  padding: 1px 0;
}

.overlay-ctrl input[type=checkbox] {
  cursor: pointer;
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
}

.overlay-ctrl.ref-ocr   { color: var(--accent); font-weight: 600; cursor: default; }
.overlay-ctrl.disabled  { opacity: .35; cursor: default; }

.foto-slot {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-3);
  border: 2px dashed var(--border);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s;
  min-height: 80px;
  user-select: none;
}

.foto-slot:hover       { border-color: var(--accent); }
.foto-slot.drag-over   { border-color: var(--accent); background: rgba(0,200,255,.08); }
.foto-slot.tiene-foto  { border-style: solid; border-color: rgba(34,197,94,.5); }

.foto-slot-num {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: .6rem;
  font-weight: 700;
  color: var(--text-3);
  z-index: 1;
}

.foto-slot-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}

.foto-slot-empty-icon  { font-size: 1.3rem; color: var(--text-3); }
.foto-slot-label       { font-size: .65rem; color: var(--text-3); text-align: center; }

.foto-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.foto-del-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(239,68,68,.9);
  color: #fff;
  border: none;
  font-size: .65rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  line-height: 1;
}

.foto-slot:hover .foto-del-btn { display: flex; }

.foto-slot-label-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,.65);
  font-size: .6rem;
  color: #fff;
  text-align: center;
  padding: 2px 4px;
  z-index: 2;
}

.foto-slot-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* ── Archivos Excel Base (Dashboard) ───────────────────────── */
.excel-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.excel-row:last-child { border-bottom: none; }

.excel-row-icon {
  font-size: 1.2rem;
  width: 30px;
  text-align: center;
  flex-shrink: 0;
}

.excel-row-info {
  flex: 1;
  min-width: 0;
}

.excel-row-proyecto {
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.excel-row-archivo {
  font-size: .75rem;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.excel-row-archivo.loaded  { color: var(--success); }
.excel-row-archivo.missing { color: var(--error); }

.excel-upload-btn {
  flex-shrink: 0;
  cursor: pointer;
  font-size: .8rem;
  padding: .45rem .9rem;
}

/* ── Back link ──────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: .85rem;
  margin-bottom: 24px;
  transition: color .15s;
}
.back-link:hover { color: var(--accent); }

/* ═══════════════════════════════════════════════════════════
   MEJORAS VISUALES v2.0
   ═══════════════════════════════════════════════════════════ */

/* ── Stats cards en Dashboard ───────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px)  { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .15s;
}

.stat-card:hover {
  border-color: rgba(0,200,255,.3);
  transform: translateY(-2px);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  min-height: 2rem;
}

.stat-label {
  font-size: .72rem;
  color: var(--text-3);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stat-icon {
  position: absolute;
  right: 18px; top: 16px;
  font-size: 1.6rem;
  opacity: .18;
}

/* ── Glassmorphism ──────────────────────────────────────────── */
.glass {
  background: rgba(10, 20, 40, 0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(0, 200, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
}

/* Aplicar glassmorphism a paneles que lo tengan */
.panel.glass, .history-panel.glass {
  background: rgba(10, 20, 40, 0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-color: rgba(0, 200, 255, 0.1);
}

/* ── Skeleton loaders ───────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-3) 25%,
    rgba(255,255,255,.055) 50%,
    var(--bg-3) 75%
  );
  background-size: 1200px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--r-sm);
  display: block;
}

.sk-line  { height: 13px; margin-bottom: 8px; }
.sk-line.w-80 { width: 80%; }
.sk-line.w-60 { width: 60%; }
.sk-line.w-40 { width: 40%; }
.sk-block { height: 40px; width: 100%; }
.sk-avatar { width: 36px; height: 36px; border-radius: 50%; }
.sk-card  { height: 80px; width: 100%; border-radius: var(--r-md); }

/* Fila de skeleton en tabla */
.sk-row td { padding: 12px 14px; }

/* ── Sidebar — usuario con avatar ───────────────────────────── */
.sidebar-user {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  color: #060B18;
  flex-shrink: 0;
  letter-spacing: .5px;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: .78rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.user-role { font-size: .66rem; color: var(--text-3); margin-top: 1px; }

.pdf-count-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #060B18;
  font-size: .62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  min-width: 20px;
  text-align: center;
  opacity: 0;
  transition: opacity .3s;
  flex-shrink: 0;
}
.pdf-count-badge.visible { opacity: 1; }

/* Indicador activo animado — barra izquierda */
.nav-item { position: relative; }

.nav-item.active {
  background: rgba(0,200,255,.12);
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 65%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  animation: barIn .2s ease forwards;
}

@keyframes barIn {
  from { height: 0; opacity: 0; }
  to   { height: 65%; opacity: 1; }
}

/* ── Modal PDF inline ───────────────────────────────────────── */
.pdf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .2s ease;
}

.pdf-modal-overlay.open { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.pdf-modal {
  background: var(--bg-2);
  border: 1px solid rgba(0, 200, 255, .18);
  border-radius: var(--r-lg);
  width: 100%; max-width: 920px;
  height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .65);
  overflow: hidden;
  animation: slideUp .25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.pdf-modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}

.pdf-modal-title {
  font-size: .875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.pdf-modal-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.pdf-modal-close {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  padding: 5px 14px;
  cursor: pointer;
  font-size: .8rem;
  font-family: inherit;
  transition: color .15s, background .15s;
}
.pdf-modal-close:hover { background: rgba(239,68,68,.15); color: var(--error); border-color: var(--error); }

.pdf-modal-body { flex: 1; overflow: hidden; background: #1a1a2e; }
.pdf-modal-body iframe { width: 100%; height: 100%; border: none; }
