/**
 * Tema visual alineado al design system "Mantenciones — Slate & Azure"
 * definido en Google Stitch (proyecto projects/15702437204656578456).
 */
:root {
  --app-sidebar: #0f172a;
  --app-sidebar-hover: #1e293b;
  --app-nav-active-bg: rgba(37, 99, 235, 0.12);
  --app-nav-active-border: #3b82f6;
  --app-primary: #2563eb;
  --app-primary-hover: #1d4ed8;
  --app-accent: #0ea5e9;
  --app-page-bg: #f8fafc;
  --app-surface: #ffffff;
  --app-border: #e2e8f0;
  --app-text: #0f172a;
  --app-text-muted: #64748b;
  --app-muted: #94a3b8;
  --app-focus-ring: rgba(37, 99, 235, 0.22);
  --app-radius: 12px;
  --app-radius-sm: 8px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Plus Jakarta Sans", var(--font-sans);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--app-text);
  background-color: var(--app-page-bg);
  -webkit-font-smoothing: antialiased;
}

.content,
#main-content {
  background-color: var(--app-page-bg);
}

h1, h2, h3, h4, h5, h6,
.navbar-brand,
.card-header,
.modal-title {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  background: var(--app-surface);
}

.table {
  font-variant-numeric: tabular-nums;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem var(--app-focus-ring);
}

.sidebar .nav-link {
  border-left: 3px solid transparent;
  border-radius: 0 var(--app-radius-sm) var(--app-radius-sm) 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Pantallas de autenticación (login, selección de empresa) */
body.auth-screen {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  font-family: var(--font-sans);
  background:
    radial-gradient(ellipse 900px 500px at 15% -20%, rgba(59, 130, 246, 0.22), transparent 55%),
    radial-gradient(ellipse 700px 450px at 100% 10%, rgba(14, 165, 233, 0.14), transparent 50%),
    linear-gradient(165deg, #0c1222 0%, #0f172a 40%, #1e293b 100%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 2.5rem;
  border-radius: var(--app-radius);
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow:
    0 4px 6px -1px rgba(15, 23, 42, 0.2),
    0 24px 48px -12px rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(16px);
}

.auth-card.auth-card--wide {
  max-width: 520px;
}

.auth-card .login-header,
.auth-card .selection-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-card .login-header .icon,
.auth-card .selection-header .icon {
  font-size: 2.75rem;
  color: #e2e8f0;
  margin-bottom: 0.75rem;
  display: inline-block;
}

.auth-card h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #f8fafc;
  margin: 0;
  font-size: 1.85rem;
}

.auth-card .form-group {
  margin-bottom: 1.5rem;
  position: relative;
}

.auth-card .input-group {
  position: relative;
}

.auth-card .input-group i,
.auth-card .select-group i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  color: #94a3b8;
}

.auth-card .select-group {
  position: relative;
}

.auth-card .subtitle {
  color: #94a3b8;
  margin: 0.5rem 0 0;
  font-size: 1.05rem;
}

.auth-card label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
  color: #cbd5e1;
}

.auth-card .input-icon {
  color: #94a3b8;
}

.auth-card input,
.auth-card select {
  width: 100%;
  padding: 0.95rem 1rem 0.95rem 2.85rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--app-radius-sm);
  font-size: 1rem;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.65);
  color: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-card input:focus,
.auth-card select:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}

.auth-card input::placeholder {
  color: #64748b;
}

.auth-card .btn-primary-solid {
  width: 100%;
  padding: 0.95rem 1rem;
  margin-top: 0.25rem;
  border: none;
  border-radius: var(--app-radius-sm);
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, var(--app-primary) 0%, #1d4ed8 100%);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-card .btn-primary-solid:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.4);
}

.auth-card .btn-primary-solid:disabled {
  background: #475569;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.auth-card a.muted-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.auth-card a.muted-link:hover {
  color: #e2e8f0;
}

.auth-card .user-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--app-radius-sm);
  padding: 1rem;
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-card .user-pill .welcome {
  color: #f8fafc;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.auth-card .user-pill .role {
  color: #94a3b8;
  font-size: 0.9rem;
}

.auth-card select option {
  background: #0f172a;
  color: #f8fafc;
}

.auth-card .error-message {
  background-color: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 0.9rem 1rem;
  border-radius: var(--app-radius-sm);
  margin-bottom: 1.25rem;
  text-align: center;
  display: none;
  animation: auth-fade-in 0.35s ease;
}

