/* ============================================================
   WebWorship — UI Moderna 2.0
   ============================================================ */

/* ── Google Font & tokens ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --sidebar-bg:      #0f172a;
  --sidebar-width:   258px;

  --primary:         #6366f1;
  --primary-dark:    #4f46e5;
  --primary-light:   #eef2ff;
  --primary-glow:    rgba(99,102,241,.35);

  --success:         #10b981;
  --danger:          #ef4444;
  --warning:         #f59e0b;
  --info:            #3b82f6;

  --bg:              #f1f5f9;
  --card:            #ffffff;

  --text:            #1e293b;
  --text-2:          #475569;
  --text-muted:      #94a3b8;
  --border:          #e2e8f0;

  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-md:  0 6px 16px rgba(0,0,0,.09);
  --shadow-lg:  0 10px 25px rgba(0,0,0,.1);

  --radius-xs:  6px;
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-full: 9999px;

  --ease: cubic-bezier(.4,0,.2,1);
  --t:    .2s;
}

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Wrapper ──────────────────────────────────────────────── */
#wrapper { display: flex; min-height: 100vh; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .3s var(--ease), min-width .3s var(--ease);
  z-index: 50;
}
#sidebar.collapsed { width: 0; min-width: 0; }

/* Marca */
.sidebar-brand {
  padding: 1.4rem 1.2rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
  white-space: nowrap;
}
.sidebar-brand .brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 1rem; color: #fff;
  box-shadow: 0 4px 10px var(--primary-glow);
  flex-shrink: 0;
}
.sidebar-brand .brand-name {
  font-size: .95rem; font-weight: 700;
  color: #fff; letter-spacing: -.2px;
  white-space: nowrap;
}
.sidebar-brand .brand-sub {
  font-size: .65rem; color: #475569;
  text-transform: uppercase; letter-spacing: .08em;
}

/* Scroll area */
.sidebar-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: .5rem .6rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.sidebar-content::-webkit-scrollbar { width: 3px; }
.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.1); border-radius: 99px;
}

/* Group labels */
.sidebar-group-label {
  font-size: .62rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: #334155;
  padding: 1rem .75rem .3rem;
  white-space: nowrap;
}

/* Links */
.sidebar-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .75rem;
  margin-bottom: .1rem;
  border-radius: var(--radius-xs);
  color: #64748b;
  text-decoration: none;
  font-size: .825rem; font-weight: 500;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
  white-space: nowrap;
}
.sidebar-link i { font-size: 1rem; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255,255,255,.05); color: #cbd5e1; }
.sidebar-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
  font-weight: 600;
}
.sidebar-label { overflow: hidden; text-overflow: ellipsis; }

/* Footer */
.sidebar-footer-version {
  padding: .7rem 1rem;
  border-top: 1px solid rgba(255,255,255,.04);
  font-size: .65rem; color: #1e293b;
  text-align: center; flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   CONTENT WRAPPER
═══════════════════════════════════════════════════════════ */
#page-content-wrapper {
  flex: 1; min-width: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
}

/* ── Top navbar ───────────────────────────────────────────── */
.top-navbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: .65rem 1.5rem;
  display: flex; align-items: center; gap: .85rem;
  position: sticky; top: 0; z-index: 40;
  flex-shrink: 0;
}
.top-navbar .page-title {
  font-size: .875rem; font-weight: 600;
  color: var(--text-2); margin: 0; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-toggle-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2);
  font-size: 1.05rem;
  transition: all var(--t);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--bg); border-color: #cbd5e1; }

/* User pill */
.user-pill {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: .25rem .65rem .25rem .35rem;
  font-size: .78rem; font-weight: 500;
  color: var(--text-2);
}
.user-avatar {
  width: 24px; height: 24px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .65rem; font-weight: 700;
  flex-shrink: 0;
}

/* ── Main content area ────────────────────────────────────── */
.main-content {
  padding: 1.5rem;
  flex: 1;
  animation: fadeIn .2s ease;
}

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

/* ═══════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════ */
.card {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
}
.card-footer {
  background: transparent !important;
  border-top: 1px solid var(--border);
}

/* Stat cards */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  transition: box-shadow var(--t), transform var(--t);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; flex-shrink: 0;
}
.stat-value {
  font-size: 1.75rem; font-weight: 700;
  color: var(--text); line-height: 1;
}
.stat-label {
  font-size: .78rem; color: var(--text-muted);
  margin-top: .2rem;
}

/* ═══════════════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════════════ */
.table { font-size: .845rem; color: var(--text); }

.table thead th {
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted);
  background: #f8fafc !important;
  border-bottom: 1px solid var(--border) !important;
  padding: .7rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  padding: .8rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: #f8fafc !important; }
