/* assets/css/app.css */
:root {
  --primary:    #1e3a5f;
  --primary-lt: #2d5f9e;
  --accent:     #e8a020;
  --success:    #28a745;
  --warning:    #ffc107;
  --danger:     #dc3545;
  --light:      #f8f9fa;
  --border:     #dee2e6;
  --text:       #212529;
  --muted:      #6c757d;
  --sidebar-w:  240px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #eef1f5;
  min-height: 100vh;
  display: flex;
}

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

.sidebar-logo {
  padding: 20px 18px 16px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo span { color: var(--accent); }

.sidebar-section {
  padding: 10px 0 4px 18px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.45);
  margin-top: 8px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 13.5px;
  transition: background .15s, border-color .15s;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255,255,255,.1);
  border-left-color: var(--accent);
  color: #fff;
}
.sidebar nav a svg { flex-shrink: 0; opacity: .75; }

.sidebar-bottom {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 12px;
  color: rgba(255,255,255,.55);
}
.sidebar-bottom a { color: rgba(255,255,255,.7); text-decoration: none; }
.sidebar-bottom a:hover { color: #fff; }

/* ── Main layout ────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 600; color: var(--primary); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

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

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Stats grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  border-top: 3px solid var(--primary);
}
.stat-card.green  { border-top-color: var(--success); }
.stat-card.yellow { border-top-color: var(--warning); }
.stat-card.red    { border-top-color: var(--danger);  }
.stat-card.orange { border-top-color: var(--accent);  }
.stat-value { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Tablas ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--light);
  border-bottom: 2px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:hover td { background: #f5f8ff; }

/* ── Botones ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .87; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary  { background: var(--primary);   color: #fff; }
.btn-accent   { background: var(--accent);    color: #fff; }
.btn-success  { background: var(--success);   color: #fff; }
.btn-danger   { background: var(--danger);    color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }

/* ── Formularios ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 13px; }
.form-control {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-lt);
  box-shadow: 0 0 0 3px rgba(45,95,158,.15);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Badges / pills ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green   { background: #d4edda; color: #155724; }
.badge-yellow  { background: #fff3cd; color: #856404; }
.badge-red     { background: #f8d7da; color: #721c24; }
.badge-blue    { background: #cce5ff; color: #004085; }
.badge-grey    { background: #e2e3e5; color: #383d41; }

/* ── Barra de progreso ───────────────────────────────────── */
.progress-bar-wrap {
  background: #e9ecef;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  min-width: 80px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s;
}
.progress-bar-fill.green  { background: var(--success); }
.progress-bar-fill.yellow { background: var(--warning); }
.progress-bar-fill.red    { background: var(--danger);  }

/* ── Alertas ─────────────────────────────────────────────── */
.alert {
  padding: 11px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Login page ─────────────────────────────────────────── */
/* ── Login: two-column layout ───────────────────────────── */
.login-wrap {
  display: flex;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
}

/* Left: image panel */
.login-image-panel {
  flex: 1 1 60%;
  position: relative;
  overflow: hidden;
}
.login-image-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.login-image-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(30,58,95,.50) 0%, rgba(20,40,70,.30) 100%);
  display: flex;
  align-items: flex-end;
  padding: 48px;
}
.login-image-tagline {
  color: #fff;
}
.login-image-logo {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}
.login-image-logo span { color: var(--accent); }
.login-image-tagline p {
  font-size: 15px;
  opacity: .88;
  line-height: 1.6;
  margin: 0;
}

/* Right: form panel */
.login-form-panel {
  flex: 0 0 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f6f9;
  padding: 32px 24px;
  overflow-y: auto;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 40px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
}
.login-logo {
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}
.login-logo span { color: var(--accent); }

@media (max-width: 768px) {
  .login-image-panel { display: none; }
  .login-form-panel  { flex: 1; background: linear-gradient(135deg, var(--primary) 0%, #2a6496 100%); }
  .login-card        { box-shadow: 0 10px 30px rgba(0,0,0,.25); }
}

/* ── Misc helpers ───────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.mb-3  { margin-bottom: 24px; }
.mt-2  { margin-top: 16px; }
.mt-3  { margin-top: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.flex-between { justify-content: space-between; }
.w-100 { width: 100%; }

/* ── Paginación ─────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  justify-content: flex-end;
}
.pagination a, .pagination span {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  text-decoration: none;
  color: var(--primary);
}
.pagination a:hover { background: var(--light); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Hamburger button ────────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
}
.hamburger:hover { background: var(--light); }
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

/* Topbar left group */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* Sidebar transition */
.sidebar {
  transition: transform .25s ease;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar: hidden off-canvas by default */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }

  /* Main layout: full width */
  .main-wrap { margin-left: 0; }

  /* Topbar */
  .topbar { padding: 0 16px; }
  .hamburger { display: flex; }
  .topbar-username { display: none; }

  /* Content */
  .content { padding: 14px; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Tables: scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* Cards / grids used in various modules */
  .card-grid,
  .areas-grid,
  .kpis-grid { grid-template-columns: 1fr; }

  /* Dashboard charts */
  .dash-grid,
  .dash-row { grid-template-columns: 1fr; }

  /* Modals */
  .modal-box {
    width: calc(100vw - 32px);
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Buttons: stack on mobile if in a group */
  .btn-group {
    flex-direction: column;
    align-items: stretch;
  }

  /* Filters bar */
  .filters, .filter-bar {
    flex-direction: column;
    gap: 8px;
  }
  .filters select,
  .filters input,
  .filter-bar select,
  .filter-bar input {
    width: 100%;
  }
}
