/* ====================================================== */
/* VARIABLES CSS Y RESET BÁSICO */
/* ====================================================== */
:root {
  /* Colores Bureau Veritas */
  --bv-primary: #003f7f;
  --bv-secondary: #0066cc;
  --bv-accent: #00a651;
  --bv-light-blue: #e6f2ff;
  --bv-dark-blue: #002d5c;
  
  /* Colores del sistema */
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Estados */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* Espaciado - Ajustado para móviles */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem; /* Reducido de 1rem */
  --space-lg: 1rem;    /* Reducido de 1.5rem */
  --space-xl: 1.5rem;  /* Reducido de 2rem */
  --space-2xl: 2rem;   /* Reducido de 3rem */
  
  /* Tipografía - Optimizada para móviles */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  
  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Bordes */
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-radius-xl: 1rem;
  
  /* Transiciones */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Layout - Responsive */
  --sidebar-width: 280px;
  --header-height: 60px;
  
  /* Touch targets mínimos para móviles */
  --touch-target-min: 44px;
}

/* Touch target adjustments para móviles */
@media (pointer: coarse) {
  :root {
    --space-md: 1rem;
    --space-lg: 1.25rem;
    --space-xl: 1.75rem;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--gray-50);
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; /* Previene zoom automático en iOS */
}

/* ====================================================== */
/* UTILIDADES GLOBALES */
/* ====================================================== */
.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Utilidad para mostrar/ocultar elementos según el dispositivo */
.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

@media (max-width: 992px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none;
  }
}

/* ====================================================== */
/* ANIMACIONES BÁSICAS */
/* ====================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ====================================================== */
/* AUTENTICACIÓN */
/* ====================================================== */
#auth-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bv-primary) 0%, var(--bv-secondary) 100%);
  z-index: 1000;
  padding: var(--space-md);
}

.auth-view {
  width: 100%;
  max-width: 400px;
  animation: slideUp 0.5s ease-out;
}

.auth-box {
  background: var(--white);
  padding: var(--space-xl);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.auth-logo {
  width: 100px;
  max-width: 120px;
  height: auto;
  margin-bottom: var(--space-lg);
}

.auth-box h3 {
  color: var(--bv-primary);
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin-bottom: var(--space-lg);
}

.auth-instructions {
  color: var(--gray-600);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-lg);
  text-align: left;
}

.auth-box form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.auth-box input,
.auth-box select {
  width: 100%;
  padding: var(--space-md);
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-base);
  transition: var(--transition-fast);
  background: var(--white);
  min-height: var(--touch-target-min);
}

.auth-box input:focus,
.auth-box select:focus {
  outline: none;
  border-color: var(--bv-secondary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.auth-box button[type="submit"] {
  width: 100%;
  padding: var(--space-md);
  background: var(--bv-primary);
  color: var(--white);
  border: none;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: var(--touch-target-min);
}

.auth-box button[type="submit"]:hover {
  background: var(--bv-dark-blue);
}

@media (hover: hover) {
  .auth-box button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}

.auth-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.auth-links a {
  color: var(--bv-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  transition: var(--transition-fast);
  padding: var(--space-xs);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-links a:hover {
  color: var(--bv-primary);
  text-decoration: underline;
}

/* ====================================================== */
/* LAYOUT PRINCIPAL */
/* ====================================================== */
#app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Backdrop para móviles */
#app-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1400;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-normal);
}

#app-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-sm);
  z-index: 1500;
}

.logo-container {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--gray-200);
  text-align: center;
}

.logo-container img {
  height: 40px;
  width: auto;
  margin-bottom: var(--space-sm);
}

.logo-container h2 {
  color: var(--bv-primary);
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.sidebar nav {
  flex: 1;
  padding: var(--space-md) 0;
  overflow-y: auto;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  color: var(--gray-600);
  text-decoration: none;
  transition: var(--transition-fast);
  font-weight: 500;
  min-height: var(--touch-target-min);
}

.sidebar nav a:hover {
  background: var(--gray-50);
  color: var(--bv-primary);
}

.sidebar nav a.active {
  background: var(--bv-light-blue);
  color: var(--bv-primary);
  border-right: 3px solid var(--bv-primary);
}

.sidebar .icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

/* User Profile */
.user-profile {
  padding: var(--space-lg);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Permite que el texto se trunque */
}

.user-name {
  font-weight: 500;
  color: var(--gray-800);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  color: var(--gray-500);
  font-size: var(--font-size-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Botón de logout mejorado y más visible */
.logout-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--error);
  color: var(--white);
  border: none;
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-md);
  transition: var(--transition-fast);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  font-size: var(--font-size-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.logout-btn:hover {
  background: #dc2626;
}

.logout-btn .icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.logout-btn span {
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0; /* Importante para evitar overflow */
}

.main-header {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.hamburger-menu {
  display: none;
  background: none;
  border: none;
  color: var(--gray-600);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--border-radius-sm);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
}

.hamburger-menu .icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Logo en el header para mantener presencia corporativa */
.header-logo {
  height: 32px;
  width: auto;
  margin-right: var(--space-sm);
}

.main-header h1 {
  flex: 1;
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--bv-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

#connectivity-status {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius-lg);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

#connectivity-status.online {
  background: var(--success);
  color: var(--white);
}

#connectivity-status.offline {
  background: var(--error);
  color: var(--white);
}

main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-lg);
  -webkit-overflow-scrolling: touch; /* Smooth scrolling en iOS */
}

