/* ==========================================================================
   WillsTech - Portal de Servicio Técnico y Postventa (Estilos Apple Glass)
   ========================================================================== */

:root {
  --bg-app: #f5f5f7;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --bg-input: #fbfbfd;
  
  --text-primary: #1d1d1f;
  --text-secondary: #58585e;
  --text-muted: #86868b;
  
  --accent-blue: #0071e3;
  --accent-blue-hover: #0077ed;
  --accent-indigo: #5856d6;
  --accent-green: #34c759;
  --accent-green-hover: #30b753;
  --accent-orange: #ff9500;
  --accent-red: #ff3b30;
  --accent-purple: #af52de;
  
  --border-subtle: rgba(0, 0, 0, 0.1);
  --border-focus: #0071e3;
  
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.08), 0 2px 5px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.05);
  --shadow-modal: 0 24px 70px rgba(0, 0, 0, 0.22), 0 6px 18px rgba(0, 0, 0, 0.1);
  
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  --font-headings: 'Outfit', -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   1. Pantalla de Autenticación / Login (Touch Friendly)
   ========================================================================== */
.auth-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 10% 20%, rgba(88, 86, 214, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 90% 80%, rgba(0, 113, 227, 0.08) 0%, transparent 50%),
              #f5f5f7;
  z-index: 9999;
}

.auth-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-xl);
  padding: 2.75rem 2.25rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.brand-bolt {
  font-size: 2rem;
  line-height: 1;
}

.brand-title {
  font-family: var(--font-headings);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.auth-title {
  font-family: var(--font-headings);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 0.35rem;
}

.role-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.1rem 0.85rem;
  min-height: 90px;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: #fafafc;
  transition: all 0.2s ease;
  position: relative;
  text-align: center;
}

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

.role-option.active {
  border-color: var(--accent-blue);
  background: rgba(0, 113, 227, 0.06);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.role-icon {
  font-size: 1.75rem;
  margin-bottom: 0.4rem;
}

.role-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.role-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.25;
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrapper .form-control {
  padding-right: 3.5rem;
}

.btn-toggle-pwd {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.35rem;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  opacity: 0.65;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-error-msg {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.25);
  color: var(--accent-red);
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

.auth-footer {
  margin-top: 1.75rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ==========================================================================
   2. Tablero Principal y Topbar (Touch Friendly)
   ========================================================================== */
.app-dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.service-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 72px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  gap: 1rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-company {
  font-family: var(--font-headings);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: block;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.google-sync-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #f0f3f6;
  border: 1px solid var(--border-subtle);
  padding: 0.55rem 1rem;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(52, 199, 89, 0.7);
  transition: all 0.25s ease;
}

.sync-dot.syncing {
  background: var(--accent-orange);
  box-shadow: 0 0 8px rgba(255, 149, 0, 0.8);
  animation: pulse-sync 1s infinite alternate ease-in-out;
}

@keyframes pulse-sync {
  0% { transform: scale(0.9); opacity: 0.5; }
  100% { transform: scale(1.25); opacity: 1; }
}

.user-role-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 113, 227, 0.08);
  color: var(--accent-blue);
  border: 1.5px solid rgba(0, 113, 227, 0.25);
  padding: 0.55rem 1rem;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 700;
}

.role-text-mob {
  display: none;
}

.btn-text-short {
  display: none;
}

/* ==========================================================================
   Botones de Acción Táctiles (Min 48px Touch Target)
   ========================================================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  min-height: 48px;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 3px 10px rgba(0, 113, 227, 0.3);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #f0f0f3;
  color: var(--text-primary);
  border: 1.5px solid var(--border-subtle);
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-secondary:active {
  transform: scale(0.97);
  background: #e5e5ea;
}

.btn-icon-only {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
}

.btn-block {
  width: 100%;
  min-height: 52px;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(255, 59, 48, 0.12);
  color: var(--accent-red);
  border: 1.5px solid rgba(255, 59, 48, 0.3);
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #25d366;
  color: #ffffff;
  border: none;
  min-height: 48px;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-touch {
  min-height: 50px;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.8rem 1.2rem;
}

/* ==========================================================================
   KPI Cards / Métricas Grandes
   ========================================================================== */
.service-main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  padding: 1.25rem 1.4rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.kpi-card.active {
  border-color: var(--accent-blue);
  background: rgba(0, 113, 227, 0.05);
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.15);
}

