/* app.css - Estilos para PWA Tickets */

:root {
  --primary: #198754;
  --primary-dark: #146c43;
  --header-height: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  padding-top: var(--header-height);
}

/* Header fijo */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--primary);
  color: white;
  padding: 0 12px;
  display: flex;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Indicador de estado */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.online { background: #4ade80; }
.status-dot.offline { background: #ef4444; }
.status-dot.syncing { background: #facc15; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Contenido principal */
.app-main {
  padding: 12px;
  max-width: 960px;
  margin: 0 auto;
}

/* En pantallas grandes, estirar más */
@media (min-width: 768px) {
  .app-main {
    padding: 16px 24px;
    max-width: 1200px;
  }
}

/* Vistas */
.view {
  animation: fadeIn 0.2s ease;
}

/* Login centrado en pantallas grandes */
#viewLogin {
  max-width: 420px;
  margin: 0 auto;
}

/* Lista de tickets estira completo */
#viewList, #viewTicket, #viewConfig {
  width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Lista de tickets */
.ticket-item {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ticket-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.ticket-item.pendiente {
  border-left: 4px solid #f59e0b;
}
.ticket-item.enviado {
  border-left: 4px solid #22c55e;
}
.ticket-item .titulo {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.ticket-item .meta {
  font-size: 0.8rem;
  color: #6b7280;
}
.ticket-item .proyecto {
  font-size: 0.75rem;
  background: #e5e7eb;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 4px;
}

/* Slots de imagen */
.img-slot-container {
  position: relative;
}
.img-slot {
  aspect-ratio: 1;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #f9fafb;
  position: relative;
}
.img-slot.has-image {
  border-style: solid;
  border-color: var(--primary);
}
.img-placeholder {
  text-align: center;
  color: #9ca3af;
  font-size: 0.75rem;
}
.img-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.btn-img-action {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-img-action:active {
  transform: scale(0.95);
}
.img-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.btn-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

/* Toast */
.toast {
  background: #1f2937;
  color: white;
}

/* Tabs */
.nav-tabs .nav-link {
  color: #6b7280;
  border: none;
  padding: 8px 12px;
  font-size: 0.9rem;
}
.nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  background: transparent;
}

/* Prioridad badges */
.prioridad-baja { background: #e5e7eb; color: #374151; }
.prioridad-media { background: #dbeafe; color: #1d4ed8; }
.prioridad-alta { background: #fef3c7; color: #92400e; }
.prioridad-critica { background: #fee2e2; color: #dc2626; }

/* Estado badges */
.estado-abierto { background: #dbeafe; color: #1d4ed8; }
.estado-en_proceso { background: #fef3c7; color: #92400e; }
.estado-cerrado { background: #dcfce7; color: #16a34a; }

/* Lista proyectos en form */
.proyecto-lista {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.proyecto-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.proyecto-opt:last-child {
  border-bottom: none;
}
.proyecto-opt:hover {
  background: #f9fafb;
}
.proyecto-opt.active {
  background: #f0fdf4;
}
.proyecto-opt.active .proyecto-radio {
  border-color: var(--primary);
  background: var(--primary);
}
.proyecto-opt.active .proyecto-radio::after {
  content: '';
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
}
.proyecto-radio {
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.proyecto-nombre {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lista proyectos sidebar */
.proyecto-item {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.proyecto-item:hover {
  background: #f9fafb;
}
.proyecto-item.active {
  border-color: var(--primary);
  background: #f0fdf4;
}

/* Formularios compactos */
.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 4px;
}
.form-control, .form-select {
  font-size: 0.9rem;
}

/* Responsive - pantalla chica */
@media (max-width: 400px) {
  .app-main {
    padding: 8px;
  }
  .btn-img-action {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
}

/* Responsive - pantalla grande (tablet/desktop) */
@media (min-width: 768px) {
  .ticket-item {
    padding: 16px 20px;
  }
  .ticket-item .titulo {
    font-size: 1.05rem;
  }
  .card-body {
    padding: 16px !important;
  }
  .proyecto-lista {
    max-height: 240px;
  }
  #viewTicket .card {
    margin-bottom: 16px;
  }
  #formTicket textarea {
    rows: 5;
    min-height: 100px;
  }
  .img-slot {
    min-height: 120px;
  }
}