/* ====================================================== */
/* FORMULARIOS */
/* ====================================================== */
#report-form {
  max-width: 1200px;
  margin: 0 auto;
}

.form-section {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  animation: slideUp 0.3s ease-out;
}

.form-section h2 {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--bv-primary);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.form-section .number {
  background: var(--bv-primary);
  color: var(--white);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 700;
  flex-shrink: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

#image-counter {
  color: var(--gray-500);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

.form-grid > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

label {
  font-weight: 500;
  color: var(--gray-700);
  font-size: var(--font-size-sm);
}

input,
select,
textarea {
  padding: var(--space-md);
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-base);
  transition: var(--transition-fast);
  background: var(--white);
  min-height: var(--touch-target-min);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--bv-secondary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

input.is-invalid,
select.is-invalid {
  border-color: var(--error);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* ====================================================== */
/* SECCIÓN DE FOTOS */
/* ====================================================== */
.photo-actions {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.file-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--bv-secondary);
  color: var(--white);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition-fast);
  text-decoration: none;
  border: none;
  font-size: var(--font-size-base);
  min-height: var(--touch-target-min);
  justify-content: center;
  flex: 1;
  max-width: 200px;
}

.file-label:hover {
  background: var(--bv-primary);
}

@media (hover: hover) {
  .file-label:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}

.file-label.camera {
  background: var(--bv-accent);
}

.file-label.camera:hover {
  background: #008f44;
}

.file-label .icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

input[type="file"] {
  display: none;
}

#photo-preview-container {
  min-height: 200px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--border-radius-lg);
  position: relative;
  transition: var(--transition-fast);
}

#photo-preview-container.dragover {
  border-color: var(--bv-secondary);
  background: var(--bv-light-blue);
}

#photo-preview-container.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.empty-state {
  text-align: center;
  color: var(--gray-500);
}

.empty-state .icon-big {
  width: 48px;
  height: 48px;
  fill: currentColor;
  margin-bottom: var(--space-md);
}

#photo-preview-container:not(.empty) {
  border-style: solid;
  padding: var(--space-lg);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

/* Photo Cards */
.photo-card {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  transition: var(--transition-normal);
  position: relative;
}

.photo-card:hover {
  border-color: var(--bv-secondary);
  box-shadow: var(--shadow-md);
}

@media (hover: hover) {
  .photo-card:hover {
    transform: translateY(-2px);
  }
}

.photo-card.is-dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.photo-card-header {
  padding: var(--space-md);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid var(--gray-200);
}

.photo-checkbox {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.photo-filename {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.photo-img-wrapper {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
}

.preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-normal);
}

.photo-overlay-actions {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  display: flex;
  gap: var(--space-xs);
  opacity: 1; /* Siempre visible en móvil */
  transition: var(--transition-fast);
}

.overlay-btn {
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.overlay-btn:hover {
  background: var(--bv-primary);
}

@media (hover: hover) {
  .overlay-btn:hover {
    transform: scale(1.1);
  }
  
  .photo-overlay-actions {
    opacity: 0;
  }
  
  .photo-card:hover .photo-overlay-actions {
    opacity: 1;
  }
}

.overlay-btn .icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.photo-controls {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.control-group label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--gray-600);
}

