/* =============================================
   TEMA CLARO / OSCURO — CSS CUSTOM PROPERTIES
   ============================================= */

:root {
  --bg-page: #ffffff;
  --bg-surface: rgba(255,255,255,0.85);
  --bg-elevated: rgba(255,255,255,0.95);
  --bg-input: white;
  --bg-table-row: rgba(255,255,255,0.5);
  --bg-table-hover: rgba(26,26,46,0.06);
  --bg-table-stripe: rgba(26,26,46,0.03);

  --text-primary: rgba(26,26,46,0.95);
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  --border-light: rgba(26,26,46,0.08);
  --border-medium: rgba(26,26,46,0.12);
  --border-strong: #d1d5db;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 15px rgba(0,0,0,0.12);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.2);
  --shadow-card: 0 4px 15px rgba(0,0,0,0.08);

  --table-header-bg: rgba(26,26,46,0.12);
  --table-header-text: rgba(26,26,46,0.95);

  --scrollbar-thumb: rgba(26,26,46,0.2);
  --scrollbar-track: transparent;

  --drawer-bg: rgba(255,255,255,0.82);
  --drawer-header-border: rgba(0,0,0,0.08);
  --drawer-input-bg: rgba(255,255,255,0.8);

  --toast-bg: rgba(255,255,255,0.90);
  --toast-text: rgba(26,26,46,0.95);
  --toast-border: rgba(26,26,46,0.12);

  --accent-yellow: #facc15;
  --accent-yellow-hover: #fbbf24;
  --accent-blue: #4a90e2;
  --accent-red: #ef4444;
  --accent-green: #22c55e;
  --accent-orange: #e67e22;
}

[data-theme="dark"] {
  --bg-page: #13132a;
  --bg-surface: rgba(25,25,45,0.88);
  --bg-elevated: rgba(35,35,55,0.92);
  --bg-input: rgba(45,45,70,0.85);
  --bg-table-row: rgba(25,25,45,0.4);
  --bg-table-hover: rgba(255,255,255,0.06);
  --bg-table-stripe: rgba(255,255,255,0.03);

  --text-primary: rgba(255,255,255,0.9);
  --text-secondary: #9ca3af;
  --text-muted: rgba(156,163,175,0.6);

  --border-light: rgba(255,255,255,0.08);
  --border-medium: rgba(255,255,255,0.12);
  --border-strong: rgba(255,255,255,0.2);

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 15px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
  --shadow-card: 0 4px 15px rgba(0,0,0,0.3);

  --table-header-bg: rgba(0,0,0,0.3);
  --table-header-text: rgba(255,255,255,0.9);

  --scrollbar-thumb: rgba(255,255,255,0.15);
  --scrollbar-track: transparent;

  --drawer-bg: rgba(25,25,45,0.88);
  --drawer-header-border: rgba(255,255,255,0.08);
  --drawer-input-bg: rgba(45,45,70,0.85);

  --toast-bg: rgba(35,35,55,0.92);
  --toast-text: rgba(255,255,255,0.9);
  --toast-border: rgba(255,255,255,0.12);
}

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

body {
  background: var(--bg-page);
  transition: background 0.3s ease;
}

/* ANIMACIONES GENERALES */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ELEMENTOS BASE */
button {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(90deg, #facc15, #fbbf24);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

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

button:active {
  transform: translateY(0);
}

/* INPUTS GENERALES */
.field {
  margin-bottom: 18px;
}

.field label {
  font-size: 13px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  transition: all 0.2s ease;
}

.field input:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
}

.field input::placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

/* SCROLLBAR */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb);
  opacity: 0.8;
}

/* ABM */

/* =========================
   TABLA
========================= */

.table-container {
  width: 100%;
  overflow-x: auto;
  margin-top: 20px;
  padding: 0 30px 30px;
}

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

  background: rgba(255,255,255,0.04);

  border-radius: 16px;
  overflow: hidden;

  backdrop-filter: blur(10px);

  border: 1px solid var(--border-medium);
}

/* =========================
   CABECERA
========================= */

.table thead {
  background: var(--table-header-bg);
}

.table th {
  padding: 16px;

  text-align: left;

  font-weight: 600;

  color: var(--table-header-text);

  border-bottom:
    1px solid var(--border-medium);

  border-right:
    1px solid var(--border-light);
}

.table th[data-sort]::after {
  content: " ↕";
  font-size: 0.7em;
  opacity: 0.3;
  margin-left: 4px;
}

.table th.sort-asc::after {
  content: " ▲";
  opacity: 1;
}

.table th.sort-desc::after {
  content: " ▼";
  opacity: 1;
}

/* =========================
   CELDAS
========================= */

.table td {
  padding: 14px 16px;

  color: var(--text-primary);

  border-bottom:
    1px solid var(--border-light);

  border-right:
    1px solid var(--border-light);
}


/* =========================
   HOVER
========================= */

.table tbody tr:hover {
  background: var(--bg-table-hover);
}

/* =========================
   ESTADOS
========================= */

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 4px 10px;

  border-radius: 999px;

  font-size: 12px;
  font-weight: 600;
}

.status.active {
  background: rgba(0,255,120,0.15);
  color: rgb(0,120,60);
}

