@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg: #F1F5F9;
  --sidebar: #0F172A;
  --sidebar-border: #1E293B;
  --accent: #F97316;
  --accent-dark: #EA580C;
  --white: #ffffff;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --card-shadow: 0 1px 6px rgba(0,0,0,.07);
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: 'Inter', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.sidebar {
  width: 240px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

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

.sidebar-logo .brand {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: .03em;
}

.sidebar-logo .brand span {
  color: var(--accent);
}

.sidebar-logo .sub {
  font-size: 11px;
  color: #475569;
  margin-top: 2px;
}

.sidebar nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 0 8px;
  margin: 16px 0 6px;
}

.nav-section:first-child { margin-top: 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #94A3B8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}

.nav-link:hover { color: #CBD5E1; background: rgba(255,255,255,.04); }

.nav-link.active {
  color: var(--accent);
  background: rgba(249,115,22,.1);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-link svg { flex-shrink: 0; }

.nav-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user .info .name {
  font-size: 13px;
  font-weight: 600;
  color: #E2E8F0;
}

.sidebar-user .info .email {
  font-size: 11px;
  color: #475569;
}

.logout-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: #64748B;
  text-decoration: none;
  font-size: 13px;
  transition: color .15s, background .15s;
}

.logout-link:hover { color: #EF4444; background: rgba(239,68,68,.06); }

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

.topbar {
  background: var(--sidebar);
  border-bottom: 1px solid var(--sidebar-border);
  border-top: 3px solid var(--accent);
  padding: 0 28px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.topbar-text {
  font-size: 12px;
  color: #475569;
}

.topbar-badge {
  font-size: 11px;
  background: rgba(249,115,22,.15);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 9999px;
  font-weight: 700;
}

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

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.page-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  transition: color .15s;
}

.back-link:hover { color: var(--text); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: none;
  font-family: 'Inter', sans-serif;
  transition: opacity .15s, transform .1s;
}

.btn:hover { opacity: .9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(249,115,22,.35);
}

.btn-dark {
  background: var(--sidebar);
  color: white;
}

.btn-outline {
  background: white;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.btn-danger {
  background: #FEF2F2;
  color: #EF4444;
  border: 1.5px solid #FECACA;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  box-shadow: var(--card-shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stat-card .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card .icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Tables ── */
.table-wrap {
  background: white;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .07em;
  text-align: left;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 13px 16px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAFA; }

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

.action-icon {
  width: 12px;
  height: 12px;
  object-fit: contain;
  flex-shrink: 0;
}

.btn-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
}

.action-edit {
  background: rgba(99,102,241,.1);
  color: #6366F1;
}

.action-edit:hover { background: rgba(99,102,241,.18); }

.action-delete {
  background: rgba(239,68,68,.08);
  color: #EF4444;
}

.action-delete:hover { background: rgba(239,68,68,.15); }

.action-view {
  background: rgba(16,185,129,.1);
  color: #10B981;
}

.action-view:hover { background: rgba(16,185,129,.18); }

.action-confirm {
  background: rgba(249,115,22,.1);
  color: var(--accent);
}

.action-confirm:hover { background: rgba(249,115,22,.18); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-green  { background: rgba(16,185,129,.12); color: #10B981; }
.badge-orange { background: rgba(249,115,22,.12);  color: #F97316; }
.badge-gray   { background: rgba(148,163,184,.12); color: #64748B; }
.badge-red    { background: rgba(239,68,68,.1);    color: #EF4444; }
.badge-blue   { background: rgba(99,102,241,.12);  color: #6366F1; }

/* ── Forms ── */
.form-card {
  background: white;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 28px;
  max-width: 600px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249,115,22,.1);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Alert ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 20px;
}

.alert-error {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  color: #B91C1C;
}

.alert-success {
  background: rgba(16,185,129,.08);
  border: 1px solid rgba(16,185,129,.2);
  color: #065F46;
}

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  background: #0F172A;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(249,115,22,.07), transparent 70%);
  pointer-events: none;
}

.login-field-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .04;
  pointer-events: none;
}

.login-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
}

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

.login-brand .logo {
  font-size: 32px;
  font-weight: 800;
  color: white;
  letter-spacing: -.01em;
}

.login-brand .logo span { color: var(--accent); }

.login-brand .tagline {
  font-size: 12px;
  color: #475569;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.login-tabs {
  display: flex;
  background: #1E293B;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
}

.login-tab {
  flex: 1;
  padding: 13px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: #475569;
  transition: background .2s, color .2s;
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
}

.login-tab.active {
  background: #253347;
  color: white;
}

.login-panel {
  background: #1E293B;
  border-radius: 0 0 16px 16px;
  padding: 28px;
  border: 1px solid rgba(255,255,255,.05);
  display: none;
}

.login-panel.active { display: block; }

.login-label {
  font-size: 10px;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 6px;
  display: block;
}

.login-input {
  width: 100%;
  background: #0F172A;
  border: 1.5px solid #334155;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: #E2E8F0;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color .15s;
  margin-bottom: 14px;
}

.login-input:focus {
  border-color: var(--accent);
}

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: .1em;
  box-shadow: 0 4px 18px rgba(249,115,22,.42);
  transition: opacity .15s;
  margin-top: 4px;
}

.login-btn:hover { opacity: .9; }

.login-alert {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: #FCA5A5;
  margin-bottom: 16px;
}

.login-success {
  background: rgba(16,185,129,.1);
  border: 1px solid rgba(16,185,129,.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: #6EE7B7;
  margin-bottom: 16px;
}

/* ── Panel cards ── */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.panel-card {
  background: white;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 24px 20px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  box-shadow: var(--card-shadow);
}

.panel-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(249,115,22,.15);
  transform: translateY(-2px);
}

.panel-card .icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.panel-card .card-label {
  font-size: 15px;
  font-weight: 700;
}

.panel-card .card-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Botón de menú móvil (oculto en escritorio) ── */
.menu-toggle { display: none; }
.nav-overlay { display: none; }

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

  /* Sidebar como panel deslizable, más ancho y con textos más grandes */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: min(84vw, 300px);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-logo { padding: 22px 20px; }
  .sidebar-logo .brand { font-size: 20px; }
  .sidebar-logo .sub { font-size: 12px; }

  nav { padding: 18px 12px; }
  .nav-section { font-size: 11px; margin: 18px 0 8px; }
  .nav-link {
    font-size: 16px;
    padding: 14px 14px;
    gap: 14px;
    margin-bottom: 4px;
  }
  .nav-link svg { width: 20px; height: 20px; }
  .nav-icon { width: 20px; height: 20px; }

  .sidebar-footer { padding: 16px 12px; }
  .avatar { width: 40px; height: 40px; font-size: 14px; }
  .sidebar-user { padding: 10px; }
  .sidebar-user .info .name { font-size: 15px; }
  .sidebar-user .info .email { font-size: 12px; }
  .logout-link { font-size: 15px; padding: 12px 10px; gap: 12px; }
  .logout-link svg { width: 18px; height: 18px; }

  .main { margin-left: 0; }
  .page { padding: 18px 14px; }

  /* Fondo oscuro detrás del menú abierto */
  .nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 250;
  }
  .nav-overlay.show { display: block; }

  /* Botón hamburguesa integrado arriba, dentro de la barra superior oscura */
  .menu-toggle {
    display: flex;
    position: fixed;
    top: 7px;
    left: 12px;
    z-index: 310;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    color: white;
    border: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .menu-toggle svg { width: 20px; height: 20px; }

  /* Le hace lugar al botón dentro de la topbar de cada página */
  .topbar { padding-left: 54px !important; padding-right: 16px !important; }

  /* Tablas con scroll horizontal en vez de aplastarse */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }

  /* Formularios y cabeceras en una columna */
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }
  .form-card { padding: 20px 16px; }

  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Acciones de formulario apiladas */
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; justify-content: center; }
}
