/* ==========================================================================
   RB HAVEN — SISTEMA DE ÓRDENES DE TRABAJO (Metodología BYPASS / VI.A.S Lab)
   Design System: Dark Mode Minimalista, Alto Rendimiento, Mobile-First
   Colores: Azul Oscuro #0d1b2a, Dorado #f5a623, Blanco #ffffff, Verde #22c55e, Rojo #ef4444
   ========================================================================== */

:root {
  font-size: 16px;
  --rbh-navy: #0d1b2a;
  --rbh-navy-light: #1b263b;
  --rbh-navy-surface: #152754;
  --rbh-gold: #f5a623;
  --rbh-gold-hover: #d98e19;
  --rbh-white: #ffffff;
  --rbh-green: #22c55e;
  --rbh-green-hover: #16a34a;
  --rbh-red: #ef4444;
  --rbh-gray-muted: #94a3b8;
  --rbh-gray-light: #e2e8f0;

  --bg-main: #0d1b2a;
  --bg-surface: #132238;
  --bg-card: #1b2a4a;
  --bg-card-hover: #22355c;
  --bg-input: #0a1322;
  
  --border-subtle: #2d3e66;
  --border-focus: #f5a623;
  --border-danger: #ef4444;

  --text-primary: #ffffff;
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  --text-inverse: #0d1b2a;

  --accent-primary: #f5a623;
  --accent-primary-hover: #d98e19;
  --accent-success: #22c55e;
  --accent-warning: #f5a623;
  --accent-danger: #ef4444;
  --accent-cyan: #06b6d4;

  /* Categorías de Oficio */
  --cat-plomeria: #3b82f6;
  --cat-electrodomesticos: #f97316;
  --cat-pintura: #ef4444;
  --cat-screens: #10b981;
  --cat-ventanas: #eab308;
  --cat-aseo: #94a3b8;
  --cat-otro: #a855f7;

  /* Estados de OT */
  --st-reportada: #3b82f6;
  --st-evaluada: #8b5cf6;
  --st-asignada: #06b6d4;
  --st-coordinada: #f59e0b;
  --st-en_progreso: #f97316;
  --st-completada: #22c55e;
  --st-verificada: #059669;
  --st-pago_liberado: #22c55e;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-heading: 'Poppins', var(--font-sans);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-drawer: -8px 0 32px rgba(0, 0, 0, 0.7);
  --transition-fast: 0.18s ease;
}

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

/* Accessibility Focus States */
:focus-visible {
  outline: 3px solid var(--rbh-gold);
  outline-offset: 2px;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout General Header & Navigation */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  color: #ffffff;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
}

.role-nav {
  display: flex;
  align-items: center;
  background: var(--bg-main);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 0.35rem;
}

