/* ========== RESET & BASE MOBILE ========== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f7f8fa;
  color: #222;
  line-height: 1.6;
}

/* Containers */
.container, .page-content {
  padding: 1rem;
}

/* Utility */
h1, h2, h3 {
  color: #1a59ff;
  margin: 0 0 0.8rem;
}

/* ========== LAYOUT ========== */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Sidebar (mobile drawer) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 15rem;
  height: 100vh;
  background: #1a59ff;
  color: #fff;
  transform: translateX(-100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
  padding: 1.5rem 1rem;
}

.sidebar.open {
  transform: translateX(0);
  opacity: 1;
}

.sidebar h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar nav a {
  color: #fff;
  text-decoration: none;
  padding: 0.8rem 1rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: background 0.2s ease;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255,255,255,0.25);
}

/* Overlay when menu open */
body.menu-open::before {
  content: "";
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 500;
}

/* Header (mobile topbar) */
.main-header {
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 900;
}

.menu-toggle {
  background: none;
  border: none;
  color: #1a59ff;
  font-size: 2rem;
  cursor: pointer;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.logout-btn {
  background: #ff4757;
  color: #fff;
  border: none;
  padding: 0.5rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  text-decoration: none;
}

/* Main content */
.main-content {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ========== BUTTONS & FORMS ========== */
.btn, button {
  background: #1a59ff;
  color: #fff;
  border: none;
  border-radius: 0.6rem;
  padding: 1rem;
  font-size: 1rem;
  text-align: center;
  width: 100%;
  cursor: pointer;
  transition: background 0.2s;
}
.btn:hover, button:hover {
  background: #0046ff;
}

input, select, textarea {
  width: 100%;
  padding: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  font-size: 1rem;
  margin: 0.5rem 0 1rem;
  background: #fff;
}

/* ========== LOGIN PAGE ========== */
.login-body {
  background: #1a59ff;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 1rem;
}

.login-box {
  background: #fff;
  border-radius: 1rem;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}

.login-box h2 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

.error {
  color: #ff4757;
  margin-bottom: 0.5rem;
}

/* ========== DASHBOARD CARDS ========== */
.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card {
  background: #fff;
  border-radius: 0.8rem;
  padding: 1.2rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.card h3 {
  font-size: 1.1rem;
  color: #1a59ff;
}

.card .number {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0.6rem 0;
}

.card small {
  color: #666;
  font-size: 0.9rem;
}

.card.wide {
  overflow-x: auto;
}

/* ========== TABLES ========== */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 0.8rem;
  overflow: hidden;
  font-size: 1rem;
}

th, td {
  padding: 0.9rem;
  border-bottom: 1px solid #eee;
  text-align: left;
}

th {
  background: #f4f6fc;
  font-weight: 600;
}

/* ========== RESPONSIVE UPGRADES ========== */

/* Tablets (>=600px) */
@media (min-width: 600px) {
  html { font-size: 16px; }

  .cards-grid {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .card {
    flex: 1;
    min-width: 45%;
  }

  .btn, button {
    width: auto;
    display: inline-block;
  }

  .sidebar {
    width: 17rem;
  }
}

/* Desktop (>=1024px) */
@media (min-width: 1024px) {
  html { font-size: 15px; }

  .layout {
    flex-direction: row;
  }

  .sidebar {
    position: static;
    transform: none;
    opacity: 1;
    height: auto;
    min-height: 100vh;
  }

  .menu-toggle {
    display: none;
  }

  .main-content {
    padding-left: 0;
  }

  .cards-grid {
    flex-wrap: wrap;
    flex-direction: row;
    gap: 1.5rem;
  }

  .card {
    min-width: 200px;
  }

  .container, .page-content {
    padding: 2rem;
  }
}



/* === Header fix === */
.main-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: #fff;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.user-info {
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* === Sidebar animation & close button === */
.sidebar {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.sidebar .close-menu {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 80%;
    max-width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    opacity: 0;
    background: #1a59ff;
    padding: 1.5rem 1rem;
    box-shadow: 3px 0 10px rgba(0,0,0,0.3);
  }

  .sidebar.open {
    transform: translateX(0);
    opacity: 1;
  }

  .sidebar .close-menu {
    display: block;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.8rem;
    position: absolute;
    top: 0.8rem;
    right: 1rem;
    cursor: pointer;
  }

  body.menu-open::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 500;
  }
}

/* === Formulario Moderno === */
.form-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  max-width: 650px;
  margin: 0 auto;
}

.form-card h2 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  color: #1a59ff;
}

.form-card .subtitle {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1.5rem;
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.form-group {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
}

.form-group.full {
  flex-basis: 100%;
}

label {
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: #333;
}

input, select, textarea {
  padding: 0.8rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1a59ff;
  box-shadow: 0 0 0 2px rgba(26, 89, 255, 0.2);
}

/* Acciones */
.form-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  gap: 1rem;
}

.btn-primary {
  background: #1a59ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
}

.btn-primary:hover {
  background: #0046ff;
}

.btn-secondary {
  background: #e5e5e5;
  color: #333;
  text-decoration: none;
  border-radius: 8px;
  padding: 0.9rem 1.5rem;
  text-align: center;
  width: 100%;
}

.btn-secondary:hover {
  background: #d8d8d8;
}

/* === Responsivo === */
@media (min-width: 600px) {
  .form-group {
    flex: 1 1 calc(50% - 1rem);
  }

  .form-group.full {
    flex-basis: 100%;
  }

  .form-actions {
    justify-content: flex-end;
  }

  .btn-primary, .btn-secondary {
    width: auto;
  }
}

/* === Tablas Responsivas === */
.table-wrapper {
  width: 100%;
  overflow-x: auto;        /* 🔹 Permite desplazamiento horizontal */
  -webkit-overflow-scrolling: touch; /* 🔹 Deslizamiento suave en iOS */
  margin-top: 1rem;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.table-wrapper::-webkit-scrollbar {
  height: 8px;
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
}

.table-responsive {
  width: 100%;
  border-collapse: collapse;
  min-width: 650px; /* 🔹 evita que se corte en pantallas pequeñas */
}

.table-responsive th,
.table-responsive td {
  padding: 0.8rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
  white-space: nowrap; /* 🔹 evita saltos de línea raros */
}

.table-responsive th {
  background: #f4f6fc;
  font-weight: 600;
  color: #333;
}

.table-responsive td a {
  margin: 0 3px;
  font-size: 1.2rem;
  text-decoration: none;
}

.table-responsive td a:hover {
  opacity: 0.8;
}

/* === Mejoras móviles === */
@media (max-width: 600px) {
  .table-responsive {
    font-size: 1rem;
    min-width: 720px; /* 🔹 fuerza scroll lateral en pantallas pequeñas */
  }

  .table-wrapper {
    border-radius: 0.5rem;
  }

  .table-responsive td a {
    font-size: 1.5rem; /* 👆 botones más grandes y cómodos */
    padding: 0.2rem;
  }

  .table-responsive th, .table-responsive td {
    padding: 0.9rem 0.7rem;
  }
}



