/* QR Control de Acceso - Materialize overrides & custom styles */

:root {
  --primary: #666cff;
  --primary-dark: #4a50e0;
  --secondary: #e83e8c;
}

/* Layout */
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
}
body.dark { background: #121212; }

/* Fixed header */
nav { background-color: var(--primary) !important; }
nav .nav-wrapper {
  padding: 0 12px;
  display: flex;
  align-items: center;
  position: relative;
}
nav .brand-logo {
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  position: static;
  transform: none;
  left: auto;
}
nav .brand-logo i { vertical-align: middle; margin-right: 4px; font-size: 22px; }
nav ul.right {
  position: static;
  transform: none;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  float: none;
  margin: 0;
}
nav ul.right li > a,
nav ul.right li > span { padding: 0 8px !important; }

/* Main content - scrollable area between header and bottom nav */
.main-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 12px calc(72px + env(safe-area-inset-bottom));
}

/* Card */
.card { border-radius: 12px; }
.card .card-content { padding: 20px; }
body.dark .card { background: #1e1e1e; color: #fff; }
body.dark .card .card-content { color: #fff; }

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}
.bottom-nav .tab-item {
  flex: 1;
  text-align: center;
  padding: 10px 0 8px;
  color: #666;
  cursor: pointer;
  transition: color 0.2s;
  user-select: none;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.bottom-nav .tab-item i { font-size: 26px; display: block; margin-bottom: 2px; }
.bottom-nav .tab-item small { font-size: 12px; display: block; line-height: 1.2; }
.bottom-nav .tab-item.active { color: var(--primary); }
.bottom-nav .tab-item.active small { font-weight: 600; }
body.dark .bottom-nav { background: #1e1e1e; border-top-color: #333; }
body.dark .bottom-nav .tab-item { color: #999; }
body.dark .bottom-nav .tab-item.active { color: #8a8eff; }

/* Buttons */
.btn, .btn-large, .btn-small, .btn-flat { border-radius: 8px; }
.btn, .btn-large, .btn-small { background-color: var(--primary) !important; }
.btn:hover, .btn-large:hover, .btn-small:hover { background-color: var(--primary-dark) !important; }
.btn i, .btn-large i { vertical-align: middle; margin-right: 4px; }

/* Forms */
.input-field input:focus + label,
.input-field input.valid + label,
.input-field input.invalid + label { color: var(--primary) !important; }
.input-field input:focus { border-bottom-color: var(--primary) !important; box-shadow: 0 1px 0 0 var(--primary) !important; }
.input-field .prefix.active { color: var(--primary); }
.input-field .invalid-text { color: #F44336; font-size: 12px; margin-top: -8px; display: block; }

/* Login page */
.login-wrap { max-width: 400px; margin: 0 auto; width: 100%; }

/* Video scanner */
video {
  width: 100%; max-width: 280px; height: auto; aspect-ratio: 1;
  display: block; margin: 0 auto;
  border-radius: 12px; object-fit: cover; background: #000;
  border: 3px solid #ddd;
}
.scanner-wrap { text-align: center; padding: 8px 0; }
video.scanning { border-color: #1976d2; box-shadow: 0 0 0 4px rgba(25,118,210,0.2); }
video.success { border-color: #2e7d32; box-shadow: 0 0 0 4px rgba(46,125,50,0.3); }
video.error { border-color: #c62828; box-shadow: 0 0 0 4px rgba(198,40,40,0.3); }

/* Card flash */
.card.flash-ok { background: #a5d6a7 !important; transition: background 0.2s; box-shadow: 0 0 0 4px rgba(76,175,80,0.4); }
.card.flash-err { background: #ef9a9a !important; transition: background 0.2s; box-shadow: 0 0 0 4px rgba(244,67,54,0.4); }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
.card.flash-ok { animation: pulse 0.3s ease-in-out; }

/* Loading */
.loading-indicator { text-align: center; padding: 16px 0; }

/* Scan history */
.scan-history { margin-top: 20px; border-radius: 12px; }
.scan-history .collection { margin: 0; border: none; border-radius: 12px; }
.scan-history .collection-item { }
.scan-history .collection-item .title { font-weight: 600; font-size: 18px; }
.scan-history .collection-item p { font-size: 16px; color: #555; font-family: monospace; margin: 0; }
.scan-history .collection-item .secondary-content { font-size: 1em; color: #333; display: inline-flex; align-items: center; gap: 2px; line-height: 1; }

/* Connection indicator */
.connection-status {
  position: fixed; bottom: calc(72px + env(safe-area-inset-bottom));
  right: 10px;
  background: rgba(0,0,0,0.7); color: white;
  border-radius: 50%; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; font-size: 20px;
}
.connection-status.online { background: #2e7d32; }
.connection-status.offline { background: #c62828; }

/* Progress bar inside card */
.progress-wrap { max-width: 200px; margin: 12px auto; }

/* Utility */
.hidden { display: none !important; }
.mt-2 { margin-top: 16px; }

/* Logo */
.logo-nav { height: 32px; vertical-align: middle; margin-right: 8px; }

/* Lock icon */
.modal-lock-icon { font-size: 48px; color: var(--secondary); }

/* Avatar circle */
.avatar-circle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  font-size: 13px; font-weight: 500;
}

/* Dark mode text */
body.dark, body.dark .main-wrap { color: #e0e0e0; }

/* Materialize toast override */
#toast-container { bottom: calc(72px + env(safe-area-inset-bottom)) !important; top: auto !important; }
.toast-dark { background-color: #323232 !important; color: #fff !important; border-radius: 8px !important; }

/* Mobile adjustments */
@media (max-width: 360px) {
  nav .brand-logo { font-size: 1rem; }
  .card .card-content { padding: 16px; }
}