.kpi-value {
  font-family: var(--font-headings);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.kpi-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

/* ==========================================================================
   Filtros y Búsqueda Táctil
   ========================================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 320px;
}

.search-box {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
  width: 22px;
  height: 22px;
}

.search-input {
  width: 100%;
  min-height: 52px;
  padding: 0.8rem 2.5rem 0.8rem 3.2rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-subtle);
  background: var(--bg-card);
  font-size: 1.05rem;
  font-family: var(--font-family);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

.search-clear {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chip {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  padding: 0.65rem 1.1rem;
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  transition: all 0.18s ease;
}

.chip.active {
  background: var(--text-primary);
  color: #ffffff;
  border-color: var(--text-primary);
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  min-height: 48px;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ==========================================================================
   Grilla y Tarjetas de Órdenes de Servicio
   ========================================================================== */
.tickets-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.4rem;
}

.ticket-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.2rem;
  transition: all 0.2s ease;
}

.ticket-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ticket-id {
  font-family: var(--font-headings);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-copy-id {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 14px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-Recibido { background: rgba(0, 113, 227, 0.12); color: var(--accent-blue); }
.status-Diagnóstico { background: rgba(175, 82, 222, 0.14); color: var(--accent-purple); }
.status-Repuesto { background: rgba(255, 149, 0, 0.15); color: var(--accent-orange); }
.status-Reparación { background: rgba(0, 113, 227, 0.18); color: #0056b3; }
.status-Listo { background: rgba(52, 199, 89, 0.18); color: #1f7a35; }
.status-Entregado { background: rgba(110, 110, 115, 0.15); color: var(--text-secondary); }
.status-Garantía { background: rgba(255, 59, 48, 0.15); color: var(--accent-red); }

.ticket-client {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.85rem;
}

.client-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.client-phone-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  color: #25d366;
  text-decoration: none;
  font-weight: 700;
  background: rgba(37, 211, 102, 0.12);
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
  min-height: 40px;
}

.ticket-device-box {
  background: #f8f8fa;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.ticket-device-box.has-preview {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.device-info-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ticket-quick-thumb-wrapper {
  position: relative;
  width: 76px;
  height: 76px;
  min-width: 76px;
  min-height: 76px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--border-subtle);
  background: #1c1c1e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ticket-quick-thumb-wrapper:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

.ticket-quick-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.quick-thumb-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
}

.quick-thumb-zoom-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.92);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.ticket-quick-thumb-wrapper:hover .quick-thumb-zoom-icon {
  opacity: 1;
}

.device-type-model {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.device-issue {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 0.35rem;
}

.ticket-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.ticket-photos-count {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--accent-blue);
  background: rgba(0, 113, 227, 0.1);
  padding: 0.3rem 0.65rem;
  border-radius: 10px;
  font-size: 0.88rem;
}

.ticket-card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1.5px solid rgba(0, 0, 0, 0.06);
}

.ticket-card-actions .btn-secondary {
  flex: 1;
  min-height: 48px;
}

/* ==========================================================================
   3. Modal Táctil y Selector de Modo (Rápido vs Avanzado)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-dialog {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 940px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

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

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ticket-id-tag {
  background: #1d1d1f;
  color: #ffffff;
  font-family: var(--font-headings);
  font-size: 0.95rem;
  font-weight: 800;
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  letter-spacing: 0.04em;
}

.modal-title {
  font-family: var(--font-headings);
  font-size: 1.35rem;
  font-weight: 700;
}

.btn-close {
  background: #f0f0f3;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Selector de Modo Rápido vs Avanzado */
.modal-mode-bar {
  padding: 0.75rem 2rem;
  background: #f3f5f9;
  border-bottom: 1.5px solid var(--border-subtle);
}

.mode-segmented-control {
  display: flex;
  background: #e2e6ee;
  border-radius: var(--radius-md);
  padding: 5px;
  gap: 6px;
}

.mode-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.mode-tab-btn.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.tab-icon {
  font-size: 1.2rem;
}

.tab-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent-blue);
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
}

/* Reglas de Visualización según el Modo */
.ticket-form.mode-simple .advance-only {
  display: none !important;
}

.ticket-form.mode-advance .advance-only {
  display: flex !important;
}

.ticket-form.mode-advance div.advance-only {
  display: block !important;
}

