@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ============================================================
   app.css — Sistema de Acreditación
   Mobile-first, alto contraste, botones grandes para uso con celular
   ============================================================ */

/* --- Reset y base ---------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --blue: #1e40af;
  --blue-dark: #0f172a;
  --blue-light: #eff6ff;
  --green: #10b981;
  --green-light: #ecfdf5;
  --green-bg: #064e3b;
  --yellow: #f59e0b;
  --yellow-light: #fef3c7;
  --yellow-bg: #78350f;
  --red: #ef4444;
  --red-light: #fef2f2;
  --red-bg: #7f1d1d;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --white: #ffffff;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 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.08);
  --topbar-h: 56px;
  --sidebar-w: 260px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
}

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

img {
  max-width: 100%;
  display: block;
}

/* --- Topbar ---------------------------------------------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--topbar-h);
  background: var(--blue-dark);
  box-shadow: var(--shadow-md);
}

.topbar-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  gap: 12px;
}

.topbar-title {
  flex: 1;
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 6px;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: .2s;
}

.topbar-logout {
  color: rgba(255, 255, 255, .8);
  font-size: 20px;
  line-height: 1;
  padding: 8px;
  border-radius: 50%;
  transition: background .15s;
}

.topbar-logout:hover {
  background: rgba(255, 255, 255, .15);
}

/* --- Sidebar -------------------------------------------- */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  z-index: 190;
  width: var(--sidebar-w);
  background: var(--white);
  box-shadow: var(--shadow-md);
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(0, 0, 0, .4);
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--gray-200);
}

.sidebar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-name {
  font-weight: 600;
  font-size: 14px;
}

.sidebar-role {
  font-size: 12px;
  color: var(--gray-400);
}

.sidebar-nav {
  list-style: none;
  padding: 8px 0;
}

.nav-link {
  display: block;
  padding: 14px 20px;
  color: var(--gray-600);
  font-size: 15px;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: var(--gray-50);
  color: var(--blue);
}

.nav-link.active {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
  border-left-color: var(--blue);
}

/* --- Main content ---------------------------------------- */
.main-content {
  margin-top: var(--topbar-h);
  padding: 20px 16px;
  min-height: calc(100vh - var(--topbar-h));
}

/* --- Cards ----------------------------------------------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: 20px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 16px;
}

/* --- Stats grid ----------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: 16px;
  text-align: center;
  transition: transform 0.2s ease;
}

.stat-number {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.stat-blue {
  border-top: 4px solid var(--blue);
}

.stat-green {
  border-top: 4px solid var(--green);
}

.stat-red {
  border-top: 4px solid var(--red);
}

.stat-yellow {
  border-top: 4px solid var(--yellow);
}

/* --- Buttons -------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-block {
  display: flex;
  width: 100%;
}

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

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

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

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

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-800);
}

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

.btn-sm {
  font-size: 14px;
  padding: 8px 14px;
}

.btn-lg {
  font-size: 20px;
  padding: 18px 24px;
}

/* --- Forms ---------------------------------------------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-800);
  transition: border-color .15s;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, .15);
}

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

/* --- Alerts --------------------------------------------- */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success {
  background: var(--green-light);
  color: #14532d;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: var(--red-light);
  color: #7f1d1d;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: var(--yellow-light);
  color: #713f12;
  border: 1px solid #fef08a;
}

.alert-info {
  background: var(--blue-light);
  color: var(--blue-dark);
  border: 1px solid #bfdbfe;
}

/* --- Tables --------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 2px solid var(--gray-200);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

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

tr:hover td {
  background: var(--gray-50);
}

/* --- Badges --------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green {
  background: var(--green-light);
  color: var(--green);
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-yellow {
  background: var(--yellow-light);
  color: var(--yellow);
}

.badge-red {
  background: var(--red-light);
  color: var(--red);
}

/* --- Scanner screens ------------------------------------ */
.result-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  animation: fadeIn .3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.result-screen.valid {
  background: linear-gradient(135deg, var(--green-bg) 0%, var(--green) 100%);
}

.result-screen.warning {
  background: linear-gradient(135deg, var(--yellow-bg) 0%, var(--yellow) 100%);
}

.result-screen.invalid {
  background: linear-gradient(135deg, var(--red-bg) 0%, var(--red) 100%);
}

.result-icon {
  font-size: 72px;
  line-height: 1;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.result-title {
  font-size: 32px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -.5px;
  margin-bottom: 20px;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.result-data {
  background: rgba(255, 255, 255, .12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.result-data p {
  color: #ffffff;
  font-size: 18px;
  margin-bottom: 6px;
}

.result-data p:last-child {
  margin-bottom: 0;
}

.result-data .big {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.result-actions .btn {
  font-size: 18px;
  padding: 18px;
}

/* --- QR Scanner ----------------------------------------- */
#qr-reader {
  width: 100% !important;
  border-radius: var(--radius);
  overflow: hidden;
}

#qr-reader video {
  border-radius: var(--radius);
}

/* Ocultar botones internos feos de html5-qrcode */
#qr-reader__dashboard_section_csr button,
#qr-reader__dashboard_section_swaplink,
#qr-reader__status_span {
  display: none !important;
}

/* --- Login ---------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.login-logo {
  font-size: 40px;
  text-align: center;
  margin-bottom: 8px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 14px;
  color: var(--gray-400);
  text-align: center;
  margin-bottom: 28px;
}

/* --- Page header ---------------------------------------- */
.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 800;
}

.page-header p {
  color: var(--gray-400);
  font-size: 14px;
  margin-top: 2px;
}

/* --- Search bar ----------------------------------------- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar .form-control {
  flex: 1;
}

/* --- Pagination ----------------------------------------- */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.pagination a,
.pagination span {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  border: 1px solid var(--gray-200);
}

.pagination a {
  background: var(--white);
  color: var(--blue);
}

.pagination a:hover {
  background: var(--blue-light);
}

.pagination .current {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

/* --- Modal ---------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, .5);
  align-items: flex-end;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 28px 20px;
  width: 100%;
  animation: slideUp .25s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* --- Utilities ------------------------------------------ */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.gap-2 {
  gap: 8px;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.w-full {
  width: 100%;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Desktop breakpoint --------------------------------- */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none !important;
  }

  .menu-toggle {
    display: none;
  }

  .main-content {
    margin-left: var(--sidebar-w);
    padding: 28px 32px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .result-title {
    font-size: 48px;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal-box {
    border-radius: 16px;
    max-width: 520px;
    margin: auto;
  }
}

@media (min-width: 1024px) {
  .main-content {
    padding: 32px 40px;
  }
}