/* ══════════════════════════════════════════════════════════════════════
   components.css — UI primitives shared by ALL pages
   Buttons, cards, footer, login, forms, modal, toast, scrollbar utility.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Buttons + Cards & Glass (ex 373-471) ──────────────────────── */
/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  color: white;
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
  justify-content: center;
}

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

/* ── Cards & Glass ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  transition: all 0.3s ease;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.card-header {
  margin-bottom: 24px;
}

.card-header h2 {
  font-size: 1.5rem;
  font-family: var(--font-heading);
  font-weight: 700;
  margin-bottom: 8px;
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}


/* ── Form group (ex 1159-1186) ─────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-group textarea { resize: vertical; min-height: 100px; }


/* ── btn-full + form-status (ex 1731-1740) ────────────────────── */
.btn-full { width: 100%; justify-content: center; }

.form-status {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.form-status.success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.form-status.error { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* ── Footer + Form Elements + Login (ex 1780-1856) ─────────────── */
/* ── Footer ─────────────────────────────────────────────────────────── */
.footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Form Elements ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

/* ── Login Page ─────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* PWA iOS: respect safe area pentru notch/Dynamic Island la login */
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.login-card .card-header {
  text-align: center;
}

.login-card .logo-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 16px;
}


/* ── Modal + Alert + Empty + Spinner (ex 3394-3527) ────────────── */
/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.modal {
  width: 100%;
  max-width: 480px;
  animation: modalSlide 0.3s ease;
}

.modal-scrollable {
  max-height: min(92vh, 1100px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.mandatory-notice-modal {
  align-self: flex-start;
}

.mandatory-notice-form {
  position: relative;
}

.mandatory-notice-footer {
  position: sticky;
  bottom: 0;
  margin-left: -32px;
  margin-right: -32px;
  margin-bottom: 0;
  padding: 18px 32px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(10, 14, 26, 0.04), rgba(10, 14, 26, 0.98) 36%);
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  z-index: 2;
}

.modal-wide {
  max-width: 880px;
}

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

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Alert/Toast ────────────────────────────────────────────────────── */
/* z-index: 10001 → por encima de cualquier modal de la app
 * (modal-mandatory-notice 500, scanner-modal 9000, nomina-modal 9999,
 * pwa-register banner 10000). Antes estaba a 300 y los toasts de error
 * quedaban ocultos debajo de los popups — el usuario no podía leer por qué
 * fallaba el submit de "Firmar y entrar". Trazabilidad: PROJECT_JOURNAL
 * 2026-04-23. */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 10001;
  animation: toastSlide 0.3s ease;
  max-width: 400px;
}

.toast-success { background: rgba(16, 185, 129, 0.9); color: white; }
.toast-error { background: rgba(239, 68, 68, 0.9); color: white; }
.toast-info { background: rgba(99, 102, 241, 0.9); color: white; }

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

/* ── Empty State ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1.2rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; }

/* ── Loading Spinner ────────────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

.spinner-lg { width: 48px; height: 48px; border-width: 4px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 24px;
}

.loading-state p { color: var(--text-muted); }


/* ── Responsive shared (ex 3528-3594) ──────────────────────────── */
/* ── Responsive ─────────────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1100px) {
  .admin-calendar-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-toggle { display: block; }
  .ui-mode-switch {
    padding: 5px 8px;
    gap: 8px;
  }
  .ui-mode-switch-text {
    display: none;
  }

  .nav-links.active {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(20px);
    padding: 24px;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    margin-left: 0;
  }

  .hero { padding: 120px 0 80px; }
  .hero h1 { font-size: 2rem; }

  .services, .contact { padding: 60px 0; }
  .section-title h2 { font-size: 1.6rem; }

  .card { padding: 24px; }

  .dashboard-wrapper { padding-top: calc(80px + env(safe-area-inset-top, 0px)); }

  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 10px 8px; }

  .admin-calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-range-popover {
    width: calc(100vw - 48px);
    left: 50%;
    transform: translateX(-50%);
  }

  .admin-range-popover-header,
  .admin-range-popover-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .nominas-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}


/* ── Dropdown / Select (ex 3604-3612) ──────────────────────────── */
/* ── Dropdown / Select ──────────────────────────────────────────────── */
select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}


/* ── Toast Container (ex 4098-4124) ────────────────────────────── */
/* ── Toast Container ─────────────────────────────────────────────── */
/* Mismo motivo que .toast arriba: tiene que estar por encima de todos
 * los modales (incluido nomina-modal-overlay 9999). */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#toast-container .toast {
  position: relative;
  bottom: auto;
  right: auto;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

#toast-container .toast.show {
  opacity: 1;
  transform: translateY(0);
}


/* ── Badges (status pills, admin/user/warning, ex 3381-3392) ───────── */
.badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-admin { background: rgba(139, 92, 246, 0.15); color: var(--accent-secondary); }
.badge-user { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.14); color: var(--warning); }

/* ══════════════════════════════════════════════════════════════════════
   Notice tracking + ack — shared între panel.html (driver semnează)
   și admin.html (admin vede confirmările). Mutate din panel.css în
   components.css pe 2026-04-26 (regresie split CSS).
   ══════════════════════════════════════════════════════════════════════ */
/* ── Notice tracking + pill + ack (ex 1505-1626) ─────────────────── */
.notice-tracking-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.notice-tracking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
}

.notice-tracking-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notice-tracking-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.notice-tracking-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notice-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
}

.notice-pill.success {
  background: rgba(16, 185, 129, 0.16);
  color: var(--success);
}

.notice-pill.warning {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.notice-tracking-side {
  text-align: right;
  min-width: 140px;
}

.notice-tracking-progress {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.notice-tracking-sub {
  margin-top: 4px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.notice-track-btn {
  margin-top: 10px;
}

.notice-ack-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.notice-ack-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
}

.notice-ack-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notice-ack-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.notice-ack-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notice-ack-detail {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.notice-ack-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 170px;
}


/* ── Notice tracking + ack responsive (mutate din panel.css 2026-04-26) */
@media (max-width: 768px) {
  .notice-tracking-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .notice-tracking-side {
    text-align: left;
    min-width: 0;
  }

  .notice-ack-item {
    flex-direction: column;
  }

  .notice-ack-actions {
    width: 100%;
    min-width: 0;
  }

  .notice-ack-actions .btn {
    width: 100%;
    justify-content: center;
  }

}
