/* ============================================================
   ADMIN PANEL — Iglesia del Dios Viviente
   Paleta: Azul Oscuro #1E2A67 | Naranja #F7941D | Blanco #FFF
   ============================================================ */

/* ---------- RESET & ROOT ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #1E2A67;
  --primary-dark: #142157;
  --primary-light: #2C3E8C;
  --primary-bg: #E8ECF8;
  --accent: #F7941D;
  --accent-hover: #E68410;
  --accent-light: #FFF3E4;
  --white: #FFFFFF;
  --bg: #F4F6FB;
  --text: #1F2937;
  --text-light: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-bg: #FEF2F2;
  --success: #10B981;
  --success-bg: #ECFDF5;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --info: #3B82F6;
  --info-bg: #EFF6FF;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, select, textarea { font-family: inherit; outline: none; }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  padding: 1.5rem;
  padding-top: calc(60px + 1.5rem);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(247, 148, 29, 0.15) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  border-radius: 50%;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  border-radius: 50%;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: loginSlideIn 0.5s ease-out;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo img {
  width: 80px;
  height: auto;
  margin: 0 auto 0.5rem;
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.login-logo span {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.login-form { display: flex; flex-direction: column; gap: 1.2rem; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}

.form-group .input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.form-group .input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 1rem;
  transition: color var(--transition);
  pointer-events: none;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  transition: all var(--transition);
}

.form-group input:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(30, 42, 103, 0.1);
}

.form-group input:focus + i,
.form-group .input-wrapper:focus-within i {
  color: var(--primary);
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.login-error.show { display: flex; }

.login-error i { font-size: 1.1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(30, 42, 103, 0.3);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: var(--white);
}

.btn-accent:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(247, 148, 29, 0.3);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

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

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger:hover {
  background: var(--danger-hover);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-light);
  transition: all var(--transition);
}

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

.login-btn {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  margin-top: 0.25rem;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
}

.login-footer a {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color var(--transition);
}

.login-footer a:hover { color: var(--accent-hover); }

/* ---------- LOGIN NAVBAR ---------- */
.login-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(20, 33, 87, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 50;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.login-nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--white);
  font-weight: 700;
  font-size: 0.95rem;
}

.login-nav-logo img {
  width: 32px;
  height: 32px;
}

.login-nav-back {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all var(--transition);
}

.login-nav-back:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.2rem;
  min-height: var(--topbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo img { width: 38px; height: 38px; flex-shrink: 0; }

.sidebar-logo-text {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  opacity: 1;
  transition: opacity var(--transition);
}

.sidebar-logo-text small {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.7;
  display: block;
}

.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

.sidebar-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--white);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  font-size: 1rem;
}

.sidebar-toggle:hover { background: rgba(255, 255, 255, 0.2); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }

.nav-section { margin-top: 1rem; }

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.4);
  padding: 0.5rem 0.8rem;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition);
}