.test-search-input,
.comment-input {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  min-height: var(--touch-target-min);
}

.delete-btn {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  border-radius: 50%;
  border: none;
  background: var(--error);
  color: var(--white);
  cursor: pointer;
  font-size: var(--font-size-lg);
  line-height: 1;
  transition: var(--transition-fast);
  opacity: 1; /* Siempre visible en móvil */
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-btn:hover {
  background: #dc2626;
}

@media (hover: hover) {
  .delete-btn {
    opacity: 0;
  }
  
  .photo-card:hover .delete-btn {
    opacity: 1;
  }
  
  .delete-btn:hover {
    transform: scale(1.1);
  }
}

/* Submit Button y Form Actions */
.form-actions {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-xl);
  justify-content: center;
  flex-wrap: wrap;
}

.secondary-button {
  padding: var(--space-lg);
  background: var(--gray-200);
  color: var(--gray-700);
  border: none;
  border-radius: var(--border-radius-lg);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: var(--touch-target-min);
  flex: 1;
  max-width: 300px;
}

.secondary-button:hover:not(:disabled) {
  background: var(--gray-300);
}

.secondary-button:disabled {
  background: var(--gray-100);
  color: var(--gray-400);
  cursor: not-allowed;
}

#submit-button,
#finalize-report-btn {
  padding: var(--space-lg);
  background: var(--bv-accent);
  color: var(--white);
  border: none;
  border-radius: var(--border-radius-lg);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: var(--touch-target-min);
  flex: 1;
  max-width: 300px;
}

#submit-button:hover:not(:disabled),
#finalize-report-btn:hover:not(:disabled) {
  background: #008f44;
}

@media (hover: hover) {
  #submit-button:hover:not(:disabled),
  #finalize-report-btn:hover:not(:disabled),
  .secondary-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }
}

#submit-button:disabled,
#finalize-report-btn:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (max-width: 768px) {
  .form-actions {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .secondary-button,
  #submit-button,
  #finalize-report-btn {
    max-width: none;
    width: 100%;
  }
}

/* ====================================================== */
/* MODALES */
/* ====================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: var(--space-md);
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  background: var(--white);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  animation: slideUp 0.3s ease-out;
  width: 100%;
}

.modal-content.small {
  max-width: 400px;
}

.modal-content.large {
  max-width: 900px;
  height: 80vh;
}

.modal-content.fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  padding: 0;
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--bv-primary);
  margin-right: var(--space-md);
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--gray-400);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.close-btn:hover {
  color: var(--gray-600);
  background: var(--gray-100);
}

.close-btn.fullscreen {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 10;
  background: rgba(0, 0, 0, 0.7);
  color: var(--white);
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  border-radius: 50%;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-lg);
}

.modal-actions {
  padding: var(--space-lg);
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.modal-actions button {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--border-radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: var(--touch-target-min);
  flex: 1;
  max-width: 200px;
}

.modal-actions button.secondary {
  background: var(--gray-200);
  color: var(--gray-700);
  border: none;
}

.modal-actions button.secondary:hover {
  background: var(--gray-300);
}

.modal-actions button:not(.secondary) {
  background: var(--bv-primary);
  color: var(--white);
  border: none;
}

.modal-actions button:not(.secondary):hover {
  background: var(--bv-dark-blue);
}

.modal-actions button.danger {
  background: var(--error);
}

.modal-actions button.danger:hover {
  background: #dc2626;
}

/* Image Preview Modal */
#fullscreen-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--gray-900);
}

/* ====================================================== */
/* PROGRESS Y NOTIFICACIONES */
/* ====================================================== */
#progress-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: var(--space-lg);
}

.progress-container {
  background: var(--white);
  padding: var(--space-xl);
  border-radius: var(--border-radius-xl);
  text-align: center;
  width: 100%;
  max-width: 350px;
  box-shadow: var(--shadow-xl);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-lg);
  border: 4px solid var(--gray-200);
  border-top: 4px solid var(--bv-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

#progress-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--bv-primary);
  margin-bottom: var(--space-sm);
}

#progress-text {
  color: var(--gray-600);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: var(--bv-primary);
  border-radius: var(--border-radius-lg);
  transition: width 0.3s ease;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 350px;
  width: 100%;
}

.toast {
  background: var(--white);
  padding: var(--space-lg);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--error);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast.info {
  border-left-color: var(--info);
}

