/* Variables y Reset */
:root {
  --bg-body: #f0f2f5;
  --bg-card: #ffffff;
  --text-main: #1a1a1a;
  --text-muted: #65676b;
  --primary: #2563eb; /* Azul más moderno */
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  scrollbar-color: var(--primary) var(--bg-body);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --border: #334155;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout Principal */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: .5rem 2rem 2rem;
}

/* Grid Layout del Panel de Administración */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 1.5rem;
  grid-template-areas:
    "create view"
    "sessions view"
    "sessions view";
}

.grid-area-create {
  grid-area: create;
}

.grid-area-view {
  grid-area: view;
}

.grid-area-sessions {
  grid-area: sessions;
}

/* Responsive: En pantallas pequeñas, apila todo verticalmente */
@media (max-width: 768px) {
  .admin-container {
    padding: 1rem;
  }
  .row {
    flex-direction: column;
  }
  .admin-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "create"
      "view"
      "sessions";
  }
}

/* Header del Dashboard */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-main);
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text-main);
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* Formularios */
.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

input, textarea, select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Botones */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 0.95rem;
}

button:not(.secondary) {
  background-color: var(--primary);
  color: white;
}

button:not(.secondary):hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

button.secondary {
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}

button.secondary:hover {
  background-color: var(--bg-body);
  border-color: var(--text-muted);
}

button:disabled,
button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
}

button:disabled:hover,
button[disabled]:hover {
  background-color: var(--primary);
  transform: none !important;
}

button.secondary:disabled,
button.secondary[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

button.secondary:disabled:hover,
button.secondary[disabled]:hover {
  background-color: transparent;
  border-color: var(--border);
}

/* Utilidades */
.row {
  display: flex;
  gap: 1rem;
}

.row > input {
  flex: 1;
}

.spaced {
  margin-top: 1.5rem;
}

.muted {
  color: var(--text-muted);
}

/* Tablas */
.table-container {
  overflow-x: auto;
  max-height: 50dvh;
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

thead {
  background-color: var(--bg-body);
}

th {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
}

td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

tr:hover td {
  background-color: rgba(0,0,0,0.02);
}

/* Modal de Login (Overlay) */
.login-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  animation: fadeIn 0.2s ease-out;
}

.login-modal {
  background-color: var(--bg-card);
  padding: 2.5rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  animation: slideUp 0.3s ease-out;
}

.login-modal h2 {
  text-align: center;
  margin-bottom: 0.5rem;
}

.login-modal p {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.login-modal button {
  width: 100%;
  margin-top: 1rem;
}

/* Toggle Switch */
.auto-refresh-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border);
  transition: .3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
  background-color: var(--primary);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Loader */
.loader {
  display: inline-flex;
  gap: 4px;
}

.loader span {
  width: 6px;
  height: 6px;
  background-color: var(--primary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loader span:nth-child(1) { animation-delay: -0.32s; }
.loader span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Footer */
footer {
  text-align: center;
  padding: .5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.error-message {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  text-align: center;
}

/* Help Tooltip */
.help-tooltip {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background-color: var(--primary);
  color: white;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transition: all 0.3s ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.help-tooltip:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
  background-color: var(--primary-hover);
}

.help-tooltip:active {
  transform: scale(0.95);
}

.help-tooltip svg {
  width: 24px;
  height: 24px;
}

.help-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: -2px;
}

/* Help Modal */
.help-modal {
  background-color: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  animation: slideUp 0.3s ease-out;
  display: flex;
  flex-direction: column;
}

.help-modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-body);
}

.help-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.close-button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.close-button:hover {
  background-color: var(--bg-body);
  color: var(--text-main);
}

.help-modal-content {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
}

.help-modal-content section {
  margin-bottom: 2rem;
}

.help-modal-content section:last-child {
  margin-bottom: 0;
}

.help-modal-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.help-modal-content p {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.help-modal-content ul {
  list-style: none;
  padding-left: 0;
  margin-top: 0.5rem;
}

.help-modal-content li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
  color: var(--text-muted);
  line-height: 1.5;
}

.help-modal-content li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: bold;
}

.help-modal-content strong {
  color: var(--text-main);
  font-weight: 600;
}

@media (max-width: 768px) {
  .help-tooltip {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .help-tooltip svg {
    width: 20px;
    height: 20px;
  }

  .help-label {
    font-size: 8px;
  }

  .help-modal {
    width: 95%;
    max-height: 90vh;
  }

  .help-modal-header {
    padding: 1rem 1.25rem;
  }

  .help-modal-header h2 {
    font-size: 1.25rem;
  }

  .help-modal-content {
    padding: 1.25rem;
  }
}
