/* ===========================================================================
   Atlas Core — CSS Principal v2
   Visual language: SafeGuard (Barlow · navy profundo · naranja acento)
   =========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&family=Barlow+Condensed:wght@600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Fondos — navy profundo como SafeGuard */
  --bg:       #080d18;
  --bg2:      #0f1623;
  --bg3:      #1a2236;
  --bg4:      #232e47;
  --border:   #2a3654;

  /* Acentos */
  --orange:   #f97316;
  --orange2:  #c2410c;
  --green:    #22c55e;
  --red:      #ef4444;
  --yellow:   #eab308;
  --blue:     #60a5fa;
  --purple:   #a78bfa;
  --teal:     #2dd4bf;
  --cyan:     #22d3ee;

  /* Texto */
  --text:     #f0f6ff;
  --text2:    #8fa3c8;
  --text3:    #4d6088;

  /* Aliases para compatibilidad con código existente */
  --atl-bg:                var(--bg);
  --atl-bg-elev:           var(--bg2);
  --atl-fg:                var(--text);
  --atl-fg-mute:           var(--text2);
  --atl-border:            var(--border);
  --atl-primary:           var(--orange);
  --atl-primary-hov:       var(--orange2);
  --atl-success:           var(--green);
  --atl-warning:           var(--yellow);
  --atl-danger:            var(--red);
  --atl-info:              var(--cyan);
  --atl-disponible:        var(--green);
  --atl-en-uso:            var(--blue);
  --atl-bloqueado:         var(--red);
  --atl-mantto:            var(--yellow);
  --atl-baja:              #4d6088;

  /* Tipografía */
  --atl-font-display: 'Barlow Condensed', system-ui, sans-serif;
  --atl-font-body:    'Barlow', system-ui, sans-serif;
  --atl-font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Radios */
  --atl-radius-sm:  6px;
  --atl-radius-md:  10px;
  --atl-radius-lg:  14px;
  --atl-radius-pill: 999px;
  --card-radius:    14px;

  /* Sombras */
  --atl-shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --atl-shadow-md: 0 4px 16px rgba(0,0,0,.5);
  --atl-shadow-lg: 0 10px 40px rgba(0,0,0,.6);

  /* Layout */
  --atl-topbar-h:  56px;
  --atl-drawer-w:  240px;
  --atl-touch-min: 44px;

  /* Alias nuevos para clientes.js y cotizaciones.js */
  --color-text-primary:        var(--text);
  --color-text-secondary:      var(--text2);
  --color-background-secondary: var(--bg3);
  --color-background-success:  rgba(34,197,94,.1);
  --color-border-default:      var(--border);
  --color-border-info:         rgba(249,115,22,.4);
  --color-primary:             var(--orange);
  --color-success:             var(--green);
  --border-radius-md:          var(--atl-radius-md);
}

/* ───────── Reset ───────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--atl-font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  font-size: 14px;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange2); }

/* ───────── Tipografía ───────── */
h1,h2,h3,h4 { font-family: var(--atl-font-display); font-weight: 800; margin: 0; letter-spacing: .3px; }
h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
.text-mute { color: var(--text2); }
.text-mono { font-family: var(--atl-font-mono); }
.text-sm   { font-size: 0.8rem; }
.text-xs   { font-size: 0.72rem; }

/* ───────── Splash ───────── */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); gap: 12px;
}
.splash-title {
  font-family: var(--atl-font-display);
  font-size: 2.2rem; font-weight: 900;
  letter-spacing: 1px; color: var(--text);
}
.splash-title span { color: var(--orange); }
.splash-subtitle {
  font-size: 0.75rem; color: var(--text3);
  letter-spacing: .15em; text-transform: uppercase;
}
.splash-loader { display: flex; gap: 6px; margin-top: 16px; }
.splash-loader div {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange);
  animation: pulse-dot 1.2s infinite ease-in-out;
}
.splash-loader div:nth-child(2) { animation-delay:.15s; }
.splash-loader div:nth-child(3) { animation-delay:.3s; }
@keyframes pulse-dot {
  0%,80%,100% { opacity:.3; transform:scale(.8); }
  40%         { opacity:1;   transform:scale(1.2); }
}

