/* ProStock - Layout moderno */
:root {
  --ps-primary: #2563eb;
  --ps-primary-dark: #1d4ed8;
  --ps-accent: #06b6d4;
  --ps-sidebar: #0f172a;
  --ps-sidebar-hover: #1e293b;
  --ps-sidebar-active: #2563eb;
  --ps-surface: #ffffff;
  --ps-bg: #f1f5f9;
  --ps-text: #0f172a;
  --ps-muted: #64748b;
  --ps-border: #e2e8f0;
  --ps-success: #10b981;
  --ps-warning: #f59e0b;
  --ps-danger: #ef4444;
  --ps-radius: 12px;
  --ps-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --ps-shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.12);
}

body {
  background: var(--ps-bg) !important;
  font-family: 'Plus Jakarta Sans', 'Public Sans', system-ui, sans-serif !important;
}

.layout-menu {
  background: var(--ps-sidebar) !important;
  border-right: none !important;
  box-shadow: var(--ps-shadow-lg);
}

.layout-menu .app-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.layout-menu .app-brand-text {
  color: #fff !important;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.layout-menu .menu-link {
  color: rgba(255, 255, 255, 0.75) !important;
  border-radius: 8px;
  margin: 2px 12px;
  padding: 0.65rem 1rem !important;
  transition: all 0.2s ease;
}

.layout-menu .menu-link:hover {
  background: var(--ps-sidebar-hover) !important;
  color: #fff !important;
}

.layout-menu .menu-item.active > .menu-link {
  background: var(--ps-sidebar-active) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.layout-menu .menu-icon {
  color: inherit !important;
}

.layout-navbar {
  background: var(--ps-surface) !important;
  border-bottom: 1px solid var(--ps-border) !important;
  box-shadow: var(--ps-shadow) !important;
  backdrop-filter: blur(8px);
}

.card {
  border: 1px solid var(--ps-border) !important;
  border-radius: var(--ps-radius) !important;
  box-shadow: var(--ps-shadow) !important;
  overflow: hidden;
}

.card-header {
  background: var(--ps-surface) !important;
  border-bottom: 1px solid var(--ps-border) !important;
  padding: 1rem 1.25rem !important;
}

.card-header h5 {
  font-weight: 600;
  color: var(--ps-text);
}

.btn-primary {
  background: var(--ps-primary) !important;
  border-color: var(--ps-primary) !important;
  border-radius: 8px !important;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--ps-primary-dark) !important;
  border-color: var(--ps-primary-dark) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-outline-primary {
  border-radius: 8px !important;
  border-color: var(--ps-primary) !important;
  color: var(--ps-primary) !important;
}

.table {
  --bs-table-hover-bg: rgba(37, 99, 235, 0.04);
}

.table thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ps-muted);
  border-bottom: 2px solid var(--ps-border) !important;
}

.page-title {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--ps-text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--ps-muted);
  font-size: 0.9rem;
}

.table-custom {
  width: 100%;
  table-layout: auto;
}

.table-custom th,
.table-custom td {
  white-space: normal;
  word-wrap: break-word;
  padding: 0.65rem 0.5rem;
  font-size: 0.9rem;
  vertical-align: middle;
}

.table-custom th {
  text-align: center;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.card-header .btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
}

.action-buttons .btn {
  padding: 0.25rem 0.5rem;
}

#produtosTable {
  min-width: 960px;
}

@media (max-width: 768px) {
  .table-custom th,
  .table-custom td {
    font-size: 0.8rem;
    padding: 0.4rem 0.3rem;
  }
}

/* Login page */
.ps-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #2563eb 100%);
  padding: 2rem;
}

.ps-auth-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--ps-shadow-lg);
  overflow: hidden;
}

.ps-auth-header {
  background: linear-gradient(135deg, var(--ps-primary) 0%, var(--ps-accent) 100%);
  padding: 2rem;
  text-align: center;
  color: #fff;
}

.ps-auth-header img {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.3);
  margin-bottom: 1rem;
}

.ps-auth-body {
  padding: 2rem;
}

.ps-auth-body .form-control {
  border-radius: 8px;
  border: 1px solid var(--ps-border);
  padding: 0.65rem 1rem;
}