.role-tab {
  padding: 0.6rem 1rem;
  min-height: 48px;
  min-width: 48px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.role-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.role-tab.active {
  background: var(--rbh-gold);
  color: #0d1b2a;
  box-shadow: 0 2px 10px rgba(245, 166, 35, 0.4);
}

.main-container {
  flex: 1;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Encabezados y Títulos */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.5rem; /* Min 20px compliant */
  font-weight: 800;
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.page-desc {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 0.25rem;
}

/* Botones Principales */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 56px;
  min-width: 48px;
  padding: 0.9rem 1.5rem;
  font-size: 1.125rem; /* 18px */
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  font-family: inherit;
  box-sizing: border-box;
}

.btn-primary {
  background: var(--rbh-gold);
  color: #0d1b2a;
  border: 1px solid var(--rbh-gold);
}
.btn-primary:hover {
  background: var(--rbh-gold-hover);
  box-shadow: 0 4px 14px rgba(245, 166, 35, 0.4);
}

.btn-success {
  background-color: var(--rbh-green);
  color: #ffffff;
  border: 1px solid var(--rbh-green);
}
.btn-success:hover {
  background-color: var(--rbh-green-hover);
}

.btn-danger {
  background-color: var(--rbh-red);
  color: #ffffff;
}

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

.btn-sm {
  padding: 0.6rem 1rem;
  font-size: 1rem;
  min-height: 48px;
}

.btn-block {
  width: 100%;
}

.btn-camera {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #ffffff;
  border: 2px solid var(--rbh-gold);
  padding: 1.25rem 1.5rem;
  font-size: 1.15rem;
  min-height: 80px;
  width: 100%;
  text-align: center;
  justify-content: center;
  font-weight: 800;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Badges y Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Categorías */
.badge-cat-plomeria { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.4); }
.badge-cat-electrodomesticos { background: rgba(249, 115, 22, 0.2); color: #fdba74; border: 1px solid rgba(249, 115, 22, 0.4); }
.badge-cat-pintura { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-cat-screens { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.4); }
.badge-cat-ventanas { background: rgba(234, 179, 8, 0.2); color: #fde047; border: 1px solid rgba(234, 179, 8, 0.4); }
.badge-cat-aseo { background: rgba(148, 163, 184, 0.2); color: #e2e8f0; border: 1px solid rgba(148, 163, 184, 0.4); }
.badge-cat-otro { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.4); }

/* Estados */
.badge-st-REPORTADA { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border: 1px solid #3b82f6; }
.badge-st-EVALUADA { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; border: 1px solid #8b5cf6; }
.badge-st-ASIGNADA { background: rgba(6, 182, 212, 0.2); color: #67e8f9; border: 1px solid #06b6d4; }
.badge-st-COORDINADA { background: rgba(245, 158, 11, 0.2); color: #fde047; border: 1px solid #f59e0b; }
.badge-st-EN_PROGRESO { background: rgba(249, 115, 22, 0.25); color: #fdba74; border: 1px solid #f97316; animation: pulse-slow 2s infinite; }
.badge-st-COMPLETADA { background: rgba(34, 197, 94, 0.25); color: #86efac; border: 1px solid #22c55e; }
.badge-st-VERIFICADA { background: rgba(5, 150, 105, 0.3); color: #6ee7b7; border: 1px solid #059669; }
.badge-st-PAGO_LIBERADO { background: rgba(34, 197, 94, 0.3); color: #86efac; border: 1px solid #22c55e; }

.badge-urgente { background: rgba(239, 68, 68, 0.25); color: #fca5a5; border: 1px solid #ef4444; }

@keyframes pulse-slow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Form Formularios Mobile First */
.form-card {
  max-width: 680px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  padding-bottom: 80px; /* Previene tapado por teclado móvil */
}

.form-group {
  margin-bottom: 1.25rem; /* Min 16px gap */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.form-label {
  font-size: 15px; /* Form labels 15px bold */
  font-weight: 700;
  color: var(--text-secondary);
}

.form-select, .form-input, .form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 16px; /* Min 16px font-size to prevent iOS zoom */
  min-height: 48px; /* Min 48px height */
  font-family: inherit;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}

.form-select:focus, .form-input:focus, .form-textarea:focus {
  border-color: var(--border-focus);
}

/* Filtros y Barra de Control */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-surface);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-width: 200px;
}

.filter-label {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 700;
}

/* Tabla Desktop */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.ot-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.ot-table th {
  background: var(--bg-card);
  padding: 1.1rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
}

.ot-table td {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 1rem;
}

.ot-row {
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.ot-row:hover {
  background-color: var(--bg-card-hover);
}

/* Drawer Lateral */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: none;
}

.drawer-backdrop.active {
  display: block;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 520px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-drawer);
  z-index: 55;
  padding: 1.5rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.drawer-panel.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
}

/* Alertas */
.alert {
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.alert-info {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

.alert-success {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.5);
  color: #86efac;
}

/* Gamificación y Estrellas */
.stars-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
}

.star-anim {
  font-size: 48px;
  color: var(--rbh-gold);
  display: inline-block;
  animation: star-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.star-anim:nth-child(1) { animation-delay: 0.05s; }
.star-anim:nth-child(2) { animation-delay: 0.15s; }
.star-anim:nth-child(3) { animation-delay: 0.25s; }
.star-anim:nth-child(4) { animation-delay: 0.35s; }
.star-anim:nth-child(5) { animation-delay: 0.45s; }

@keyframes star-pop {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  70% { transform: scale(1.25) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Responsive Rules & Mobile Navigation */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .app-header {
    padding: 0.75rem 1rem;
  }

  .brand-subtitle {
    display: none;
  }

  .role-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #0d1b2a;
    border-top: 1px solid var(--border-subtle);
    border-radius: 0;
    padding: 0.5rem 0.25rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
  }

  .role-tab {
    flex: 1;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.75rem;
    text-align: center;
    padding: 0.4rem 0.2rem;
    min-height: 52px;
    justify-content: center;
    border-radius: 0.5rem;
  }

  .nav-icon {
    font-size: 1.35rem;
    line-height: 1;
  }

  .nav-text {
    font-size: 0.72rem;
    font-weight: 700;
  }

  .main-container {
    padding: 1rem 0.75rem 100px 0.75rem; /* space for fixed bottom navigation bar */
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header .btn {
    width: 100%;
  }
}

@media (min-width: 769px) {
  .mobile-only {
    display: none !important;
  }
}
