/*
 * JCM Taller UI base
 * Shared production styles for the workshop flow: Placa -> OT -> Cobro.
 */
:root {
  --ta-bg: #f5f7fa;
  --ta-surface: #ffffff;
  --ta-surface-soft: #f9fafb;
  --ta-text: #111827;
  --ta-muted: #667085;
  --ta-line: #d8dee8;
  --ta-primary: #1457c8;
  --ta-primary-ink: #ffffff;
  --ta-success: #0f9f6e;
  --ta-warning: #b86b00;
  --ta-danger: #c83333;
  --ta-info: #087ca7;
  --ta-radius: 8px;
  --ta-shadow: 0 8px 22px rgba(15, 23, 42, .07);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg, var(--ta-bg));
  color: var(--text, var(--ta-text));
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body.ta-app {
  min-height: 100vh;
}

body.ta-app > #ta-navbar {
  flex: 0 0 auto;
}

body.ta-app .ta-shell-root,
body.ta-app .ta-main,
body.ta-app .ta-topbar,
body.ta-app .ta-content {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

body.ta-app .ta-shell-root,
body.ta-app .ta-main,
body.ta-app .ta-main-full {
  overflow-x: clip;
  overflow-y: visible;
}

body.ta-app .ta-content,
body.ta-app .ta-content * {
  min-width: 0;
}

body.ta-app img,
body.ta-app canvas,
body.ta-app svg {
  max-width: 100%;
}

body.ta-nav-managed {
  transition: padding-left .18s ease;
}

body.layout-horizontal,
body.layout-vertical,
body.layout-vertical.ta-sidebar-collapsed {
  padding-left: 0;
}

body.ta-nav-managed .table-wrap,
body.ta-nav-managed [class*="table-wrap"] {
  max-width: 100%;
  overflow-x: auto;
}

body.layout-vertical .container,
body.layout-vertical .app-container,
body.layout-vertical .page-container,
body.layout-vertical .app-shell,
body.layout-vertical .ta-shell-root {
  max-width: none;
}

body.ta-nav-managed .sidebar:not(.ta-sidebar-inner),
body.ta-nav-managed .side-nav,
body.ta-nav-managed .side-brand,
body.ta-nav-managed .side-footer {
  display: none !important;
}

body.ta-dark-mode {
  --ta-bg: #0f172a;
  --ta-surface: #111827;
  --ta-surface-soft: #172033;
  --ta-text: #e5e7eb;
  --ta-muted: #9ca3af;
  --ta-line: #263244;
}

.container,
.app-container,
.page-container,
.app-shell {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 20px clamp(12px, 2vw, 28px);
}

.content-wide {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
}

.main-grid,
.page-grid,
.ta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.has-sidebar {
  grid-template-columns: minmax(0, 1fr) clamp(280px, 22vw, 360px);
}

.card,
.ta-card,
.side-panel,
.kpi {
  background: var(--card, var(--ta-surface));
  border: 1px solid var(--line, var(--ta-line));
  border-radius: var(--ta-radius);
  box-shadow: var(--ta-shadow);
}

.card,
.ta-card,
.side-panel {
  padding: clamp(14px, 1.5vw, 22px);
}

.kpis,
.ta-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.kpi {
  min-height: 88px;
  padding: 14px;
}

.kpi h4,
.kpi .label {
  margin: 0 0 6px;
  color: var(--muted, var(--ta-muted));
  font-size: .84rem;
  font-weight: 700;
}

.kpi .val,
.kpi strong {
  display: block;
  color: var(--text, var(--ta-text));
  font-size: 1.35rem;
  line-height: 1.1;
  font-weight: 800;
}

.btn,
button,
input[type="button"],
input[type="submit"] {
  min-height: 38px;
  border-radius: var(--ta-radius);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line, var(--ta-line));
  background: var(--ta-surface);
  color: inherit;
  padding: 0 12px;
  text-decoration: none;
  cursor: pointer;
}

.btn.ok,
.btn.primary,
.btn--primary {
  border-color: var(--brand, var(--ta-primary));
  background: var(--brand, var(--ta-primary));
  color: var(--ta-primary-ink);
}