.ps-auth-body .form-control:focus {
  border-color: var(--ps-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* OS Tickets */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-aberto { background: #dbeafe; color: #1d4ed8; }
.status-em-trabalho { background: #fef3c7; color: #b45309; }
.status-aguarda-pecas { background: #fce7f3; color: #be185d; }
.status-concluido { background: #d1fae5; color: #047857; }
.status-faturado { background: #e0e7ff; color: #4338ca; }

.timer-display {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ps-primary);
  letter-spacing: 0.05em;
}

.timer-controls .btn {
  min-width: 100px;
}

.intervencao-card {
  border-left: 4px solid var(--ps-primary);
  margin-bottom: 1rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--ps-border);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .photo-date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.65rem;
  padding: 0.25rem;
  text-align: center;
}

.stat-card {
  background: linear-gradient(135deg, var(--ps-primary) 0%, var(--ps-accent) 100%);
  color: #fff;
  border-radius: var(--ps-radius);
  padding: 1.25rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-card .stat-label {
  opacity: 0.85;
  font-size: 0.85rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: #f1f5f9;
  border-radius: 999px;
  font-size: 0.85rem;
}

.user-chip .avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ps-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
}

@media (max-width: 768px) {
  .timer-display { font-size: 1.5rem; }
}

/* ========== MOBILE ========== */
@media (max-width: 1199.98px) {
  html.layout-menu-expanded {
    overflow: hidden;
  }

  .layout-menu {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1100;
    width: 280px !important;
    max-width: 85vw;
  }

  html.layout-menu-expanded .layout-menu {
    transform: translateX(0);
  }

  .layout-overlay {
    z-index: 1090;
    background: rgba(15, 23, 42, 0.5) !important;
  }

  .layout-page {
    padding-left: 0 !important;
  }

  .container-p-y {
    padding-top: 1rem !important;
    padding-bottom: 5.5rem !important;
  }

  .container-xxl {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .layout-navbar {
    padding: 0.5rem 1rem !important;
    min-height: 56px;
  }

  .user-chip span:not(.avatar-sm) {
    display: none;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-sm {
    min-height: 40px;
    padding: 0.5rem 0.85rem;
  }

  .form-control,
  .form-select {
    min-height: 48px;
    font-size: 16px;
  }

  .form-control-sm,
  .form-select-sm {
    min-height: 40px;
    font-size: 15px;
  }

  .modal-dialog {
    margin: 0.75rem;
    max-width: calc(100% - 1.5rem);
  }

  .modal-fullscreen-sm-down {
    margin: 0;
    max-width: 100%;
  }

  .table-responsive {
    border-radius: var(--ps-radius);
  }
}

/* Bottom navigation */
.ps-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1080;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: #fff;
  border-top: 1px solid var(--ps-border);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
  padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom, 0px));
  height: calc(60px + env(safe-area-inset-bottom, 0px));
}

.ps-bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  color: var(--ps-muted);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 600;
  border: none;
  background: none;
  padding: 0.25rem;
  min-height: 52px;
  transition: color 0.2s;
}

.ps-bottom-nav-item i {
  font-size: 1.35rem;
}

.ps-bottom-nav-item.active {
  color: var(--ps-primary);
}

.ps-bottom-nav-item.active i {
  transform: scale(1.05);
}

/* OS list mobile cards */
.ps-ticket-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ps-ticket-card {
  display: block;
  background: #fff;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--ps-shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.ps-ticket-card:active {
  transform: scale(0.98);
}

.ps-ticket-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.ps-ticket-card-matricula {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ps-text);
}

.ps-ticket-card-meta {
  font-size: 0.85rem;
  color: var(--ps-muted);
  line-height: 1.5;
}

.ps-ticket-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ps-border);
}

.ps-ticket-card-stat {
  font-size: 0.75rem;
  color: var(--ps-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ps-ticket-card-stat i {
  font-size: 1rem;
}

.ps-fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  right: 1rem;
  z-index: 1070;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ps-primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.ps-fab:active {
  transform: scale(0.95);
}

.ps-filter-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.25rem;
}

.ps-filter-scroll::-webkit-scrollbar {
  display: none;
}

.ps-filter-scroll .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Client picker (nova OS) */
.ps-client-picker {
  position: relative;
}

.ps-client-search-wrap {
  position: relative;
}

.ps-client-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  background: #f8fafc;
  margin-bottom: 0.5rem;
}