.sidebar.collapsed .nav-section-title {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.nav-item i { font-size: 1.15rem; width: 24px; text-align: center; flex-shrink: 0; }

.nav-item span { opacity: 1; transition: opacity var(--transition); }

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.nav-item.active {
  background: rgba(247, 148, 29, 0.2);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-item .nav-section-title { opacity: 0; width: 0; }

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.65rem;
}

.sidebar-footer {
  padding: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-logout {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}

.nav-logout i { font-size: 1.15rem; width: 24px; text-align: center; flex-shrink: 0; }

.nav-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.sidebar.collapsed .nav-logout {
  justify-content: center;
  padding: 0.65rem;
}

.sidebar.collapsed .nav-logout span { display: none; }

/* ---------- SIDEBAR OVERLAY (MOBILE) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition);
}

/* ---------- MAIN CONTENT AREA ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ---------- TOPBAR ---------- */
.topbar {
  background: var(--white);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-trigger {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.3rem;
  line-height: 1;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-search input {
  padding: 0.45rem 1rem 0.45rem 2.3rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  background: var(--bg);
  width: 220px;
  transition: all var(--transition);
}

.topbar-search input:focus {
  border-color: var(--primary);
  background: var(--white);
  width: 260px;
}

.topbar-search i {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.topbar-user:hover { background: var(--bg); }

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.topbar-info { line-height: 1.3; }

.topbar-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }

.topbar-role { font-size: 0.7rem; color: var(--text-light); }

/* ---------- PAGE CONTENT ---------- */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.breadcrumb {
  font-size: 0.82rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.breadcrumb a { color: var(--primary); font-weight: 500; }
.breadcrumb a:hover { color: var(--primary-dark); }

/* ---------- STAT CARDS ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue  { background: var(--primary-bg); color: var(--primary); }
.stat-icon.orange { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.red   { background: var(--danger-bg); color: var(--danger); }

.stat-info { flex: 1; }

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ---------- TABLE ---------- */
.table-container {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}

.table-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.table-actions .search-input {
  padding: 0.45rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--bg);
  width: 200px;
  transition: all var(--transition);
}

.table-actions .search-input:focus {
  border-color: var(--primary);
  background: var(--white);
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  background: var(--bg);
  padding: 0.8rem 1.2rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr { transition: background var(--transition); }

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

tbody tr:last-child td { border-bottom: none; }

.action-btns {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.action-btns .btn-icon { width: 32px; height: 32px; font-size: 0.85rem; border-radius: 6px; }
.action-btns .btn-icon.edit:hover   { background: var(--primary-bg); color: var(--primary); }
.action-btns .btn-icon.delete:hover { background: var(--danger-bg); color: var(--danger); }

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.status-badge.active  { background: var(--success-bg); color: var(--success); }
.status-badge.pending { background: var(--warning-bg); color: var(--warning); }
.status-badge.canceled { background: var(--danger-bg); color: var(--danger); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-light);
}

.empty-state i { font-size: 3rem; color: var(--text-muted); margin-bottom: 0.8rem; }

.empty-state p { font-size: 0.95rem; }

/* ---------- PAGINATION ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pagination-info { font-size: 0.82rem; color: var(--text-light); }

.pagination-btns {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.pagination-btns button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pagination-btns button:hover:not(:disabled) {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.pagination-btns button.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.pagination-btns button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.modal-overlay.show { display: flex; opacity: 1; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
  animation: modalSlideUp 0.3s ease-out forwards;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body { padding: 1.5rem; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  position: sticky;
  bottom: 0;
  background: var(--white);
}

/* Form in modal */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-form .form-group { gap: 0.35rem; }

.modal-form .form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.modal-form .form-group input,
.modal-form .form-group select,
.modal-form .form-group textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  transition: all var(--transition);
}

.modal-form .form-group input:focus,
.modal-form .form-group select:focus,
.modal-form .form-group textarea:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(30, 42, 103, 0.08);
}

.modal-form .form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* ============================================================
   PROGRAMACION — Image Upload
   ============================================================ */
.image-preview-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.image-preview-card .card-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.image-preview-card .card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.image-preview-body {
  padding: 1.5rem;
  text-align: center;
}

.image-preview-body img {
  max-height: 400px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin: 0 auto;
  border: 1px solid var(--border);
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
  margin-top: 1.5rem;
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.upload-area i {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.upload-area p {
  font-size: 0.9rem;
  color: var(--text-light);
}

.upload-area span {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

#uploadInput { display: none; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 280px;
  animation: toastSlideIn 0.35s ease-out;
  pointer-events: auto;
}

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

.toast.success { background: var(--success); color: var(--white); }
.toast.error   { background: var(--danger); color: var(--white); }
.toast.warning { background: var(--warning); color: var(--text); }
.toast.info    { background: var(--info); color: var(--white); }

.toast.removing {
  animation: toastSlideOut 0.3s ease-in forwards;
}

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

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

/* ---------- Tablet: Sidebar collapse ---------- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    width: var(--sidebar-width);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .menu-trigger { display: block; }

  .sidebar-toggle { display: none; }

  .topbar-title {
    font-size: 1.05rem;
  }
}

/* ---------- Mobile landscape / small tablet ---------- */
@media (max-width: 768px) {
  :root {
    --topbar-height: 56px;
  }

  .topbar {
    padding: 0 0.8rem;
  }

  .topbar-search {
    display: none;
  }

  .topbar-search input {
    width: 140px;
    font-size: 0.8rem;
  }

  .topbar-search input:focus {
    width: 160px;
  }

  .page-content {
    padding: 0.8rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
  }

  .stat-card {
    padding: 1rem 0.8rem;
    gap: 0.6rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .stat-card:active {
    transform: scale(0.97);
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    border-radius: var(--radius-sm);
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.72rem;
  }

  .stat-change {
    font-size: 0.68rem;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
  }

  .page-header h2 {
    font-size: 1.2rem;
  }

  .page-header .btn,
  .page-header .btn-accent {
    width: 100%;
    justify-content: center;
    padding: 0.7rem 1rem;
    font-size: 0.88rem;
  }

  .table-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
    padding: 1rem;
  }

  .table-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .table-actions .search-input {
    flex: 1;
    min-width: 0;
    width: 100%;
  }

  .table-header .btn-outline {
    width: 100%;
    justify-content: center;
  }

  thead th {
    padding: 0.6rem 0.8rem;
    font-size: 0.7rem;
  }

  tbody td {
    padding: 0.7rem 0.8rem;
    font-size: 0.8rem;
  }

  .topbar-name {
    display: none;
  }

  .topbar-info {
    line-height: 1.1;
  }

  .topbar-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.7rem;
  }

  .topbar-role {
    font-size: 0.65rem;
  }

  .breadcrumb {
    font-size: 0.75rem;
  }

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

  .modal-header {
    padding: 1rem 1.2rem;
  }

  .modal-header h3 {
    font-size: 1rem;
  }

  .modal-body {
    padding: 1.2rem;
  }

  .modal-footer {
    padding: 0.8rem 1.2rem;
    flex-direction: column;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  .image-preview-card .card-header {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }

  .image-preview-body {
    padding: 0.8rem;
  }

  .image-preview-body img {
    max-height: 250px;
  }

  .upload-area {
    padding: 1.5rem 1rem;
  }

  .upload-area i {
    font-size: 1.8rem;
  }

  .upload-area p {
    font-size: 0.82rem;
  }

  /* Toast full-width on mobile */
  .toast-container {
    left: 0.8rem;
    right: 0.8rem;
    top: 0.6rem;
  }

  .toast {
    min-width: 0;
    width: 100%;
    font-size: 0.82rem;
    padding: 0.7rem 1rem;
  }

  /* Login */
  .login-page {
    padding: 1rem;
    padding-top: 5rem;
  }

  .login-card {
    padding: 1.8rem 1.3rem;
    max-width: 100%;
  }

  .login-logo img {
    width: 60px;
  }

  .login-logo h1 {
    font-size: 1.2rem;
  }

  .login-navbar {
    padding: 0 0.8rem;
    height: 50px;
  }

  .login-nav-logo {
    font-size: 0.85rem;
  }

  .login-nav-logo img {
    width: 28px;
    height: 28px;
  }

  .login-nav-back {
    font-size: 0.75rem;
    padding: 0.3rem 0.7rem;
  }
}

/* ---------- Small phones ---------- */
@media (max-width: 480px) {
  .topbar-search {
    display: none;
  }

  .topbar-role {
    display: none;
  }

  .topbar {
    padding: 0 0.6rem;
    gap: 0.5rem;
  }

  .topbar-title {
    font-size: 0.95rem;
  }

  .topbar-left {
    gap: 0.5rem;
  }

  .menu-trigger {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.9rem 0.7rem;
    border-radius: var(--radius);
  }

  .stat-card:active {
    transform: scale(0.96);
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .stat-label {
    font-size: 0.68rem;
  }

  .page-header .table-actions {
    flex-direction: column;
    width: 100%;
  }

  .page-header .table-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .page-header h2 {
    font-size: 1.1rem;
  }

  .breadcrumb {
    font-size: 0.72rem;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    animation: modalSlideUpMobile 0.3s ease-out forwards;
  }

  @keyframes modalSlideUpMobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .modal-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .table-wrapper {
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: 0.78rem;
  }

  thead th {
    padding: 0.5rem 0.6rem;
    font-size: 0.65rem;
    letter-spacing: 0.3px;
  }

  tbody td {
    padding: 0.6rem 0.6rem;
    font-size: 0.75rem;
  }

  .action-btns .btn-icon {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
  }

  .status-badge {
    font-size: 0.68rem;
    padding: 0.2rem 0.5rem;
  }

  .pagination {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
  }

  .pagination-info {
    font-size: 0.75rem;
  }

  .pagination-btns button {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }

  /* Login mobile refinements */
  .login-page {
    padding: 0.8rem;
    padding-top: 4.2rem;
  }

  .login-navbar {
    padding: 0 0.7rem;
    height: 46px;
  }

  .login-nav-logo {
    font-size: 0.8rem;
    gap: 0.4rem;
  }

  .login-nav-logo img {
    width: 24px;
    height: 24px;
  }

  .login-nav-back {
    font-size: 0.72rem;
    padding: 0.3rem 0.6rem;
    gap: 0.3rem;
  }

  .login-card {
    padding: 1.5rem 1rem;
    border-radius: var(--radius-lg);
  }

  .login-logo img {
    width: 55px;
  }

  .login-logo h1 {
    font-size: 1.1rem;
  }

  .login-logo span {
    font-size: 0.75rem;
  }

  .login-btn {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .login-footer a {
    font-size: 0.8rem;
  }

  .form-group input {
    padding: 0.65rem 0.9rem 0.65rem 2.4rem;
    font-size: 0.88rem;
  }

  .form-group label {
    font-size: 0.78rem;
  }

  /* Form select on mobile */
  .form-group select {
    padding: 0.65rem 0.9rem;
    font-size: 0.88rem;
  }

  .upload-area {
    padding: 1.2rem 0.8rem;
    border-radius: var(--radius);
  }

  .upload-area i {
    font-size: 1.5rem;
  }

  .upload-area p {
    font-size: 0.78rem;
  }

  .image-preview-body img {
    max-height: 200px;
  }

  .image-preview-card .card-header h3 {
    font-size: 0.9rem;
  }
}

/* ---------- Safe area for notched phones ---------- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sidebar-footer {
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom));
  }

  .toast-container {
    top: calc(0.6rem + env(safe-area-inset-top));
  }
}
