/* BazzanTech — Estilos PWA */
/* Diseño mobile-first, responsive, botones grandes para mecánicos */

:root {
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --surface-light: #2a2a2a;
  --primary: #e0e0e0;
  --primary-hover: #f0f0f0;
  --accent: #ff3333;
  --accent-hover: #ff4444;
  --accent-dark: #cc0000;
  --text: #ffffff;
  --text-muted: #999;
  --border: #333;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  padding-top: var(--safe-top);
}

.hidden { display: none !important; }

/* ===== LOGIN ===== */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
}

.login-card {
  text-align: center;
  width: 100%;
  max-width: 320px;
}

.logo-login {
  width: 180px;
  height: auto;
  margin: 0 auto 1rem;
  display: block;
  border-radius: 20px;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--primary);
}

.login-sub {
  color: var(--accent);
  font-size: 0.95rem;
  margin-top: 0.25rem;
  margin-bottom: 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.4rem;
  margin-top: 1rem;
}

.pin-input {
  width: 100%;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.8rem;
  padding: 0.9rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.pin-input:focus {
  border-color: var(--accent);
}

/* ===== APP LAYOUT ===== */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.logo-header {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
}

#page-title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

/* ===== VIEWS ===== */
.view {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(80px + var(--safe-bottom));
  animation: fadeIn 0.2s ease;
}

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

/* ===== SEARCH ===== */
.search-bar {
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
}

/* ===== VEHICLE CARDS ===== */
.vehicles-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.vehicle-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.vehicle-card:active {
  transform: scale(0.98);
}

.card-plate {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent);
  font-family: 'Courier New', monospace;
}

.card-brand {
  font-size: 0.95rem;
  color: var(--text);
  margin-top: 0.25rem;
}

.card-owner {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.card-reason {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.card-photo-count {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 4rem;
  opacity: 0.3;
  margin-bottom: 1rem;
}

/* ===== FORMS ===== */
.form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 500px;
  margin: 0 auto;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.text-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.text-input:focus {
  border-color: var(--accent);
}

textarea.text-input {
  resize: vertical;
  font-family: inherit;
}

.form-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ===== PHOTOS ===== */
.photos-section {
  margin: 0.5rem 0;
}

.btn-photo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem;
  background: var(--surface-light);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  justify-content: center;
  transition: border-color 0.2s;
}

.btn-photo:active {
  border-color: var(--accent);
}

.btn-photo-icon {
  font-size: 1.4rem;
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.photo-thumb {
  position: relative;
  width: calc(33.333% - 0.5rem);
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

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

.photo-thumb .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  background: rgba(0,0,0,0.7);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:active {
  transform: scale(0.98);
  background: var(--accent-dark);
}

.btn-primary:disabled {
  opacity: 0.5;
}

.btn-large {
  width: 100%;
  padding: 1.1rem;
  font-size: 1.1rem;
  margin-top: 1.5rem;
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-secondary:active {
  background: var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-danger:active {
  background: rgba(255,51,51,0.1);
}

/* ===== DETAIL VIEW ===== */
.detail-header {
  margin-bottom: 1.5rem;
}

.detail-plate {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
}

.detail-brand {
  font-size: 1.2rem;
  color: var(--text);
  margin-top: 0.25rem;
}

.detail-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.detail-value {
  font-size: 1rem;
  color: var(--text);
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.detail-value:last-child {
  margin-bottom: 0;
}

.detail-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--primary);
}

/* ===== HISTORY ===== */
.history-entry {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--accent);
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.history-work {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

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

.history-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.history-photos img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
}

.detail-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.detail-photos img {
  width: 100%;
  max-width: 200px;
  height: auto;
  border-radius: 10px;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 0.5rem;
  padding-bottom: calc(0.5rem + var(--safe-bottom));
  z-index: 100;
}

.bottom-nav-spacer {
  height: calc(60px + var(--safe-bottom));
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.5rem;
  font-size: 0.75rem;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-btn-center {
  flex: 0 0 auto;
  padding: 0.5rem 1.5rem;
}

.nav-btn-center .nav-icon {
  font-size: 1.5rem;
}

.nav-icon {
  font-size: 1.3rem;
}

/* ===== ACTION BUTTONS ===== */
.action-bar {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.action-bar > * {
  flex: 1;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-light);
  color: var(--text);
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  z-index: 200;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  border: 1px solid var(--border);
}

.toast.error {
  border-color: var(--accent);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.spinner {
  font-size: 2rem;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== FULLSCREEN PHOTO VIEWER ===== */
.photo-viewer {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.95);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  cursor: zoom-out;
}

.photo-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* ===== BACK BUTTON ===== */
.back-btn {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  padding-bottom: 2px;
  transition: background 0.2s;
}

.back-btn:active {
  background: var(--accent);
}

/* ===== VEHICLE CARD WITH THUMBNAIL ===== */
.vehicle-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.card-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  order: 2;
}

.card-info {
  flex: 1;
  min-width: 0;
  order: 1;
}

.card-thumb-placeholder {
  background: var(--surface-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.card-badges {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  display: flex;
  gap: 0.75rem;
}

/* ===== STORAGE BADGE ===== */
.storage-badge {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  transition: border-color 0.2s;
}

.storage-badge.warn {
  border-color: #f0a020;
  color: #f0a020;
}

.storage-badge.danger {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== STORAGE MODAL ===== */
.storage-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.storage-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  max-width: 340px;
  width: 100%;
}

.storage-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.storage-bar-bg {
  width: 100%;
  height: 24px;
  background: var(--surface-light);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.storage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #eab308);
  border-radius: 12px;
  transition: width 0.3s;
}

.storage-bar-fill.warn { background: #eab308; }
.storage-bar-fill.danger { background: var(--accent); }

.storage-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1rem 0;
}

.storage-stat {
  background: var(--surface-light);
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
}

.storage-stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.storage-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.storage-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ===== RESPONSIVE — TABLET/DESKTOP ===== */
@media (min-width: 768px) {
  .view {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }
  
  .vehicle-card {
    padding: 1.25rem;
  }
  
  .photo-thumb {
    width: calc(25% - 0.5625rem);
  }
}

@media (min-width: 1024px) {
  .view {
    max-width: 800px;
  }
}

/* ===== DEBUG ===== */
.debug-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--accent-dark);
  color: white;
  padding: 0.5rem;
  font-size: 0.75rem;
  text-align: center;
  z-index: 500;
}
