/* =====================================================
   SISTEMA DE ENCUESTAS - ESTILOS UNIFICADOS
   ===================================================== */

:root {
  --bg: #f8f9fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --danger: #dc2626;
  --error: #dc2626;
  --shadow: 0 8px 24px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
}

/* =====================================================
   ANIMACIONES GLOBALES
   ===================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* =====================================================
   UTILIDADES COMUNES
   ===================================================== */

.u-wrap { 
  display: none; 
}

/* =====================================================
   BOTONES
   ===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
}

.btn i {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary.loading i {
  animation: spin 1s linear infinite;
}

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* =====================================================
   CAMPOS DE FORMULARIO
   ===================================================== */

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.field small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Input con icono */
.input-wrapper {
  position: relative;
}

.input-wrapper input {
  padding-left: 44px;
  width: 100%;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: color 0.2s;
  pointer-events: none;
  z-index: 1;
}

.input-wrapper input:focus + i {
  color: var(--primary);
}

/* =====================================================
   MODAL
   ===================================================== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.close-modal {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.close-modal:hover {
  background: var(--bg);
  color: var(--text);
  transform: rotate(90deg);
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* =====================================================
   BADGES Y ESTADOS
   ===================================================== */

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  transition: transform 0.2s;
}

.status-badge:hover {
  transform: scale(1.05);
}

.status-active {
  background: #ecfdf5;
  color: var(--success);
}

.status-inactive {
  background: #fee2e2;
  color: var(--danger);
}

.status {
  background: #ecfdf5;
  color: var(--success);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

/* =====================================================
   MENSAJES
   ===================================================== */

.error-message {
  background: #fee;
  border: 1px solid #fcc;
  color: var(--error);
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 16px;
  display: none;
  animation: shake 0.4s;
}

.error-message.show {
  display: block;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state i {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text);
}

/* =====================================================
   LAYOUTS - DASHBOARD/ADMIN
   ===================================================== */

body.dashboard-layout,
body.admin-layout {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 36px;
  animation: fadeIn 0.5s ease-out;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 36px;
  flex-wrap: wrap;
  gap: 16px;
  animation: slideDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header h1 i {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logout {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
  transition: all 0.2s;
}

.logout:hover {
  background: white;
  color: var(--text);
}

.logout i {
  width: 16px;
  height: 16px;
}

/* Stats (KPIs) */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 42px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat:nth-child(1) { animation-delay: 0.1s; }
.stat:nth-child(2) { animation-delay: 0.2s; }
.stat:nth-child(3) { animation-delay: 0.3s; }

.stat:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.08);
}

.stat span {
  font-size: 13px;
  color: var(--muted);
  display: block;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  font-weight: 700;
}

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* Cards (encuestas) */
.cards {
  display: grid;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  box-shadow: 0 12px 32px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}

.meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.numbers {
  display: flex;
  gap: 32px;
  margin-top: 18px;
}

.numbers div {
  text-align: left;
}

.numbers strong {
  font-size: 22px;
  font-weight: 700;
}

.numbers span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Actions */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 160px;
}

.action {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.action:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary);
}

.action i {
  width: 16px;
  height: 16px;
}

/* =====================================================
   TABLA (ADMIN)
   ===================================================== */

.table-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
}

.table-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.table-header h2 {
  font-size: 18px;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg);
}

th {
  padding: 14px 24px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody tr {
  border-top: 1px solid var(--border);
  transition: background 0.2s;
  animation: fadeIn 0.4s ease-out backwards;
}

tbody tr:nth-child(1) { animation-delay: 0.1s; }
tbody tr:nth-child(2) { animation-delay: 0.15s; }
tbody tr:nth-child(3) { animation-delay: 0.2s; }
tbody tr:nth-child(4) { animation-delay: 0.25s; }
tbody tr:nth-child(5) { animation-delay: 0.3s; }

tbody tr:hover {
  background: #fafbfc;
}

td {
  padding: 16px 24px;
  font-size: 14px;
}

.actions-cell {
  display: flex;
  gap: 8px;
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */

body.login-layout {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

body.login-layout::before,
body.login-layout::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  animation: float 20s infinite ease-in-out;
}

body.login-layout::before {
  width: 400px;
  height: 400px;
  top: -200px;
  right: -100px;
  animation-delay: -5s;
}

body.login-layout::after {
  width: 300px;
  height: 300px;
  bottom: -150px;
  left: -100px;
  animation-delay: -10s;
}

.login-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.logo {
  text-align: center;
  margin-bottom: 32px;
  animation: fadeIn 0.8s ease-out 0.2s backwards;
}

.logo i {
  width: 64px;
  height: 64px;
  color: var(--primary);
  margin-bottom: 16px;
}

.logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.logo p {
  font-size: 14px;
  color: var(--muted);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  animation: fadeIn 1s ease-out 0.6s backwards;
}

/* =====================================================
   PLANTILLAS (MODAL)
   ===================================================== */

.template-grid {
  display: grid;
  gap: 12px;
}

.template-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.template-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
}

.template-card.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.template-card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.template-card p {
  font-size: 13px;
  color: var(--muted);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 760px) {
  body.dashboard-layout,
  body.admin-layout {
    padding: 20px;
  }

  .card {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  table {
    font-size: 13px;
  }

  th, td {
    padding: 12px 16px;
  }

  .actions-cell {
    flex-direction: column;
  }

  .login-card {
    padding: 32px 24px;
  }
}
