/* ==========================================================================
   FORMULARIO PROFESIONAL DE INCIDENCIAS - DISEÑO COMPACTO Y ELEGANTE
   Optimizado para máxima eficiencia en dispositivos móviles
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Paleta de colores profesional y refinada */
  --primary-50: #f0f9ff;
  --primary-500: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;
  --primary-900: #0c4a6e;
  
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  --success-50: #f0fdf4;
  --success-500: #22c55e;
  --success-600: #16a34a;
  
  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  
  --error-50: #fef2f2;
  --error-500: #ef4444;
  --error-600: #dc2626;
  
  /* Espaciado compacto y eficiente */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  
  /* Radios sutiles */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Sombras elegantes */
  --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);
  
  /* Tipografía optimizada */
  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  
  /* Transiciones suaves */
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET Y BASE
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-50);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */

.container {
  max-width: 100%;
  margin: 0 auto;
  padding: var(--space-4);
  min-height: 100vh;
}

/* ==========================================================================
   HEADER MINIMALISTA
   ========================================================================== */

.header {
  text-align: center;
  padding: var(--space-6) 0 var(--space-4);
  margin-bottom: var(--space-6);
}

.header h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-2);
  letter-spacing: -0.025em;
}

.header p {
  font-size: var(--text-sm);
  color: var(--gray-500);
  font-weight: 500;
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.4;
}

/* ==========================================================================
   FORMULARIO COMPACTO
   ========================================================================== */

.main-content {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  max-width: 400px;
  margin: 0 auto;
}

.incident-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ==========================================================================
   FORM GROUPS COMPACTOS
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.label-text {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  letter-spacing: -0.025em;
}

.label-subtitle {
  font-size: var(--text-xs);
  color: var(--gray-400);
  font-weight: 500;
}

/* ==========================================================================
   INPUTS PROFESIONALES
   ========================================================================== */

.form-input,
.form-select,
.form-textarea {
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  font-weight: 400;
  background: white;
  color: var(--gray-900);
  transition: all var(--transition);
  appearance: none;
  width: 100%;
  min-height: 44px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--gray-400);
  font-weight: 400;
}

/* Estados de validación */
.form-input:valid:not(:placeholder-shown),
.form-select:valid,
.form-textarea:valid:not(:placeholder-shown) {
  border-color: var(--success-500);
}

.form-input:invalid:not(:placeholder-shown),
.form-select:invalid,
.form-textarea:invalid:not(:placeholder-shown) {
  border-color: var(--error-500);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--error-500);
  background: var(--error-50);
}

/* ==========================================================================
   SELECT PERSONALIZADO
   ========================================================================== */

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--space-3) center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: var(--space-8);
  cursor: pointer;
}

.form-select:focus {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%230ea5e9' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* ==========================================================================
   TEXTAREA COMPACTO
   ========================================================================== */

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

.char-counter {
  align-self: flex-end;
  font-size: var(--text-xs);
  color: var(--gray-400);
  font-weight: 500;
  margin-top: var(--space-1);
}

/* ==========================================================================
   OPCIONES DE PRIORIDAD COMPACTAS
   ========================================================================== */

.priority-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.priority-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  background: white;
  min-height: 60px;
  justify-content: center;
}

.priority-option:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-sm);
}

.priority-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.priority-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transition: all var(--transition);
  position: relative;
}

.priority-indicator::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
  transform: translate(-50%, -50%) scale(0);
  transition: all var(--transition);
}

.priority-text {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Estados de prioridad */
.priority-high .priority-indicator {
  background: var(--error-500);
}

.priority-medium .priority-indicator {
  background: var(--warning-500);
}

.priority-low .priority-indicator {
  background: var(--success-500);
}

/* Estados seleccionados */
.priority-option input[type="radio"]:checked + .priority-indicator::after {
  transform: translate(-50%, -50%) scale(1);
}

.priority-high:has(input[type="radio"]:checked) {
  border-color: var(--error-500);
  background: var(--error-50);
}

.priority-medium:has(input[type="radio"]:checked) {
  border-color: var(--warning-500);
  background: var(--warning-50);
}

.priority-low:has(input[type="radio"]:checked) {
  border-color: var(--success-500);
  background: var(--success-50);
}

/* ==========================================================================
   SUBIDA DE IMÁGENES COMPACTA
   ========================================================================== */

.image-upload-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.image-input {
  display: none;
}

.add-image-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1.5px dashed var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  cursor: pointer;
  transition: all var(--transition);
  font-size: var(--text-sm);
  color: var(--gray-600);
  font-weight: 500;
  min-height: 50px;
}

.add-image-btn:hover {
  border-color: var(--primary-400);
  background: var(--primary-50);
  color: var(--primary-700);
}

.btn-icon {
  font-size: var(--text-base);
}

/* ==========================================================================
   PREVIEW DE IMÁGENES COMPACTO
   ========================================================================== */