.toast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.toast-title {
  font-weight: 600;
  color: var(--gray-800);
  font-size: var(--font-size-sm);
}

.toast-close {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0;
  font-size: 18px;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-message {
  color: var(--gray-600);
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

/* ====================================================== */
/* RESPONSIVE DESIGN OPTIMIZADO */
/* ====================================================== */

/* Tablets grandes (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  #photo-preview-container:not(.empty) {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .photo-actions .file-label {
    flex: 0 1 auto;
    min-width: 160px;
  }
}

/* Tablets y móviles grandes (hasta 992px) */
@media (max-width: 992px) {
  :root {
    --sidebar-width: 280px;
    --header-height: 56px;
  }
  
  #app-container {
    position: relative;
    z-index: 1; /* Z-index bajo para no interferir con auth */
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 1500;
    box-shadow: none;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  }
  
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  
  .main-content {
    width: 100%;
    margin-left: 0;
  }
  
  .hamburger-menu {
    display: flex;
  }
  
  .main-header {
    padding: 0 var(--space-md);
  }
  
  .main-header h1 {
    font-size: var(--font-size-lg);
  }
  
  main {
    padding: var(--space-md);
  }
  
  .form-section {
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
  }
  
  .form-section h2 {
    font-size: var(--font-size-lg);
  }
  
  .photo-actions {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .photo-actions .file-label {
    flex: 1;
    max-width: none;
    justify-content: center;
  }
  
  .modal-content.large {
    height: 85vh;
    max-width: 95vw;
  }
  
  .modal-actions {
    padding: var(--space-md);
    gap: var(--space-sm);
  }
  
  .modal-actions button {
    min-width: 120px;
  }
}

/* Móviles (hasta 768px) */
@media (max-width: 768px) {
  :root {
    --space-md: 0.75rem;
    --space-lg: 1rem;
    --space-xl: 1.25rem;
    --space-2xl: 1.5rem;
    --header-height: 52px;
  }
  
  .auth-box {
    padding: var(--space-lg);
    margin: var(--space-md);
  }
  
  .auth-box h3 {
    font-size: var(--font-size-lg);
  }
  
  .logo-container {
    padding: var(--space-md);
  }
  
  .logo-container h2 {
    font-size: var(--font-size-base);
  }
  
  .sidebar nav {
    padding: var(--space-sm) 0;
  }
  
  .sidebar nav a {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
  }
  
  .user-profile {
    padding: var(--space-md);
  }
  
  .main-header {
    padding: 0 var(--space-sm);
  }
  
  .main-header h1 {
    font-size: var(--font-size-base);
  }
  
  .header-logo {
    height: 24px;
  }
  
  main {
    padding: var(--space-sm);
  }
  
  .form-section {
    padding: var(--space-md);
    border-radius: var(--border-radius-md);
  }
  
  .form-section h2 {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-md);
  }
  
  .form-section .number {
    width: 28px;
    height: 28px;
    font-size: var(--font-size-xs);
  }
  
  .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }
  
  .photo-controls {
    padding: var(--space-md);
    gap: var(--space-md);
  }
  
  .modal-overlay {
    padding: var(--space-sm);
    align-items: flex-end;
  }
  
  .modal-content {
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    max-height: 90vh;
    animation: slideUp 0.3s ease-out;
  }
  
  .modal-content.small,
  .modal-content.large {
    max-width: none;
    width: 100%;
    height: auto;
    max-height: 85vh;
  }
  
  .modal-header {
    padding: var(--space-md);
  }
  
  .modal-header h3 {
    font-size: var(--font-size-base);
  }
  
  .modal-body {
    padding: var(--space-md);
  }
  
  .modal-actions {
    flex-direction: column;
    padding: var(--space-md);
  }
  
  .modal-actions button {
    flex: 1;
    max-width: none;
    order: 2;
  }
  
  .modal-actions button.secondary {
    order: 1;
  }
  
  .progress-container {
    padding: var(--space-lg);
    margin: var(--space-sm);
  }
  
  #toast-container {
    top: var(--space-sm);
    right: var(--space-sm);
    left: var(--space-sm);
    max-width: none;
  }
  
  .toast {
    padding: var(--space-md);
  }
  
  #submit-button,
  #finalize-report-btn {
    margin-top: var(--space-lg);
    font-size: var(--font-size-base);
  }
}