/* ───────── Topbar ───────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center;
  height: var(--atl-topbar-h); padding: 0 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
/* topbar desktop handled above */
.topbar-icon {
  display: flex; align-items: center; justify-content: center;
  width: var(--atl-touch-min); height: var(--atl-touch-min);
  border-radius: var(--atl-radius-md);
  color: var(--text); transition: background .15s;
}
.topbar-icon:hover { background: rgba(255,255,255,.07); }
.topbar-icon:active { transform: scale(.94); }
.topbar-title {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 1px; min-width: 0;
}
.topbar-title .brand {
  font-family: var(--atl-font-display);
  font-size: 1.1rem; font-weight: 900;
  letter-spacing: .5px;
}
.topbar-title .brand span { color: var(--orange); }
.org-selector {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.72rem; color: var(--text2);
  padding: 2px 8px; border-radius: 99px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.org-selector:hover { background: rgba(255,255,255,.09); }

/* ───────── Drawer ───────── */
.drawer {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--atl-drawer-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200; overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-brand {
  font-family: var(--atl-font-display);
  font-size: 1.3rem; font-weight: 900; letter-spacing: .8px;
}
.drawer-brand span { color: var(--orange); }
.drawer-org {
  font-size: 0.7rem; color: var(--text3);
  text-transform: uppercase; letter-spacing: .15em; margin-top: 2px;
}
.drawer-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.drawer-section-title {
  padding: 14px 14px 4px;
  font-size: 0.6rem; font-weight: 700;
  color: var(--text3); text-transform: uppercase; letter-spacing: .2em;
}
.drawer-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; margin: 1px 7px;
  border-radius: 9px; cursor: pointer;
  font-size: 0.82rem; font-weight: 500;
  color: var(--text2); transition: all .15s;
  text-decoration: none;
}
.drawer-link:hover { background: var(--bg3); color: var(--text); }
.drawer-link.active {
  background: rgba(249,115,22,.15);
  color: var(--orange);
}
.drawer-icon { width: 20px; text-align: center; font-size: 14px; }
.drawer-overlay {
  position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
}
.drawer-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.65rem; color: var(--text3);
  flex-shrink: 0;
}
.drawer-version { margin-top: 4px; }

/* ───────── Desktop: sidebar fijo visible ───────── */
@media (min-width: 768px) {
  /* Drawer fijo, empieza debajo del topbar */
  .drawer {
    transform: translateX(0) !important;
    position: fixed;
    top: var(--atl-topbar-h);
    height: calc(100vh - var(--atl-topbar-h));
    z-index: 100;
  }
  .drawer-overlay { display: none !important; }
  #btn-drawer { display: none !important; }

  /* Topbar fijo full width */
  #topbar {
    position: fixed !important;
    top: 0; left: 0; right: 0;
    z-index: 200;
  }

  /* App: margen izquierdo por drawer + padding top por topbar */
  #app {
    margin-left: var(--atl-drawer-w) !important;
    max-width: none !important;
    padding-top: calc(var(--atl-topbar-h) + 16px) !important;
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: 32px;
  }
}

/* ───────── Layout principal (mobile-first) ───────── */
#app {
  min-height: calc(100vh - var(--atl-topbar-h));
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
}