.btn.warn {
  border-color: rgba(184, 107, 0, .25);
  background: #fff7e8;
  color: var(--ta-warning);
}

.btn.danger {
  border-color: rgba(200, 51, 51, .25);
  background: #fff0f0;
  color: var(--ta-danger);
}

.btn.ghost {
  background: var(--ta-surface-soft);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line, var(--ta-line));
  border-radius: var(--ta-radius);
  background: var(--card, var(--ta-surface));
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line, var(--ta-line));
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--ta-surface-soft);
  color: var(--ta-muted);
  font-size: .82rem;
  font-weight: 800;
}

input,
select,
textarea {
  max-width: 100%;
  border: 1px solid var(--line, var(--ta-line));
  border-radius: var(--ta-radius);
  background: var(--ta-surface);
  color: var(--text, var(--ta-text));
  font: inherit;
}

input,
select {
  min-height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 76px;
  padding: 9px 10px;
}

.pill,
.chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border: 1px solid var(--line, var(--ta-line));
  border-radius: 999px;
  padding: 3px 9px;
  line-height: 1.2;
}

.status-pill,
.payment-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: .78rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.status-pill.ok,
.payment-pill.ok {
  background: #dcfce7;
  color: #067647;
  border-color: #bbf7d0;
}

.status-pill.warn,
.payment-pill.warn {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.status-pill.error,
.payment-pill.error {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.status-pill.info,
.payment-pill.info {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.ta-empty {
  border: 1px dashed var(--line, var(--ta-line));
  border-radius: var(--ta-radius);
  padding: 18px;
  color: var(--muted, var(--ta-muted));
  background: var(--ta-surface-soft);
  text-align: center;
}

.ta-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 12000;
  border-radius: var(--ta-radius);
  padding: 11px 14px;
  background: #111827;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
}

.pill--cerrada,
.badge.ok,
.chip.ok {
  background: #eafaf3;
  border-color: rgba(15, 159, 110, .25);
  color: #08764f;
}

.pill--abierta,
.badge.warn,
.chip.warn {
  background: #fff7e8;
  border-color: rgba(184, 107, 0, .25);
  color: var(--ta-warning);
}

.badge.danger,
.chip.danger {
  background: #fff0f0;
  border-color: rgba(200, 51, 51, .25);
  color: var(--ta-danger);
}

.overlay,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(17, 24, 39, .48);
}

.modal {
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border-radius: var(--ta-radius);
}

.ta-plate-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.ta-plate-search input {
  height: 48px;
  text-transform: uppercase;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0;
}

/* Global navigation shell */
body.ta-nav-managed {
  min-height: 100vh;
  padding: 0 !important;
}

body.ta-nav-managed .ta-shell-root,
body.ta-nav-managed main,
body.ta-nav-managed .ta-main,
body.ta-nav-managed .ta-main-full,
body.ta-nav-managed .ta-content {
  min-width: 0 !important;
  max-width: 100%;
}

body.ta-nav-managed .sidebar:not(.ta-sidebar-inner),
body.ta-nav-managed .side-nav,
body.ta-nav-managed .side-brand,
body.ta-nav-managed .side-footer {
  display: none !important;
}

#ta-navbar.ta-nav-vertical {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  z-index: 9000;
}

#ta-navbar.ta-nav-horizontal {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 9000;
}

#ta-navbar.ta-nav-horizontal .ta-sidebar-inner,
#ta-navbar.ta-nav-vertical .ta-modern-topbar,
#ta-navbar.ta-nav-vertical .ta-drawer,
#ta-navbar.ta-nav-vertical .ta-drawer-backdrop {
  display: none !important;
}

.ta-modern-topbar {
  height: 74px;
  display: grid;
  grid-template-columns: minmax(230px, 310px) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 10px clamp(14px, 2.4vw, 30px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line, var(--ta-line));
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
  backdrop-filter: saturate(1.2) blur(12px);
}

.ta-topbar-left,
.ta-topbar-right,
.ta-modern-brand,
.ta-sidebar-brand,
.ta-drawer-brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.ta-topbar-left,
.ta-topbar-right {
  gap: 12px;
}