/* Móviles pequeños (hasta 480px) */
@media (max-width: 480px) {
  :root {
    --space-sm: 0.375rem;
    --space-md: 0.5rem;
    --space-lg: 0.75rem;
    --space-xl: 1rem;
    --space-2xl: 1.25rem;
    --font-size-base: 0.9rem;
  }
  
  .auth-container {
    padding: var(--space-sm);
  }
  
  .auth-box {
    padding: var(--space-md);
  }
  
  /* Asegurar que el botón de login funcione */
  .auth-box button[type="submit"] {
    min-height: 48px;
    font-size: 16px; /* Evita zoom en iOS */
    -webkit-appearance: none;
    border: none;
    outline: none;
  }
  
  /* Asegurar que los inputs funcionen */
  .auth-box input,
  .auth-box select {
    font-size: 16px; /* Evita zoom en iOS */
    -webkit-appearance: none;
    border-radius: var(--border-radius-md);
  }
  
  .sidebar {
    width: calc(100vw - 60px);
    max-width: 280px;
  }
  
  .main-header h1 {
    font-size: var(--font-size-sm);
  }
  
  #connectivity-status {
    display: none; /* Ocultar en móviles muy pequeños */
  }
  
  .form-section h2 {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }
  
  .photo-card-header {
    padding: var(--space-sm);
  }
  
  .photo-filename {
    font-size: var(--font-size-xs);
  }
  
  .delete-btn,
  .overlay-btn {
    width: 36px;
    height: 36px;
  }
  
  .modal-content.fullscreen {
    border-radius: 0;
  }
  
  .close-btn.fullscreen {
    top: var(--space-sm);
    right: var(--space-sm);
    width: 36px;
    height: 36px;
  }
}

/* ====================================================== */
/* MEJORAS DE ACCESIBILIDAD Y UX MÓVIL */
/* ====================================================== */

/* Mejoras para dispositivos táctiles */
@media (pointer: coarse) {
  /* Aumentar áreas táctiles */
  .sidebar nav a,
  button,
  .file-label,
  input,
  select,
  textarea {
    min-height: 48px;
  }
  
  /* Evitar hover effects en dispositivos táctiles */
  .sidebar nav a:hover,
  .file-label:hover,
  button:hover,
  .photo-card:hover,
  .tool-btn:hover {
    transform: none;
  }
  
  /* Mejorar feedback táctil */
  .sidebar nav a:active,
  button:active,
  .file-label:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
}

/* Reducir animaciones en dispositivos con preferencia reducida */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .sidebar {
    transition: none;
  }
}

/* Focus visible mejorado para navegación por teclado */
:focus-visible {
  outline: 3px solid var(--bv-secondary);
  outline-offset: 2px;
}

/* Estados de validación */
.is-invalid {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.is-invalid-container {
  border-color: var(--error) !important;
}

/* ====================================================== */
/* PRINT STYLES OPTIMIZADOS */
/* ====================================================== */
@media print {
  #auth-container,
  .sidebar,
  .main-header,
  .modal-overlay,
  #progress-overlay,
  #toast-container,
  #app-backdrop,
  button:not(.print-visible),
  .hamburger-menu,
  .photo-overlay-actions,
  .delete-btn {
    display: none !important;
  }
  
  .main-content {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
  }
  
  main {
    padding: 0 !important;
  }
  
  .form-section {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid var(--gray-400);
    margin-bottom: 1rem;
  }
  
  .photo-card {
    break-inside: avoid;
    border: 1px solid var(--gray-400);
  }
  
  .preview-img {
    max-height: 200px;
    object-fit: contain;
  }
  
  /* Ajustar tamaños de fuente para impresión */
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  h1, h2, h3 {
    page-break-after: avoid;
  }
}

/* ====================================================== */
/* ESTILOS AÑADIDOS PARA LA V2 COLABORATIVA */
/* ====================================================== */

/* Estilo para el botón de acción principal en la sidebar */
.sidebar nav a.action-link {
  background-color: var(--bv-primary);
  color: var(--white);
  margin: 0 var(--space-lg) var(--space-lg);
  border-radius: var(--border-radius-md);
  font-weight: 600;
  justify-content: center;
  border-right: none;
}

.sidebar nav a.action-link:hover {
  background-color: var(--bv-dark-blue);
  color: var(--white);
}

/* Estilos para el Dashboard de Informes */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-xl);
}