@keyframes auth-fade-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.75rem;
  }
}

/* ========== Vista móvil principal (mobile.php) ========== */
body.mobile-app {
  font-family: var(--font-sans);
  background: var(--app-page-bg);
  color: var(--app-text);
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

.mobile-app .text-primary {
  color: var(--app-primary) !important;
}

.mobile-header {
  background: linear-gradient(135deg, var(--app-primary), var(--app-primary-hover));
  color: #fff;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-content {
  padding: 1rem;
}

.mobile-app .action-card {
  background: var(--app-surface);
  border-radius: var(--app-radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  border: 1px solid var(--app-border);
  display: block;
  width: 100%;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.mobile-app .action-card:hover,
.mobile-app .action-card:active {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  color: inherit;
  text-decoration: none;
}

.mobile-app .action-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.mobile-app .btn-mobile {
  padding: 1rem 1.5rem;
  border-radius: var(--app-radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  width: 100%;
  margin-bottom: 1rem;
}

.mobile-app .btn-primary-mobile {
  background: linear-gradient(135deg, var(--app-primary), var(--app-primary-hover));
  color: #fff;
}

.mobile-app .btn-success-mobile {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
}

.mobile-app .camera-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.mobile-app #video,
.mobile-app #canvas {
  width: 100%;
  border-radius: var(--app-radius-sm);
  box-shadow: 0 4px 15px rgba(15, 23, 42, 0.12);
}

.mobile-app .capture-btn {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--app-primary);
  border: 4px solid #fff;
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 4px 15px rgba(15, 23, 42, 0.2);
  cursor: pointer;
  z-index: 110;
}

.mobile-app .photo-preview {
  max-width: 100%;
  border-radius: var(--app-radius-sm);
  margin: 1rem 0;
}

.mobile-app .mobile-navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--app-surface);
  border-top: 1px solid var(--app-border);
  padding: 0.5rem 0;
  display: flex;
  justify-content: space-around;
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.06);
  z-index: 100;
}

.mobile-app .nav-item-mobile {
  text-align: center;
  color: var(--app-text-muted);
  text-decoration: none;
  padding: 0.5rem;
  border-radius: var(--app-radius-sm);
  min-width: 60px;
}

.mobile-app .nav-item-mobile.active {
  color: var(--app-primary);
  background: var(--app-nav-active-bg);
}

.mobile-app .form-control-mobile {
  border-radius: var(--app-radius-sm);
  padding: 1rem;
  font-size: 1.1rem;
  border: 2px solid var(--app-border);
}

.mobile-app .form-control-mobile:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem var(--app-focus-ring);
}

.mobile-app #edit-estado {
  font-weight: 600;
  border-width: 2px;
  transition: all 0.3s ease;
}

.mobile-app #edit-estado option {
  padding: 0.5rem;
  font-weight: 600;
}

.mobile-app #edit-estado.border-warning {
  background-color: rgba(234, 179, 8, 0.12);
}

.mobile-app #edit-estado.border-primary {
  background-color: rgba(37, 99, 235, 0.1);
}

.mobile-app #edit-estado.border-success {
  background-color: rgba(22, 163, 74, 0.12);
}

.mobile-app #edit-estado.border-secondary {
  background-color: rgba(100, 116, 139, 0.12);
}

.mobile-app .hidden {
  display: none !important;
}

.mobile-app .activo-selectable {
  cursor: pointer;
  transition: background-color 0.2s;
}

.mobile-app .activo-selectable:hover {
  background-color: var(--app-page-bg);
}

.mobile-app .activo-selected {
  background-color: var(--app-nav-active-bg);
  border-color: var(--app-primary) !important;
}

/* Galería de fotos (mobile) */
.mobile-app .photo-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.mobile-app .photo-modal-content {
  position: relative;
  max-width: 95%;
  max-height: 95%;
  text-align: center;
}

.mobile-app .photo-modal-image {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--app-radius-sm);
  margin: 0 auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.mobile-app .gallery-photo {
  cursor: pointer;
  transition: transform 0.2s;
  border-radius: var(--app-radius-sm);
  margin-bottom: 1rem;
}

.mobile-app .gallery-photo:hover {
  transform: scale(1.02);
}

.mobile-app .photo-modal-content > * {
  pointer-events: auto;
}

.mobile-app .photo-modal .btn {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}