.ta-modern-brand,
.ta-sidebar-brand,
.ta-drawer-brand {
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.ta-modern-brand img,
.ta-drawer-brand img {
  width: 78px;
  height: 42px;
  object-fit: contain;
  object-position: left center;
  flex: 0 0 auto;
}

.ta-global-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  max-width: 620px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line, var(--ta-line));
  border-radius: 10px;
  background: #fff;
}

.ta-global-search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.ta-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 9200;
  display: none;
  padding: 8px;
  border: 1px solid var(--line, var(--ta-line));
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 22px 55px rgba(15, 23, 42, .18);
}

.ta-search-results.open {
  display: grid;
  gap: 4px;
}

.ta-search-result {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.ta-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: rgba(15, 23, 42, .42);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.ta-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.ta-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 9110;
  display: flex;
  flex-direction: column;
  width: min(330px, calc(100vw - 28px));
  min-width: 0;
  background: #071a2e;
  color: #fff;
  box-shadow: 18px 0 55px rgba(15, 23, 42, .35);
  transform: translateX(-104%);
  transition: transform .2s ease;
}

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

.ta-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.ta-drawer-nav,
.ta-sidebar-nav {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 14px 12px;
}

.ta-drawer-group h3 {
  margin: 10px 8px 7px;
  color: #9fb3ca;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ta-drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 12px;
  border-radius: 9px;
  color: #e6eef8;
  font-size: .9rem;
  font-weight: 850;
  text-decoration: none;
}

.ta-drawer-link:hover,
.ta-drawer-link.is-active {
  background: #0b63f6;
  color: #fff;
}

#ta-navbar.ta-nav-vertical .ta-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px 12px;
  background: #071a2e;
  color: #fff;
  box-shadow: 12px 0 30px rgba(15, 23, 42, .14);
}

.ta-sidebar-bottom,
.ta-drawer-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

.ta-sidebar-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border-radius: 9px;
  background: #0b63f6;
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 1180px) {
  .has-sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .container,
  .app-container,
  .page-container,
  .app-shell {
    padding: 14px clamp(10px, 4vw, 18px);
  }

  .ta-plate-search {
    grid-template-columns: 1fr;
  }

  .btn {
    width: auto;
  }

  .ta-modern-topbar {
    height: auto;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 10px;
  }

  .ta-topbar-center {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .ta-global-search {
    max-width: none;
  }

  .ta-api-compact,
  .ta-user-copy,
  .ta-notify {
    display: none !important;
  }

  #ta-navbar.ta-nav-vertical {
    position: sticky;
    width: 100%;
    height: auto;
  }
}

/* Definitive AppShell sizing */
body.ta-app.ta-nav-managed {
  display: flex !important;
  align-items: stretch;
  width: 100%;
  min-height: 100vh;
  height: 100vh;
  padding: 0 !important;
  overflow: hidden !important;
  background: #f4f6fb !important;
}

body.ta-app.ta-nav-managed > #ta-navbar.ta-sidebar {
  position: sticky !important;
  inset: auto !important;
  top: 0 !important;
  align-self: stretch;
  flex: 0 0 280px !important;
  width: 280px !important;
  max-width: 280px !important;
  height: 100vh !important;
  margin: 0 !important;
  z-index: 9000;
  overflow: visible;
}

body.ta-app.ta-nav-managed > #ta-navbar.ta-nav-horizontal {
  flex: 0 0 0 !important;
  width: 0 !important;
  max-width: 0 !important;
}

body.ta-app.ta-nav-managed > .ta-shell-root {
  display: contents !important;
  width: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
}

body.ta-app.ta-nav-managed > main.ta-main,
body.ta-app.ta-nav-managed > .ta-shell-root > main.ta-main {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  min-height: 100vh !important;
  height: 100vh !important;
  margin: 0 !important;
  overflow: hidden !important;
  background: #f4f6fb;
}

body.ta-nav-managed .ta-module-topbar {
  display: none !important;
}

body.ta-nav-managed .ta-app-topbar {
  flex: 0 0 72px !important;
  display: grid !important;
  grid-template-columns: minmax(180px, 280px) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 16px;
  height: 72px !important;
  min-width: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--line, var(--ta-line));
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
  z-index: 40;
}

