/* ══════════════════════════════════════════════════════════════════════════
   ClimaPro — Sistema de gestión para empresa de climatización
   CSS Principal — Design System completo
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Variables globales (sobreescritas desde el template según empresa) ─── */
:root {
  --color-primary: #1A6EBD;
  --color-sidebar: #0D2137;
  --color-accent: #00C9E4;

  /* Derivados calculados */
  --color-primary-dark: color-mix(in srgb, var(--color-primary) 80%, black);
  --color-primary-light: color-mix(in srgb, var(--color-primary) 15%, white);
  --color-accent-glow: color-mix(in srgb, var(--color-accent) 30%, transparent);

  /* Neutros */
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E2E8F0;
  --border-dark: #CBD5E1;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;

  /* Estados */
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;

  /* Dimensiones del sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 64px;

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.08);

  /* Radios */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transiciones */
  --transition: 200ms ease;
  --transition-slow: 350ms cubic-bezier(.4,0,.2,1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width var(--transition-slow), transform var(--transition-slow);
  overflow: hidden;
}

/* Brand / Logo */
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 80px;
  display: flex;
  align-items: center;
}

.sidebar-logo {
  max-height: 48px;
  max-width: 200px;
  object-fit: contain;
}

.sidebar-logo-text {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
}

.sidebar-logo-text i {
  font-size: 1.6rem;
  color: var(--color-accent);
}

/* Menú */
.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-divider {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 14px 8px 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.75);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  margin-bottom: 2px;
  text-decoration: none;
}

.sidebar-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}

.sidebar-item.active {
  background: linear-gradient(135deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 70%, var(--color-accent)));
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.sidebar-item i {
  font-size: 1.1rem;
  min-width: 20px;
  text-align: center;
}

/* Footer del sidebar */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-top: 4px;
}

.sidebar-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout {
  font-size: 0.75rem;
  color: rgba(255,255,255,.45);
  text-decoration: none;
  transition: color var(--transition);
}

.sidebar-logout:hover { color: var(--danger); text-decoration: none; }

/* ══════════════════════════════════════════════════════════════════════════
   CONTENIDO PRINCIPAL
   ══════════════════════════════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: none;
}

.topbar-toggle:hover { background: var(--bg); color: var(--color-primary); }

.topbar-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Contenido de página */
.page-content {
  flex: 1;
  padding: 28px;
}

/* ══════════════════════════════════════════════════════════════════════════
   CARDS Y MÉTRICAS
   ══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { color: var(--color-primary); }

.card-body { padding: 20px 24px; }

/* Metric cards (dashboard) */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: all var(--transition);
  cursor: default;
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.metric-icon.primary { background: var(--color-primary-light); color: var(--color-primary); }
.metric-icon.success { background: #dcfce7; color: var(--success); }
.metric-icon.warning { background: #fef9c3; color: var(--warning); }
.metric-icon.danger  { background: #fee2e2; color: var(--danger); }
.metric-icon.info    { background: #dbeafe; color: var(--info); }
.metric-icon.accent  { background: color-mix(in srgb, var(--color-accent) 15%, white); color: var(--color-accent); }

.metric-info { min-width: 0; }

.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-family: 'JetBrains Mono', monospace;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 3px;
}

/* ══════════════════════════════════════════════════════════════════════════
   BOTONES
   ══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--color-primary) 40%, transparent);
}

.btn-accent {
  background: var(--color-accent);
  color: var(--color-sidebar);
  border-color: var(--color-accent);
  font-weight: 700;
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

/* ══════════════════════════════════════════════════════════════════════════
   TABLAS
   ══════════════════════════════════════════════════════════════════════════ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

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

.table th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ══════════════════════════════════════════════════════════════════════════
   FORMULARIOS
   ══════════════════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: all var(--transition);
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ══════════════════════════════════════════════════════════════════════════
   BADGES / ETIQUETAS DE ESTADO
   ══════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-muted   { background: var(--bg); color: var(--text-secondary); }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }

/* ══════════════════════════════════════════════════════════════════════════
   ALERTAS FLASH
   ══════════════════════════════════════════════════════════════════════════ */
.messages-container { padding: 0 28px; margin-top: 16px; }

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 10px;
  animation: slideDown .3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

.alert-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: .6;
  color: inherit;
  padding: 0 4px;
}
.alert-close:hover { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════════════
   PÁGINA DE LOGIN
   ══════════════════════════════════════════════════════════════════════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-sidebar) 0%, color-mix(in srgb, var(--color-primary) 60%, #000) 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp .5s ease;
}

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

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  margin: 0 auto 14px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--color-primary) 40%, transparent);
}

.login-brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.login-brand-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ══════════════════════════════════════════════════════════════════════════
   UTILIDADES
   ══════════════════════════════════════════════════════════════════════════ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }

.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.text-muted    { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-danger   { color: var(--danger); }
.text-sm       { font-size: 0.82rem; }
.text-xs       { font-size: 0.72rem; }
.font-mono     { font-family: 'JetBrains Mono', monospace; }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }

.w-full  { width: 100%; }
.hidden  { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-content {
    margin-left: 0;
    min-width: 0;
  }
  .topbar {
    padding: 0 12px;
    gap: 8px;
    height: 56px;
    overflow: hidden;
  }
  .topbar-toggle { display: flex; }
  .topbar-title {
    font-size: 0.95rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-actions {
    gap: 4px;
    flex-shrink: 0;
  }
  .hide-mobile { display: none !important; }
  .page-content { padding: 12px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* Adaptación de jornada y tablas en móvil */
  .jornada-header {
    padding: 14px;
    gap: 12px;
    flex-direction: column;
    align-items: stretch;
  }
  .jornada-header > div {
    width: 100%;
  }
  .jornada-header .stat-chip {
    padding: 4px 10px;
    font-size: 0.75rem;
  }
  .work-card-header {
    padding: 12px 14px;
    font-size: 0.88rem;
    flex-wrap: wrap;
    gap: 8px;
  }
  .work-row {
    padding: 12px 14px;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .work-actions {
    justify-content: flex-start;
    width: 100%;
    margin-top: 4px;
  }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .btn-sm { padding: 5px 8px; font-size: 0.75rem; }
  .jornada-header h3 { font-size: 1.1rem; }
}

/* Overlay para mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
.sidebar-overlay.active { display: block; }