.mobile-app #photo-counter {
  background: rgba(0, 0, 0, 0.5);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  backdrop-filter: blur(10px);
}

.mobile-app .photo-modal-header {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border-radius: 10px 10px 0 0;
}

.mobile-app .photo-modal-controls {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border-radius: 0 0 10px 10px;
}

@media (max-width: 480px) {
  .mobile-app .photo-modal-header {
    padding: 1rem !important;
  }

  .mobile-app .photo-modal-controls {
    padding: 1rem !important;
    flex-wrap: wrap;
    gap: 1rem !important;
  }

  .mobile-app #photo-counter {
    order: -1;
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
  }

  .mobile-app .photo-modal-controls .btn {
    flex: 1;
    min-width: 100px;
  }
}

@media (max-width: 576px) {
  .mobile-app .mobile-content {
    padding: 0.5rem;
  }

  .mobile-app .action-card {
    padding: 1rem;
  }

  .mobile-app .photo-modal-image {
    max-height: 60vh;
  }
}

/* ========== Selección de empresa móvil (mobile_seleccionar_empresa.php) ========== */
body.mobile-select-empresa {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  font-family: var(--font-sans);
  background: linear-gradient(165deg, #0c1222 0%, var(--app-primary) 45%, var(--app-primary-hover) 100%);
  -webkit-font-smoothing: antialiased;
}

.mobile-select-empresa .selection-container {
  background: var(--app-surface);
  padding: 2rem;
  border-radius: var(--app-radius);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
  width: 100%;
  max-width: 450px;
  border: 1px solid var(--app-border);
}

.mobile-select-empresa .selection-header {
  text-align: center;
  margin-bottom: 2rem;
}

.mobile-select-empresa .selection-header .icon {
  font-size: 3rem;
  color: var(--app-primary);
  margin-bottom: 1rem;
}

.mobile-select-empresa .selection-header h3 {
  color: var(--app-text);
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.mobile-select-empresa .selection-header p {
  color: var(--app-text-muted);
  margin: 0;
}

.mobile-select-empresa .user-info {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: var(--app-radius);
  padding: 1.2rem;
  margin-bottom: 2rem;
  text-align: center;
}

.mobile-select-empresa .user-info .welcome {
  color: var(--app-text);
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 1.1rem;
}

.mobile-select-empresa .user-info .role {
  color: var(--app-text-muted);
  font-size: 0.9rem;
}

.mobile-select-empresa .form-group {
  margin-bottom: 1.5rem;
}

.mobile-select-empresa .form-group label {
  display: block;
  color: var(--app-text);
  font-weight: 600;
  margin-bottom: 0.8rem;
  font-size: 1rem;
}

.mobile-select-empresa .select-group {
  position: relative;
}

.mobile-select-empresa .select-group i {
  position: absolute;
  left: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--app-text-muted);
  z-index: 5;
}

.mobile-select-empresa .form-control-mobile {
  border-radius: var(--app-radius-sm);
  padding: 1rem 1.2rem 1rem 3rem;
  font-size: 1.1rem;
  border: 2px solid var(--app-border);
  width: 100%;
  background: var(--app-surface);
  color: var(--app-text);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mobile-select-empresa .form-control-mobile:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem var(--app-focus-ring);
  outline: none;
}

.mobile-select-empresa .form-control-mobile option {
  padding: 0.5rem;
  background: var(--app-surface);
  color: var(--app-text);
}

.mobile-select-empresa .continue-button {
  background: linear-gradient(135deg, var(--app-primary), var(--app-primary-hover));
  border: none;
  border-radius: var(--app-radius-sm);
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  width: 100%;
  color: #fff;
  margin-top: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.mobile-select-empresa .continue-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.mobile-select-empresa .continue-button:disabled {
  background: var(--app-text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.mobile-select-empresa .logout-link {
  text-align: center;
  margin-top: 1.5rem;
}

.mobile-select-empresa .logout-link a {
  color: var(--app-text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s;
}

.mobile-select-empresa .logout-link a:hover {
  color: var(--app-primary);
}

.mobile-select-empresa .error-message {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #b91c1c;
  padding: 1rem;
  border-radius: var(--app-radius-sm);
  margin-bottom: 1.5rem;
  text-align: center;
  display: none;
  animation: auth-fade-in 0.3s ease;
}

@media (max-width: 576px) {
  .mobile-select-empresa .selection-container {
    padding: 1.5rem;
    margin: 0.5rem;
  }
}
