:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-color: #1e293b;
  --border-color: #e2e8f0;
  --error-color: #ef4444;
  --success-color: #22c55e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  min-height: 100vh;
}

/* Auth Layout (Login) */
.login-container {
  margin: auto;
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-color);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary-color);
}

.btn-primary {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.alert-error {
  background-color: #fee2e2;
  color: var(--error-color);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}

/* Dashboard Layout */
.dashboard-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  background-color: #0f172a;
  color: white;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow-y: auto;
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: bold;
  color: #38bdf8;
  margin-bottom: 2rem;
}

.sidebar-menu {
  list-style: none;
  flex: 1;
}

.sidebar-menu li a {
  display: block;
  color: #94a3b8;
  padding: 0.75rem 1rem;
  text-decoration: none;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.sidebar-menu li a.active,
.sidebar-menu li a:hover {
  background-color: #1e293b;
  color: white;
}

.main-content {
  flex: 1;
  padding: 2rem;
  height: 100vh;
  overflow-y: auto;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-color);
  margin: -2rem -2rem 2rem -2rem;
}

.user-badge {
  font-size: 0.875rem;
  font-weight: 600;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--error-color);
  color: var(--error-color);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
}

.btn-logout:hover {
  background: var(--error-color);
  color: white;
}

.card {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

/* Tablas */
.table-container {
  overflow-x: auto;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.data-table th {
  background-color: #f1f5f9;
  font-weight: 600;
}

.badge {
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }

/* Modal Formulario */
.modal-overlay {
  padding: 1rem;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  max-height: 90vh;
  overflow-y: auto;
  background: white;
  padding: 2rem;
  border-radius: 10px;
  width: 100%;
  max-width: 550px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.btn-secondary {
  background-color: #64748b;
  color: white;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn-action {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  margin-right: 0.3rem;
}
.btn-edit { background: #f59e0b; color: white; }
.btn-toggle { background: #64748b; color: white; }

/* =====================================================================
   MENÚ LATERAL AGRUPADO
   ===================================================================== */
.sidebar-group-title {
  list-style: none;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin: 1.1rem 0 0.4rem 0.75rem;
}
.sidebar-toggle { display: none; }

/* =====================================================================
   RESPONSIVE (celular / tablet)
   El menú de la izquierda pasa a ser una barra fija arriba con un botón
   "☰ Menú" que despliega los módulos; el contenido ocupa todo el ancho.
   ===================================================================== */
@media (max-width: 768px) {
  body { display: block; }

  .dashboard-layout {
    flex-direction: column;
    width: 100%;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 900;
    padding: 0.6rem 1rem;
    flex-direction: column;
    overflow: visible;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    font-size: 1.05rem;
  }

  .sidebar-toggle {
    display: inline-flex;
    background: #1e293b;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 0.45rem 0.85rem;
    font-size: 0.9rem;
    cursor: pointer;
  }

  .sidebar-menu {
    display: none;
    margin-top: 0.6rem;
    max-height: 70vh;
    overflow-y: auto;
    flex: none;
  }
  .sidebar.abierto .sidebar-menu { display: block; }

  .sidebar-menu li a {
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
  }

  .main-content {
    width: 100%;
    min-width: 0;
    height: auto;
    overflow-y: visible;
    padding: 1rem;
  }

  .navbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin: -1rem -1rem 1.25rem -1rem;
    padding: 1rem;
  }
  .navbar h2 { font-size: 1.15rem; }
  .navbar > div { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; width: 100%; }
  .navbar > div .btn-logout { margin-left: 0 !important; }

  .card { padding: 1rem; overflow-x: auto; }

  /* Inputs con ancho fijo en línea: que nunca se pasen del ancho de la pantalla */
  .main-content input[style*="width"],
  .main-content select[style*="width"] { max-width: 100%; }

  .modal-grid { grid-template-columns: 1fr; }
  .modal-card { width: 100%; padding: 1.25rem; }
  .login-container { padding: 1.75rem 1.25rem; margin: 1rem; }

  .data-table th, .data-table td { padding: 0.6rem 0.7rem; font-size: 0.82rem; }

  /* Lista de empleados: ocultar CUIL y Email para que entre en el celular */
  .tabla-emp th:nth-child(3), .tabla-emp td:nth-child(3),
  .tabla-emp th:nth-child(4), .tabla-emp td:nth-child(4) { display: none; }
}

/* Formulario de alta/edición de empleado: los botones quedan siempre a la vista */
#form-empleado > div:last-child {
  position: sticky;
  bottom: 0;
  background: #ffffff;
  padding-top: 0.9rem;
  margin-top: 1rem !important;
  border-top: 1px solid #e2e8f0;
}

@media (max-width: 768px) {
  /* Lista de empleados en celular: también se oculta el Rol */
  .tabla-emp th:nth-child(6), .tabla-emp td:nth-child(6) { display: none; }
}

#modal-empleado .modal-card { padding-bottom: 0; }
#form-empleado > div:last-child { padding-bottom: 1.2rem; }

/* Título "Portal RRHH" como enlace al inicio: mismo aspecto que antes */
.sidebar-brand-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.sidebar-brand-link:hover { text-decoration: underline; }
@media (max-width: 768px) {
  .sidebar-brand-link { display: inline-block; padding: 0.35rem 0.5rem 0.35rem 0; }
}