.report-card,
.skeleton-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  cursor: pointer;
}

.report-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--bv-secondary);
}

.report-card-client {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--bv-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: var(--space-xs);
}

.report-card-id {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-bottom: var(--space-lg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-card-meta {
  font-size: var(--font-size-xs);
  color: var(--gray-500);
  border-top: 1px solid var(--gray-200);
  padding-top: var(--space-lg);
  margin-bottom: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.report-card-photos {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.report-card-photos .icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.skeleton-card {
  height: 180px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite linear;
  cursor: default;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Estilos para el Workspace */
.workspace-header {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  margin-bottom: var(--space-2xl);
  flex-wrap: wrap;
}

.back-button {
  background: none;
  border: 1px solid var(--gray-300);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  font-weight: 500;
  color: var(--gray-700);
  transition: var(--transition-fast);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.back-button:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.workspace-info {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--gray-600);
}

#finalize-report-btn {
  background-color: var(--bv-accent);
}

#finalize-report-btn:hover:not(:disabled) {
  background-color: #008f44;
}

/* Estilos para el Modal de Nuevo Informe */
#new-report-modal h3 {
  padding: var(--space-lg);
  margin: 0;
  border-bottom: 1px solid var(--gray-200);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--bv-primary);
}

#new-report-modal .modal-content {
  padding: 0;
}

#new-report-modal form {
  padding: var(--space-lg);
}

#new-report-modal .control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

#new-report-modal .control-group label {
  font-weight: 500;
  color: var(--gray-700);
  font-size: var(--font-size-sm);
}

#new-report-modal .control-group input,
#new-report-modal .control-group select {
  padding: var(--space-md);
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-base);
  transition: var(--transition-fast);
  background: var(--white);
  min-height: var(--touch-target-min);
}

#new-report-modal .control-group input:focus,
#new-report-modal .control-group select:focus {
  outline: none;
  border-color: var(--bv-secondary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

#new-report-modal .modal-actions {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* Responsive adjustments para V2 */
@media (max-width: 768px) {
  .reports-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
  
  .workspace-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-lg);
  }
  
  .workspace-info {
    font-size: var(--font-size-lg);
    text-align: center;
  }
  
  .back-button {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .reports-grid {
    gap: var(--space-md);
  }
  
  .report-card,
  .skeleton-card {
    padding: var(--space-lg);
  }
  
  .report-card-client {
    font-size: var(--font-size-base);
  }
  
  .workspace-info {
    font-size: var(--font-size-base);
  }
}
/* ====================================== */
/* ESTILOS PARA DASHBOARD COLABORATIVO */
/* ====================================== */

.loading-message, .offline-message, .error-message, .empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 2rem 0;
}

.loading-message p {
    color: #6b7280;
    font-size: 1.1rem;
}

.offline-message {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
}

.error-message {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
}

.error-message button {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 1rem;
}

.empty-state {
    background: #f9fafb;
    border: 2px dashed #d1d5db;
}

.empty-state h3 {
    color: #374151;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.reports-header h2 {
    color: var(--text-color, #1f2937);
    margin: 0;
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 0.5rem;
}

.report-card {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color, #e5e7eb);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.report-header h3 {
    margin: 0;
    color: var(--text-color, #1f2937);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    flex: 1;
    margin-right: 1rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-in-progress {
    background: #dbeafe;
    color: #1e40af;
}

.status-uploading {
    background: #fef3c7;
    color: #b45309;
}

.status-generating {
    background: #e0e7ff;
    color: #5b21b6;
}

.status-unknown {
    background: #f3f4f6;
    color: #6b7280;
}

.report-details {
    margin-bottom: 1.5rem;
}

.report-details p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #6b7280;
}

.report-details strong {
    color: var(--text-color, #1f2937);
    font-weight: 500;
}

.report-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-primary {
    background: var(--primary-color, #003f7f);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-size: 0.9rem;
}

.btn-primary:hover {
    background: var(--secondary-color, #0066cc);
}

.btn-secondary {
    background: #6b7280;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: not-allowed;
    opacity: 0.6;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .reports-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0;
    }
    
    .reports-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .report-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .report-header h3 {
        margin-right: 0;
    }
    
    .status-badge {
        align-self: flex-start;
    }
}