.ps-client-selected-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  min-width: 0;
}

.ps-client-selected-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps-client-results-wrap {
  margin-top: 0.35rem;
  margin-bottom: 0.5rem;
}

.ps-client-results {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  background: #fff;
  box-shadow: var(--ps-shadow);
}

.ps-client-result {
  min-height: 44px;
  display: flex;
  align-items: center;
  text-align: left;
  background: #fff;
}

.ps-client-result:hover,
.ps-client-result:focus {
  background: #f1f5f9;
}

.ps-new-cliente-form {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.ps-client-search-hint {
  font-size: 0.8125rem;
  color: var(--ps-muted);
  margin-top: 0.35rem;
}

/* KM camera capture */
.ps-km-capture {
  padding: 0.85rem;
  border: 1px dashed var(--ps-border);
  border-radius: var(--ps-radius);
  background: #f8fafc;
}

.ps-km-camera-btn {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  font-weight: 600;
}

.ps-km-preview {
  margin-top: 0.75rem;
  border-radius: var(--ps-radius);
  overflow: hidden;
  border: 1px solid var(--ps-border);
  background: #fff;
}

.ps-km-preview img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #111;
  display: block;
}

.ps-km-preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.ps-km-preview.is-processing img {
  opacity: 0.75;
}

.ps-km-preview-actions .spinner-border {
  vertical-align: -0.125em;
}

/* OS ticket mobile tabs */
.ps-mobile-tabs {
  display: flex;
  gap: 0.35rem;
  background: #fff;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 0.35rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--ps-shadow);
}

.ps-mobile-tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ps-muted);
  min-height: 44px;
}

.ps-mobile-tabs button.active {
  background: var(--ps-primary);
  color: #fff;
}

.ps-mobile-tabs button i {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 0.15rem;
}

/* Mobile action bar (OS detail) */
.ps-mobile-action-bar {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  z-index: 1075;
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--ps-border);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}

.ps-mobile-action-bar .btn {
  flex: 1;
  font-weight: 600;
  gap: 0.35rem;
}

.ps-mobile-timer-bar {
  position: fixed;
  bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  left: 1rem;
  right: 1rem;
  z-index: 1076;
  background: #059669;
  color: #fff;
  border-radius: 12px;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.4);
}

.ps-mobile-timer-bar .ps-mobile-timer-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 700;
}

.ps-mobile-timer-bar .btn {
  min-height: 40px;
  background: #fff;
  color: #059669;
  border: none;
  font-weight: 700;
}

@media (max-width: 1199.98px) {
  .ps-os-ticket-page .container-p-y {
    padding-bottom: 7.5rem !important;
  }

  .ps-os-ticket-page.ps-timer-active .container-p-y {
    padding-bottom: 10rem !important;
  }

  .intervencao-card .timer-section {
    background: #f8fafc;
    border-radius: 10px;
    padding: 1rem !important;
    margin-top: 0.75rem !important;
  }

  .intervencao-card .timer-controls {
    width: 100%;
  }

  .intervencao-card .timer-controls .btn {
    flex: 1;
    min-height: 52px;
    font-size: 1rem;
    font-weight: 600;
  }

  .intervencao-card .timer-display {
    width: 100%;
    text-align: center;
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
  }

  .intervencao-card .tempo-manual-row {
    width: 100%;
    flex-wrap: nowrap !important;
  }

  .intervencao-card .tempo-manual-row input {
    flex: 1;
    min-width: 0;
  }

  .photo-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.85rem;
  }

  .stat-card .stat-value {
    font-size: 1.25rem;
  }

  .stat-card .stat-label {
    font-size: 0.75rem;
  }

  .ps-desktop-table {
    display: none !important;
  }

  .ps-hide-mobile {
    display: none !important;
  }
}

@media (min-width: 1200px) {
  .ps-mobile-tabs,
  .ps-mobile-action-bar,
  .ps-mobile-timer-bar,
  .ps-bottom-nav,
  .ps-fab,
  .ps-ticket-cards {
    display: none !important;
  }

  .ps-desktop-only-table {
    display: none !important;
  }
}

@media (max-width: 1199.98px) {
  .ps-auth-page {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .ps-auth-body {
    padding: 1.5rem;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem;
  }

  .card-header .btn,
  .card-header .btn-group {
    width: 100%;
  }
}