.ta-app-topbar-left,
.ta-app-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ta-app-topbar-center {
  min-width: 0;
}

.ta-breadcrumb {
  min-width: 0;
  line-height: 1.1;
}

.ta-breadcrumb span {
  display: block;
  color: var(--muted, var(--ta-muted));
  font-size: .74rem;
  font-weight: 800;
}

.ta-breadcrumb strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--text, var(--ta-text));
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ta-nav-managed .ta-content {
  flex: 1 1 auto !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 0 !important;
  padding: 24px !important;
  overflow: auto !important;
  align-content: start;
}

body.ta-nav-managed .settings-layout {
  width: 100%;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(280px, 360px) !important;
}

body.ta-nav-managed .settings-content,
body.ta-nav-managed .dashboard-content,
body.ta-nav-managed .orders-content,
body.ta-nav-managed .clients-content,
body.ta-nav-managed .vehicles-content,
body.ta-nav-managed .inventory-content,
body.ta-nav-managed .finance-content,
body.ta-nav-managed .reports-content,
body.ta-nav-managed .agenda-content,
body.ta-nav-managed .diario-content,
body.ta-nav-managed .suppliers-content {
  padding: 24px !important;
}

#ta-navbar.ta-nav-vertical .ta-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100% !important;
  max-height: 100vh;
  overflow: hidden;
}

#ta-navbar.ta-nav-vertical .ta-sidebar-nav {
  overflow-y: auto;
  scrollbar-width: thin;
}

@media (max-width: 1280px) and (min-width: 901px) {
  body.ta-app.ta-nav-managed > #ta-navbar.ta-nav-vertical {
    flex-basis: 280px !important;
    width: 280px !important;
    max-width: 280px !important;
  }

  body.ta-nav-managed .settings-layout {
    grid-template-columns: minmax(210px, 240px) minmax(0, 1fr) !important;
  }

  body.ta-nav-managed .preview-card {
    position: static !important;
    grid-column: 1 / -1 !important;
  }
}

@media (max-width: 900px) {
  body.ta-app.ta-nav-managed {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body.ta-app.ta-nav-managed > #ta-navbar.ta-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    flex: 0 0 min(300px, 86vw) !important;
    width: min(300px, 86vw) !important;
    max-width: min(300px, 86vw) !important;
    height: 100dvh !important;
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 9100;
  }

  body.ta-app.ta-nav-managed > #ta-navbar.ta-sidebar.open {
    transform: translateX(0);
  }

  body.ta-drawer-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9090;
    background: rgba(15, 23, 42, .46);
  }

  body.ta-app.ta-nav-managed > main.ta-main {
    min-height: 100vh !important;
    height: auto !important;
  }

  body.ta-nav-managed .ta-app-topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    height: auto !important;
    min-height: 72px;
    padding: 10px 14px;
  }

  body.ta-nav-managed .ta-app-topbar-center {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  body.ta-nav-managed .ta-app-topbar .ta-global-search {
    max-width: none;
  }

  body.ta-nav-managed .ta-app-topbar .ta-user-copy,
  body.ta-nav-managed .ta-app-topbar .ta-notify {
    display: none !important;
  }

  body.ta-nav-managed .ta-content {
    padding: 16px !important;
  }

  body.ta-nav-managed .settings-layout {
    grid-template-columns: 1fr !important;
  }

  body.ta-nav-managed .settings-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.ta-nav-managed .preview-card {
    position: static !important;
  }
}

@media (max-width: 560px) {
  body.ta-nav-managed .ta-app-topbar {
    gap: 8px;
  }

  body.ta-nav-managed .ta-app-topbar .ta-new-ot {
    padding: 0 10px;
  }

  body.ta-nav-managed .ta-app-topbar .ta-new-ot span,
  body.ta-nav-managed .ta-app-topbar .ta-user,
  body.ta-nav-managed .ta-search-kbd {
    display: none !important;
  }

  body.ta-nav-managed .settings-nav {
    grid-template-columns: 1fr !important;
  }
}