.table-light th, .table-light { background: #f8fafc !important; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  font-size: .82rem; font-weight: 600;
  border-radius: var(--radius-xs);
  padding: .42rem .9rem;
  transition: all var(--t);
  letter-spacing: .01em;
  display: inline-flex; align-items: center; gap: .3rem;
}

/* Primary */
.btn-primary {
  background: var(--primary); border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px var(--primary-glow);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark); border-color: var(--primary-dark);
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Outline variants */
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-outline-secondary {
  color: var(--text-2); border-color: var(--border); background: var(--card);
}
.btn-outline-secondary:hover {
  background: var(--bg); border-color: #cbd5e1; color: var(--text);
}

.btn-outline-danger { color: var(--danger); border-color: #fecaca; }
.btn-outline-danger:hover {
  background: var(--danger); border-color: var(--danger); color: #fff;
}

.btn-outline-success { color: var(--success); border-color: #a7f3d0; }
.btn-outline-success:hover {
  background: var(--success); border-color: var(--success); color: #fff;
}

/* Sizes */
.btn-sm {
  font-size: .77rem; padding: .28rem .65rem;
  border-radius: var(--radius-xs);
}
.btn-lg {
  font-size: .95rem; padding: .65rem 1.4rem;
  border-radius: var(--radius-sm);
}

/* Button group */
.btn-group .btn { border-radius: var(--radius-xs) !important; margin-left: 3px; }
.btn-group .btn:first-child { margin-left: 0; }

/* Danger solid */
.btn-danger {
  background: var(--danger); border-color: var(--danger); color: #fff;
}
.btn-danger:hover {
  background: #dc2626; border-color: #dc2626;
  box-shadow: 0 4px 12px rgba(239,68,68,.35);
}

/* ═══════════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════════ */
.badge {
  font-size: .67rem; font-weight: 600;
  padding: .28em .65em;
  border-radius: var(--radius-full);
  letter-spacing: .02em;
}
.badge.bg-success  { background: #dcfce7 !important; color: #15803d; }
.badge.bg-danger   { background: #fee2e2 !important; color: #b91c1c; }
.badge.bg-warning  { background: #fef9c3 !important; color: #a16207; }
.badge.bg-primary  { background: var(--primary-light) !important; color: var(--primary-dark); }
.badge.bg-info     { background: #dbeafe !important; color: #1d4ed8; }
.badge.bg-secondary { background: #f1f5f9 !important; color: var(--text-2);
                      border: 1px solid var(--border) !important; }

/* Admin badge */
.admin-badge {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff; font-size: .65rem; font-weight: 700;
  padding: .22em .6em; border-radius: var(--radius-full);
  letter-spacing: .04em; text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════ */
.form-control, .form-select {
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  font-size: .855rem;
  padding: .48rem .75rem;
  color: var(--text);
  background: #fff;
  transition: border-color var(--t), box-shadow var(--t);
  font-family: inherit;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
  outline: none;
}
.form-control-lg { font-size: .95rem; padding: .6rem .9rem; }

.form-label {
  font-size: .8rem; font-weight: 600;
  color: var(--text-2); margin-bottom: .35rem;
}
.form-text { font-size: .74rem; color: var(--text-muted); margin-top: .25rem; }

.input-group-text {
  background: #f8fafc; border: 1.5px solid var(--border);
  color: var(--text-muted); font-size: .855rem;
  border-radius: var(--radius-xs);
}
.input-group > .form-control:not(:first-child),
.input-group > .input-group-text:not(:first-child) {
  border-left: 0;
}
.input-group > .form-control:not(:last-child),
.input-group > .input-group-text:not(:last-child) {
  border-right: 0;
}

.form-check-input:checked {
  background-color: var(--primary); border-color: var(--primary);
}
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(99,102,241,.15); }

.form-switch .form-check-input { width: 2.2em; }

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

/* ═══════════════════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════════════════ */
.alert {
  border-radius: var(--radius-sm) !important;
  border: none !important;
  font-size: .845rem;
  padding: .75rem 1rem;
}
.alert-success {
  background: #f0fdf4; color: #166534;
  border-left: 3px solid #22c55e !important;
}
.alert-danger {
  background: #fef2f2; color: #991b1b;
  border-left: 3px solid #ef4444 !important;
}
.alert-warning {
  background: #fffbeb; color: #92400e;
  border-left: 3px solid #f59e0b !important;
}
.alert-info {
  background: #eff6ff; color: #1e40af;
  border-left: 3px solid #3b82f6 !important;
}
.alert-secondary {
  background: #f8fafc; color: var(--text-2);
  border-left: 3px solid #94a3b8 !important;
}
.btn-close { opacity: .4; }
.btn-close:hover { opacity: .8; }

/* ═══════════════════════════════════════════════════════════
   CODE & MISC
═══════════════════════════════════════════════════════════ */
code {
  background: #f1f5f9; color: #7c3aed;
  padding: .15em .45em; border-radius: 4px;
  font-size: .83em;
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}

.list-group-item {
  border-color: var(--border);
  font-size: .845rem;
}

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════════ */
.login-bg {
  min-height: 100vh;
  background: #0f172a;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  position: relative; overflow: hidden;
}

/* Orbs decorativos */
.login-bg::before {
  content: '';
  position: absolute;
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(99,102,241,.18) 0%, transparent 65%);
  top: -200px; right: -150px;
  pointer-events: none;
}
.login-bg::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(124,58,237,.12) 0%, transparent 65%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}

.login-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  padding: 2.5rem 2.25rem;
  box-shadow: 0 25px 60px rgba(0,0,0,.5),
              0 0 0 1px rgba(255,255,255,.04) inset;
  position: relative; z-index: 1;
  animation: loginIn .4s ease;
}

@keyframes loginIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: #fff;
  margin: 0 auto 1.35rem;
  box-shadow: 0 8px 24px rgba(99,102,241,.45);
}
.login-title {
  font-size: 1.45rem; font-weight: 700;
  color: #fff; text-align: center;
  margin-bottom: .3rem; letter-spacing: -.3px;
}
.login-subtitle {
  font-size: .8rem; color: #64748b;
  text-align: center; margin-bottom: 2rem;
}

.login-card .form-label { color: #94a3b8; font-size: .78rem; }

.login-card .form-control {
  background: rgba(255,255,255,.05);
  border: 1.5px solid rgba(255,255,255,.1);
  color: #fff; border-radius: 10px;
  padding: .65rem .9rem; font-size: .875rem;
}
.login-card .form-control::placeholder { color: #334155; }
.login-card .form-control:focus {
  background: rgba(255,255,255,.08);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
  color: #fff;
}

.login-card .input-group-text {
  background: rgba(255,255,255,.05);
  border: 1.5px solid rgba(255,255,255,.1);
  color: #475569; border-right: none;
  border-radius: 10px 0 0 10px;
}
.login-card .input-group .form-control {
  border-left: none; border-radius: 0 10px 10px 0;
}
.login-card .input-group .form-control:focus { border-left: none; }

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border: none; border-radius: 10px;
  padding: .7rem 1rem; font-size: .9rem; font-weight: 600;
  color: #fff; cursor: pointer; letter-spacing: .01em;
  transition: all .25s;
  box-shadow: 0 4px 16px rgba(99,102,241,.4);
  display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(99,102,241,.55);
}
.login-btn:active { transform: translateY(0); }

.login-footer {
  text-align: center; color: #334155;
  font-size: .7rem; margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
}

.login-card .alert-danger {
  background: rgba(239,68,68,.1);
  border-left: 3px solid #ef4444 !important;
  color: #fca5a5; font-size: .82rem;
}

/* ═══════════════════════════════════════════════════════════
   UTILITIES & EXTRAS
═══════════════════════════════════════════════════════════ */

/* Page header row */
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem; flex-wrap: wrap; gap: .75rem;
}
.page-header-info h5 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.page-header-info small { color: var(--text-muted); font-size: .78rem; }

/* Back button */
.btn-back {
  width: 32px; height: 32px;
  border: 1px solid var(--border); background: var(--card);
  border-radius: var(--radius-xs);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); text-decoration: none;
  transition: all var(--t); flex-shrink: 0; font-size: .9rem;
}
.btn-back:hover { background: var(--bg); color: var(--text); }

/* Empty state */
.empty-state {
  padding: 3.5rem 1.5rem; text-align: center;
}
.empty-state i { font-size: 3rem; color: var(--border); display: block; margin-bottom: 1rem; }
.empty-state h6 { color: var(--text-2); font-weight: 600; margin-bottom: .4rem; }
.empty-state p { color: var(--text-muted); font-size: .845rem; }

/* Separator helpers */
.section-label {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); margin-bottom: .5rem;
}

/* ── Responsive ───────────────────────────────────────────── */

/* Backdrop para mobile */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 290;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
#sidebar-backdrop.show { display: block; }

@media (max-width: 767.98px) {
  #sidebar {
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: 300;
    width: 0;
    min-width: 0;
  }
  /* En mobile el sidebar abre con .mobile-open */
  #sidebar.mobile-open {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
  }
  /* En mobile ignorar la clase collapsed del desktop */
  #sidebar.collapsed {
    width: 0;
    min-width: 0;
  }
  .main-content { padding: 1rem; }
  .top-navbar { padding: .55rem 1rem; }
}
