/* app.css - Variables CSS + Layout mobile-first */
:root {
  --color-primary: #1565C0;
  --color-primary-dark: #0D47A1;
  --color-primary-light: #BBDEFB;
  --color-ok: #2E7D32;
  --color-warning: #F57C00;
  --color-danger: #D32F2F;
  --color-info: #1565C0;
  --color-fase-incidencia: #D32F2F;
  --color-fase-ok: #2E7D32;
  --color-fase-default: #616161;
  --banner-critico: #D32F2F;
  --banner-alto: #F57C00;
  --banner-medio: #1565C0;
  --banner-bajo: #2E7D32;
  --cat-urgente: #D32F2F;
  --cat-sin-respuesta: #F57C00;
  --cat-documentacion: #1565C0;
  --cat-estancadas: #7B1FA2;
  --bg-primary: #FFFFFF;
  --bg-secondary: #F5F5F5;
  --bg-card-alert: #FFF3E0;
  --text-primary: #000000;
  --text-secondary: #424242;
  --radius: 8px;
  --shadow: 0 2px 4px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 17.6px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-primary);
  color: white;
  padding: 12px 16px;
  padding-top: calc(env(safe-area-inset-top, 28px) + 12px);
}

.header-title { font-size: 20px; font-weight: bold; }

/* Busqueda */
.search-bar {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 4px;
  padding: 2px 8px;
  margin: 2px 6px;
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 12px;
  min-height: 24px;
}

/* Filtros rapidos */
.filtros-rapidos {
  display: flex;
  gap: 4px;
  padding: 2px 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--color-primary);
  background: white;
  color: var(--color-primary);
  min-height: 22px;
  min-width: 28px;
  white-space: nowrap;
  cursor: pointer;
}

.chip.activo {
  background: var(--color-primary);
  color: white;
}

.chip .badge {
  background: var(--color-danger);
  color: white;
  border-radius: 8px;
  padding: 1px 5px;
  font-size: 10px;
  margin-left: 3px;
}

/* Contenido principal */
.contenido {
  flex: 1;
  overflow-y: auto;
  padding: 2px 6px 52px;
  -webkit-overflow-scrolling: touch;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: white;
  border-top: 1px solid #E0E0E0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  min-height: 44px;
  justify-content: center;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 10px;
  position: relative;
  cursor: pointer;
}

.bottom-nav-item span:first-child {
  font-size: 16px !important;
}

.bottom-nav-item.activo { color: var(--color-primary); }

.bottom-nav-item .nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 20px);
  background: var(--color-danger);
  color: white;
  border-radius: 10px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: bold;
}

/* Bottom bar acciones */
.bottom-bar {
  position: fixed;
  bottom: 56px;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #E0E0E0;
  z-index: 90;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  min-height: 36px;
  min-width: 36px;
  cursor: pointer;
  text-transform: uppercase;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-success {
  background: var(--color-ok);
  color: white;
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
}

.btn:disabled { opacity: 0.5; }

.btn-flex { flex: 1; }

/* Bottom Sheet */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
}

.bottom-sheet-overlay.visible { display: block; }

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  z-index: 201;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.bottom-sheet.visible { transform: translateY(0); }

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: #CCC;
  border-radius: 2px;
  margin: 0 auto 16px;
}

.bottom-sheet-titulo {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 16px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 120px;
  left: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

.toast-exito { background: var(--color-ok); }
.toast-error { background: var(--color-danger); }
.toast-info { background: var(--color-info); }

.toast-deshacer {
  background: transparent;
  border: 1px solid white;
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  min-height: 36px;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Secciones colapsables */
.seccion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #E0E0E0;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  min-height: 48px;
}

.seccion-contenido {
  padding: 8px 0;
  display: none;
}

.seccion-contenido.abierta { display: block; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #E0E0E0 25%, #F5F5F5 50%, #E0E0E0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-card {
  height: 120px;
  margin-bottom: 12px;
}

/* Utilidades */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.p-16 { padding: 16px; }

/* App layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Responsive tablet */
@media (min-width: 640px) and (max-width: 1024px) {
  .app-split {
    display: flex;
    flex-direction: row;
  }
  .app-split .panel-lista { width: 40%; border-right: 1px solid #E0E0E0; }
  .app-split .panel-detalle { flex: 1; }
}