.ticket-form.mode-advance .form-row.advance-only {
  display: flex !important;
}

.modal-body {
  padding: 1.75rem 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.modal-footer {
  padding: 1.25rem 2rem;
  border-top: 1.5px solid var(--border-subtle);
  background: #fafafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.modal-footer-utilities,
.modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* ==========================================================================
   Controles de Formulario Táctiles Grandes
   ========================================================================== */
.form-section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-subtle);
}

.section-icon {
  font-size: 1.2rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1rem;
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.form-row {
  display: flex;
  gap: 1.1rem;
}

.form-row-highlight {
  background: #f4f6fa;
  padding: 1.2rem;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(0, 113, 227, 0.18);
}

.flex-1 { flex: 1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-control,
.form-control-touch {
  font-family: var(--font-family);
  font-size: 1.05rem;
  min-height: 52px;
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: all 0.18s ease;
}

.form-control:focus,
.form-control-touch:focus {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.18);
}

textarea.form-control-touch {
  min-height: 80px;
  line-height: 1.4;
}

.form-select-status {
  font-weight: 700;
  color: var(--accent-blue);
  background-color: #ffffff;
}

.input-with-action {
  display: flex;
  gap: 0.5rem;
}

.btn-input-action {
  background: #25d366;
  border: none;
  color: #ffffff;
  min-width: 52px;
  min-height: 52px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Atajos Rápidos de 1 Toque (Quick Chips)
   ========================================================================== */
.quick-chips-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.quick-chips-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.quick-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.quick-chip {
  background: #f0f4f9;
  border: 1.5px solid rgba(0, 113, 227, 0.18);
  color: var(--text-primary);
  padding: 0.6rem 1rem;
  border-radius: 20px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
  user-select: none;
}

.quick-chip:active {
  transform: scale(0.96);
}

.quick-chip.active {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

/* ==========================================================================
   Botones Táctiles para Fotos WebP
   ========================================================================== */
.photo-upload-zone {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.photo-actions-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-camera-touch,
.btn-gallery-touch {
  flex: 1;
  min-height: 56px;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.9rem 1.4rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-camera-touch {
  background: #e8f3ff;
  color: var(--accent-blue);
  border: 2px solid rgba(0, 113, 227, 0.3);
}

.btn-camera-touch:active {
  background: #d4e8ff;
  transform: scale(0.98);
}

.btn-gallery-touch {
  background: #f0f0f5;
  color: var(--text-primary);
  border: 2px solid var(--border-subtle);
}

.btn-gallery-touch:active {
  background: #e5e5ea;
  transform: scale(0.98);
}

.hidden-input { display: none; }

.photo-hint-text {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.photo-alt-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -0.35rem;
}

.btn-link-cam {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition: opacity 0.15s ease;
}

.btn-link-cam:hover {
  color: var(--accent-blue-hover);
  opacity: 0.85;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  min-height: 80px;
  background: #f9f9fb;
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.photo-thumb-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1.5px solid var(--border-subtle);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.photo-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

/* ==========================================================================
   Bitácora de Notas
   ========================================================================== */
.notes-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.notes-feed {
  background: #f8f8fa;
  border-radius: var(--radius-md);
  padding: 1.1rem;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1.5px solid var(--border-subtle);
}

.note-item {
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.note-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.note-author {
  font-weight: 700;
  color: var(--accent-blue);
}

.note-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.no-notes-hint {
  font-size: 0.92rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.75rem;
}

.new-note-box {
  display: flex;
  gap: 0.75rem;
}

.new-note-box .form-control {
  flex: 1;
}

/* ==========================================================================
   Lightbox / Visor en Pantalla Completa
   ========================================================================== */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
}

.lightbox-content {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: -50px;
  right: 0;
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: #ffffff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-counter {
  position: absolute;
  bottom: -40px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  font-weight: 600;
}

.lightbox-nav {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  padding: 0 1rem;
}

.lightbox-btn {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: #ffffff;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  font-size: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
}

/* ==========================================================================
   Modal de Cámara en Vivo / Webcam
   ========================================================================== */
.modal-camera-dialog {
  max-width: 620px;
  width: 100%;
}

.modal-camera-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.live-camera-view {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-stream-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-camera-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-snap-photo {
  min-height: 48px;
  padding: 0.75rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 800;
}

/* ==========================================================================
   Comprobante Imprimible (@media print)
   ========================================================================== */
@media print {
  body * {
    visibility: hidden;
  }

  .printable-ticket,
  .printable-ticket * {
    visibility: visible;
  }

  .printable-ticket {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin: 0;
    padding: 1.5cm;
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
  }

  .receipt-container {
    max-width: 700px;
    margin: 0 auto;
    border: 1px solid #000000;
    padding: 1.5rem;
  }

  .receipt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
  }

  .receipt-brand h2 {
    font-size: 18pt;
    font-weight: 800;
  }

  .receipt-order-id {
    font-size: 16pt;
    font-weight: 800;
    border: 2px solid #000000;
    padding: 0.3rem 0.6rem;
  }

  .receipt-divider {
    border-top: 1px dashed #000000;
    margin: 0.8rem 0;
  }

  .receipt-section h3 {
    font-size: 11pt;
    font-weight: 700;
    margin-bottom: 0.4rem;
  }

  .receipt-section p {
    margin: 0.25rem 0;
    font-size: 10.5pt;
  }

  .receipt-terms {
    font-size: 8.5pt;
    margin: 0.8rem 0;
    color: #444;
  }

  .receipt-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
    padding-top: 1rem;
  }

  .signature-box {
    width: 45%;
    text-align: center;
  }

  .signature-line {
    border-top: 1px solid #000000;
    margin-bottom: 0.4rem;
  }
}

/* ==========================================================================
   Toast de Sincronización Flotante (No Bloqueante)
   ========================================================================== */
.sync-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(29, 29, 31, 0.94);
  color: #ffffff;
  padding: 0.8rem 1.4rem;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.sync-toast.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

.sync-toast.toast-success {
  border-color: rgba(52, 199, 89, 0.5);
  box-shadow: 0 8px 24px rgba(52, 199, 89, 0.2);
}

.sync-toast.toast-warning {
  border-color: rgba(255, 149, 0, 0.5);
}

/* ==========================================================================
   Adaptabilidad Móvil y Táctil Optimizada
   ========================================================================== */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  body {
    font-size: 0.95rem;
  }

  /* 1. Topbar en Móvil: Todo en una sola fila sin desbordamiento */
  .service-topbar {
    padding: 0.5rem 0.75rem;
    min-height: 56px;
    gap: 0.45rem;
  }

  .topbar-brand {
    gap: 0.4rem;
    min-width: 0;
  }

  .brand-bolt {
    font-size: 1.35rem;
  }

  .brand-company {
    font-size: 1.05rem;
  }

  .brand-sub {
    display: none !important;
  }

  .google-sync-badge {
    display: none !important;
  }

  .topbar-actions {
    gap: 0.35rem;
  }

  .user-role-badge {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
    border-radius: 16px;
    gap: 0.3rem;
  }

  .role-text-desk {
    display: none !important;
  }

  .role-text-mob {
    display: inline !important;
  }

  .btn-text-full {
    display: none !important;
  }

  .btn-text-short {
    display: inline !important;
  }

  #btnOpenNewTicket {
    min-height: 38px;
    padding: 0.45rem 0.75rem;
    font-size: 0.84rem;
    gap: 0.3rem;
  }

  #btnLogout {
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
    padding: 0;
  }

  /* 2. KPI Grid en Móvil: Tira horizontal desplazable elegante (60px alto) */
  .service-main {
    padding: 0.75rem;
    gap: 0.85rem;
  }

  .kpi-grid {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.2rem 0.1rem 0.5rem 0.1rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .kpi-grid::-webkit-scrollbar {
    display: none;
  }

  .kpi-card {
    flex: 0 0 auto;
    min-width: 108px;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    scroll-snap-align: start;
    border-width: 1.5px;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  .kpi-label {
    font-size: 0.75rem;
    white-space: nowrap;
    margin-top: 0.15rem;
  }

  /* 3. Barra de Búsqueda y Filtros en Móvil */
  .filter-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .search-row {
    width: 100%;
    min-width: 0;
    gap: 0.4rem;
  }

  .search-input {
    min-height: 44px;
    padding: 0.55rem 2rem 0.55rem 2.4rem;
    font-size: 0.95rem;
  }

  .search-icon {
    left: 0.75rem;
    width: 18px;
    height: 18px;
  }

  .btn-refresh {
    min-height: 44px;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
  }

  .refresh-text {
    display: none;
  }

  .filter-chips {
    width: 100%;
    gap: 0.35rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .filter-chips::-webkit-scrollbar {
    display: none;
  }

  .chip {
    min-height: 36px;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
  }

  /* 4. Grilla de Tarjetas en Móvil */
  .tickets-container {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .ticket-card {
    padding: 1.1rem;
    gap: 0.85rem;
    border-radius: var(--radius-md);
  }

  .ticket-id {
    font-size: 1.05rem;
  }

  .client-name {
    font-size: 1.05rem;
  }

  .ticket-device-box {
    padding: 0.75rem 0.85rem;
  }

  .ticket-device-box.has-preview {
    gap: 0.75rem;
  }

  .ticket-quick-thumb-wrapper {
    width: 68px;
    height: 68px;
    min-width: 68px;
    min-height: 68px;
    border-radius: 8px;
  }

  .ticket-card-actions {
    gap: 0.5rem;
    padding-top: 0.65rem;
  }

  .ticket-card-actions .btn-secondary {
    min-height: 42px;
    font-size: 0.9rem;
  }

  /* 5. MODAL EN MÓVIL: Full Screen / Pantalla Completa Limpia */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
  }

  .modal-title-group {
    gap: 0.5rem;
    min-width: 0;
  }

  .ticket-id-tag {
    font-size: 0.82rem;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
  }

  .modal-title {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn-close {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  /* Selector de Modo: Ocultar badges largos para que no se desborden */
  .modal-mode-bar {
    padding: 0.4rem 0.85rem;
    flex-shrink: 0;
  }

  .mode-segmented-control {
    padding: 3px;
    gap: 4px;
  }

  .mode-tab-btn {
    min-height: 38px;
    padding: 0.4rem 0.6rem;
    font-size: 0.88rem;
    gap: 0.4rem;
  }

  .desk-only {
    display: none !important;
  }

  /* Cuerpo del Formulario */
  .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.9rem 1rem 1.25rem;
    gap: 1.1rem;
  }

  .form-grid-3 {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .span-2,
  .span-3 {
    grid-column: span 1;
  }

  .form-row {
    flex-direction: column;
    gap: 0.85rem;
  }

  .form-section-title {
    font-size: 0.95rem;
    padding-bottom: 0.35rem;
    margin-top: 0.25rem;
  }

  .form-control,
  .form-control-touch {
    min-height: 44px;
    font-size: 16px; /* Evita zoom automático invasivo en iOS */
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
  }

  textarea.form-control-touch {
    min-height: 70px;
  }

  .btn-input-action {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.2rem;
  }

  .quick-chips-wrapper {
    gap: 0.35rem;
  }

  .quick-chips-label {
    font-size: 0.78rem;
  }

  .quick-chips-list {
    gap: 0.4rem;
  }

  .quick-chip {
    min-height: 36px;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 16px;
  }

  /* Botones de Cámara y Galería en 2 columnas paralelas */
  .photo-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .btn-camera-touch,
  .btn-gallery-touch {
    width: 100%;
    min-height: 46px;
    padding: 0.5rem 0.6rem;
    font-size: 0.84rem;
    gap: 0.4rem;
    border-radius: 10px;
  }

  .btn-camera-touch svg,
  .btn-gallery-touch svg {
    width: 18px;
    height: 18px;
  }

  .photo-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 0.6rem;
    padding: 0.6rem;
  }

  /* FOOTER DEL MODAL EN MÓVIL: Siempre visible y botón "Guardar" accesible */
  .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 60;
    background: #ffffff;
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.06);
    padding: 0.65rem 1rem max(0.65rem, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
  }

  .modal-footer-utilities {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
  }

  .btn-util {
    flex: 1;
    min-height: 38px;
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
  }

  .modal-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
  }

  .btn-cancel-action {
    flex: 1;
    min-height: 46px;
    font-size: 0.95rem;
    border-radius: 10px;
    justify-content: center;
  }

  .btn-save-action {
    flex: 2;
    min-height: 46px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    justify-content: center;
  }

  .sync-toast {
    bottom: 5.2rem;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: max-content;
    max-width: 90vw;
    font-size: 0.84rem;
    padding: 0.65rem 1.1rem;
  }

  .sync-toast.hidden {
    transform: translateX(-50%) translateY(20px) scale(0.95);
  }
}