/* ───────── Cards ───────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 14px 16px;
}
.card + .card { margin-top: 10px; }

/* ───────── Botones ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-family: var(--atl-font-body); font-weight: 600;
  font-size: 0.82rem; transition: all .15s;
  min-height: 36px; white-space: nowrap;
  cursor: pointer; border: none;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--orange); color: white;
  box-shadow: 0 2px 8px rgba(249,115,22,.3);
}
.btn-primary:hover { background: var(--orange2); }

.btn-secondary {
  background: rgba(249,115,22,.12);
  color: var(--orange);
  border: 1px solid rgba(249,115,22,.3);
}
.btn-secondary:hover { background: rgba(249,115,22,.2); }

.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-ghost-danger {
  background: transparent; color: var(--red);
  border: 1px solid rgba(239,68,68,.3);
}
.btn-ghost-danger:hover { background: rgba(239,68,68,.1); }

.btn-success {
  background: var(--green); color: white;
  box-shadow: 0 2px 8px rgba(34,197,94,.25);
}
.btn-success:hover { background: #16a34a; }

.btn-danger {
  background: var(--red); color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 5px 12px; font-size: 0.75rem; min-height: 30px; }
.btn-lg { padding: 12px 24px; font-size: 0.9rem; min-height: 44px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ───────── Formularios ───────── */
.form-label {
  display: block;
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text3); margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text); font-family: var(--atl-font-body);
  font-size: 0.88rem;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249,115,22,.15);
}
.form-control::placeholder { color: var(--text3); }
.form-control:disabled {
  opacity: .6; cursor: not-allowed;
  background: var(--bg4);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ───────── Badges / Pills ───────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
.badge-green  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-orange { background: rgba(249,115,22,.15);  color: var(--orange); }
.badge-blue   { background: rgba(96,165,250,.15);  color: var(--blue); }
.badge-gray   { background: rgba(77,96,136,.2);    color: var(--text2); }
.badge-yellow { background: rgba(234,179,8,.15);   color: var(--yellow); }
.badge-purple { background: rgba(167,139,250,.15); color: var(--purple); }
.badge-teal   { background: rgba(45,212,191,.15);  color: var(--teal); }

/* Estados de activos */
.estado-disponible   { background: rgba(34,197,94,.15);  color: var(--green); }
.estado-en_alquiler  { background: rgba(96,165,250,.15);  color: var(--blue); }
.estado-bloqueado    { background: rgba(239,68,68,.15);   color: var(--red); }
.estado-mantenimiento{ background: rgba(234,179,8,.15);   color: var(--yellow); }
.estado-baja         { background: rgba(77,96,136,.2);    color: var(--text3); }
.estado-vendido      { background: rgba(167,139,250,.15); color: var(--purple); }

/* ───────── Toasts ───────── */
.toast-container {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 9999; display: flex;
  flex-direction: column; gap: 8px;
  pointer-events: none; width: 90%; max-width: 380px;
}
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.82rem; font-weight: 600;
  box-shadow: var(--atl-shadow-md);
  animation: toast-in .2s ease;
  pointer-events: auto;
  border-left: 3px solid var(--orange);
  background: var(--bg2);
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--cyan); }
@keyframes toast-in {
  from { opacity:0; transform:translateY(12px); }
  to   { opacity:1; transform:translateY(0); }
}

/* ───────── Modal / Overlay ───────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in .2s ease;
}
.modal-sheet {
  width: 100%; max-width: 560px;
  background: var(--bg2);
  border-radius: 16px 16px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto;
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border); border-radius: 2px;
  margin: -8px auto 16px;
}
@keyframes fade-in { from{opacity:0} to{opacity:1} }

/* ───────── Sección con título ───────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title-label {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .15em;
  color: var(--text3);
}

/* ───────── Stats / KPI cards ───────── */
.stat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--card-radius); padding: 14px 16px;
  position: relative; overflow: hidden;
}
.stat::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--orange);
}
.stat.s-g::before { background: var(--green); }
.stat.s-r::before { background: var(--red); }
.stat.s-y::before { background: var(--yellow); }
.stat.s-b::before { background: var(--blue); }
.stat.s-o::before { background: var(--orange); }
.stat-val {
  font-family: var(--atl-font-display);
  font-size: 1.8rem; font-weight: 900; line-height: 1;
}
.stat-label { font-size: 0.72rem; color: var(--text2); margin-top: 4px; }

/* ───────── Tabla simple ───────── */
.table-wrap { overflow-x: auto; border-radius: var(--card-radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px;
  background: var(--bg3);
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text3); text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(42,54,84,.5);
  font-size: 0.82rem; color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ───────── Empty state ───────── */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text2);
}
.empty-state .icon { font-size: 44px; opacity: .35; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; margin-bottom: 6px; color: var(--text); font-family: var(--atl-font-display); }

/* ───────── Chips / Filtros ───────── */
.chips {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 6px; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 5px 12px; border-radius: 99px;
  background: var(--bg2); border: 1px solid var(--border);
  font-size: 0.75rem; white-space: nowrap; color: var(--text2);
  cursor: pointer; transition: all .15s;
}
.chip.active, .chip:hover {
  background: rgba(249,115,22,.15);
  border-color: rgba(249,115,22,.4);
  color: var(--orange);
}

/* ───────── Divider ───────── */
.divider {
  height: 1px; background: var(--border);
  margin: 14px 0;
}
.divider-label {
  display: flex; align-items: center; gap: 10px;
  color: var(--text3); font-size: 0.68rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  margin: 16px 0 12px;
}
.divider-label::before, .divider-label::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ───────── Org pill (topbar) ───────── */
.org-pill {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.72rem; color: var(--text2);
  padding: 2px 8px; border-radius: 99px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
  max-width: 160px;
}
.org-pill:hover { background: rgba(255,255,255,.09); }
.org-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