.image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: var(--space-2);
}

.image-item {
  position: relative;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--gray-200);
  transition: all var(--transition);
}

.image-item:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-remove {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  transition: all var(--transition);
}

.image-remove:hover {
  background: var(--error-600);
  transform: scale(1.1);
}

/* ==========================================================================
   BOTÓN DE ENVÍO PROFESIONAL
   ========================================================================== */

.form-actions {
  margin-top: var(--space-2);
}

.submit-btn {
  width: 100%;
  padding: var(--space-4);
  background: var(--primary-500);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  box-shadow: var(--shadow-sm);
}

.submit-btn:hover:not(:disabled) {
  background: var(--primary-600);
  box-shadow: var(--shadow-md);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.submit-btn:disabled {
  background: var(--gray-300);
  color: var(--gray-500);
  cursor: not-allowed;
}

.submit-btn.loading {
  pointer-events: none;
  background: var(--primary-400);
}

.submit-btn.loading .btn-text {
  opacity: 0.7;
}

/* ==========================================================================
   MENSAJES DE ERROR COMPACTOS
   ========================================================================== */

.error-message {
  color: var(--error-600);
  font-size: var(--text-xs);
  font-weight: 500;
  margin-top: var(--space-1);
  display: none;
  background: var(--error-50);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--error-500);
}

.error-message.show {
  display: block;
}

/* ==========================================================================
   MODALES COMPACTOS
   ========================================================================== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  backdrop-filter: blur(4px);
  padding: var(--space-4);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
}

.modal-header {
  margin-bottom: var(--space-4);
}

.modal-icon {
  font-size: var(--text-2xl);
  display: block;
  margin-bottom: var(--space-3);
}

.modal-header h2 {
  color: var(--gray-900);
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0;
}

.modal-body {
  margin-bottom: var(--space-5);
  color: var(--gray-600);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.modal-body strong {
  color: var(--gray-900);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: center;
}

.modal-btn {
  background: var(--primary-500);
  color: white;
  border: none;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 40px;
}

.modal-btn:hover {
  background: var(--primary-600);
}

/* ==========================================================================
   LOADING SPINNER COMPACTO
   ========================================================================== */

.loading-spinner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(248, 250, 252, 0.9);
  z-index: 999;
  backdrop-filter: blur(4px);
}

.loading-spinner.show {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top: 3px solid var(--primary-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-4);
}

.loading-spinner p {
  color: var(--gray-600);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ==========================================================================
   ANIMACIONES
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Dispositivos muy pequeños */
@media (max-width: 320px) {
  .container {
    padding: var(--space-3);
  }
  
  .main-content {
    padding: var(--space-4);
  }
  
  .header h1 {
    font-size: var(--text-xl);
  }
  
  .priority-options {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  
  .priority-option {
    flex-direction: row;
    gap: var(--space-3);
    justify-content: flex-start;
    text-align: left;
  }
  
  .image-preview {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  }
}

/* Dispositivos pequeños */
@media (max-width: 375px) {
  .main-content {
    max-width: 100%;
  }
  
  .image-preview {
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  }
}

/* Dispositivos medianos */
@media (min-width: 376px) and (max-width: 768px) {
  .main-content {
    max-width: 420px;
  }
  
  .header h1 {
    font-size: var(--text-2xl);
  }
  
  .header p {
    font-size: var(--text-base);
    max-width: 320px;
  }
  
  .image-preview {
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
  }
}

/* Tablets */
@media (min-width: 769px) {
  .container {
    padding: var(--space-8);
  }
  
  .main-content {
    max-width: 480px;
    padding: var(--space-8);
  }
  
  .header {
    padding: var(--space-8) 0 var(--space-6);
  }
  
  .header h1 {
    font-size: var(--text-2xl);
  }
  
  .header p {
    font-size: var(--text-base);
    max-width: 400px;
  }
  
  .incident-form {
    gap: var(--space-6);
  }
  
  .image-preview {
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  }
  
  .modal-content {
    max-width: 400px;
  }
}

/* ==========================================================================
   UTILIDADES
   ========================================================================== */

.modal-open {
  overflow: hidden;
}

*:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

::selection {
  background: var(--primary-100);
  color: var(--primary-900);
}

/* ==========================================================================
   OPTIMIZACIONES TÁCTILES
   ========================================================================== */

@media (hover: none) {
  .priority-option:hover {
    border-color: var(--gray-200);
    box-shadow: none;
  }
  
  .priority-option:active {
    transform: scale(0.98);
  }
  
  .submit-btn:active:not(:disabled) {
    transform: scale(0.98);
  }
}

/* ==========================================================================
   ACCESIBILIDAD
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  .form-input,
  .form-select,
  .form-textarea {
    border-width: 2px;
  }
  
  .priority-option {
    border-width: 2px;
  }
}