.status.inactive {
  background: rgba(255,80,80,0.15);
  color: rgb(180,40,40);
}

/* =========================
   ACCIONES
========================= */

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

/* =========================
   BOTÓN EDITAR
========================= */

.edit-btn {
  border: none;

  padding: 8px 12px;

  border-radius: 10px;

  cursor: pointer;

  font-size: 13px;
  font-weight: 600;

  background: rgba(151, 151, 151,0.2);
  color: rgb(100, 100, 100);

  transition: 0.2s ease;
}

.edit-btn:hover {
  background: rgba(151, 151, 151,0.2);
  transform: translateY(-1px);
}

/* =========================
   BOTÓN ACTIVAR
========================= */

.activate-btn {
  border: none;

  padding: 8px 12px;

  border-radius: 10px;

  cursor: pointer;

  font-size: 13px;
  font-weight: 600;

  background: rgba(0,255,120,0.12);
  color: rgb(0,120,60);

  transition: 0.2s ease;
}

.activate-btn:hover {
  background: rgba(0,255,120,0.20);
  transform: translateY(-1px);
}

.activate-btn:disabled,
.deactivate-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.activate-btn:disabled:hover,
.deactivate-btn:disabled:hover {
  background: inherit;
  transform: none;
}

/* =========================
   BOTÓN DESACTIVAR
========================= */

.deactivate-btn {
  border: none;

  padding: 8px 12px;

  border-radius: 10px;

  cursor: pointer;

  font-size: 13px;
  font-weight: 600;

  background: rgba(255,80,80,0.12);
  color: rgb(180,40,40);

  transition: 0.2s ease;
}

.deactivate-btn:hover {
  background: rgba(255,80,80,0.20);
  transform: translateY(-1px);
}

/* =========================
   BUSCADOR TABLA
========================= */

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 30px;
  margin-top: 20px;
}

.table-search {
  width: 100%;
  max-width: 400px;

  padding: 12px;

  border-radius: 10px;
  border: 1px solid var(--border-medium);

  background: var(--bg-input);

  font-size: 14px;
}

/* =========================
   COLUMN PICKER
========================= */

.column-picker-wrapper {
  position: relative;
  margin-left: auto;
}

.column-picker-btn {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-medium);
  background: var(--bg-input);
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  color: var(--text-primary);
  margin-top: 0;
  width: auto;
  box-shadow: none;
}

.column-picker-btn:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
}

.column-picker-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 6px;
  background: var(--bg-elevated);
  border-radius: 10px;
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-md);
  padding: 8px;
  min-width: 170px;
  display: none;
  z-index: 100;
}

.column-picker-dropdown.open {
  display: block;
}

.column-picker-item {
  display: block;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  color: var(--text-primary);
  border-radius: 6px;
}

.column-picker-item:hover {
  background: var(--bg-table-hover);
}

.column-picker-item input {
  margin-right: 8px;
  vertical-align: middle;
}

.column-hidden {
  display: none;
}

/* =========================
   FILTRO INACTIVOS
========================= */

.filter-inactivos {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  margin-left: 8px;
}

.filter-inactivos input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

/* =========================
   FLASH ERROR
========================= */

.flash-error {
  margin: 0 30px;
  padding: 12px 16px;
  background: rgba(231, 76, 60, 0.12);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: 10px;
  color: #c0392b;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* =========================
   TOAST SUCCESS
========================= */

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
}

.toast {
  padding: 14px 20px;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.3s ease;
}

.toast-success {
  background: #22c55e;
}

.toast-error {
  background: #ef4444;
}

.toast-hiding {
  animation: toastOut 0.3s ease forwards;
}

.toast-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  margin-top: 0;
  width: auto;
  box-shadow: none;
}

.toast-close:hover {
  transform: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ========================= */
/* 📱 RESPONSIVE GLOBAL */
/* ========================= */

@media (max-width: 768px) {
  .table-container {
    padding: 0 12px 20px;
    margin-top: 12px;
  }

  .table th {
    padding: 12px 10px;
    font-size: 13px;
  }

  .table td {
    padding: 10px;
    font-size: 13px;
  }

  .table-toolbar {
    flex-wrap: wrap;
    padding: 0 12px;
    gap: 8px;
  }

  .table-search {
    max-width: 100%;
    font-size: 16px;
  }

  .filter-inactivos {
    margin-left: 0;
    font-size: 14px;
    padding: 8px 0;
  }

  .column-picker-wrapper {
    margin-left: 0;
  }

  .column-picker-btn {
    padding: 10px 14px;
    font-size: 13px;
  }

  #toast-container {
    top: auto;
    bottom: 20px;
    right: 50%;
    transform: translateX(50%);
    width: 90%;
    max-width: 400px;
  }

  .toast {
    font-size: 13px;
    padding: 12px 16px;
  }

  .edit-btn,
  .activate-btn,
  .deactivate-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .flash-error {
    margin: 0 12px;
  }
}

@media (max-width: 480px) {
  .table th {
    padding: 10px 8px;
    font-size: 12px;
  }

  .table td {
    padding: 8px;
    font-size: 12px;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-inactivos {
    justify-content: center;
  }
}
