/* ==========================================================================
   sismitaller · UI base (sidebar lateral + topbar + formularios)
   Bootstrap 5 sigue siendo el framework base; aqui solo lo complementamos.
   ========================================================================== */

:root {
  --app-sidebar-width: 260px;
  --app-topbar-height: 56px;
  --app-sidebar-bg: #1e293b;
  --app-sidebar-text: #cbd5e1;
  --app-sidebar-active: #38bdf8;
  --app-sidebar-border: #0f172a;
  --app-main-bg: #f1f5f9;
  --app-border: #e2e8f0;
  --app-muted: #64748b;
}

/* ---------------------------------------------------------------------------
   Shell general
   --------------------------------------------------------------------------- */
body.app-body {
  background: var(--app-main-bg);
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
}

/* Sidebar fija (desktop) */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--app-sidebar-width);
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1030;
}

.app-sidebar-brand {
  height: var(--app-topbar-height);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 1.25rem;
  color: #f8fafc;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--app-sidebar-border);
  flex-shrink: 0;
}
.app-sidebar-brand:hover {
  color: #fff;
}

.app-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1.5rem;
}
.app-sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.app-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 3px;
}

.app-nav-group {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 1rem 1.25rem 0.35rem;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 1.25rem;
  color: var(--app-sidebar-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.app-nav-link i {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}
.app-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.app-nav-link.active,
.app-nav-link[aria-current="page"] {
  color: #fff;
  background: rgba(56, 189, 248, 0.14);
  border-left-color: var(--app-sidebar-active);
}
.app-nav-link.active i {
  color: var(--app-sidebar-active);
}

/* Contenido a la derecha de la sidebar */
.app-content {
  margin-left: var(--app-sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------------- */
.app-topbar {
  height: var(--app-topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  flex-shrink: 0;
}
.app-topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}
.app-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.app-topbar-user {
  font-size: 0.875rem;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.app-topbar-user i {
  color: var(--app-muted);
}
.app-topbar-toggler {
  color: #334155;
  border: 0;
  background: transparent;
  padding: 0.25rem 0.5rem;
  font-size: 1.25rem;
  line-height: 1;
}
.app-topbar-toggler:hover {
  color: #000;
}

.app-main {
  flex: 1;
  padding: 1.5rem;
}

/* ---------------------------------------------------------------------------
   Móvil: sidebar en offcanvas + topbar reducida
   --------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .app-sidebar.app-sidebar-desktop {
    display: none;
  }
  .app-content {
    margin-left: 0;
  }
  .app-main {
    padding: 1rem 0.75rem;
  }
  .app-topbar {
    padding: 0 0.75rem;
  }
}

.app-offcanvas {
  --bs-offcanvas-width: 300px;
}
/* La marca va en el header del offcanvas; se oculta la del partial */
.app-offcanvas .app-sidebar {
  position: static;
  width: auto;
  bottom: auto;
  min-height: 100%;
}
.app-offcanvas .app-sidebar-brand {
  display: none;
}
.offcanvas-body.app-offcanvas-body {
  padding: 0;
}

/* ---------------------------------------------------------------------------
   Formularios · patrón
   --------------------------------------------------------------------------- */
.app-form {}
.app-form-section {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--app-muted);
  border-bottom: 1px solid var(--app-border);
  padding-bottom: 0.45rem;
  margin: 1.6rem 0 1rem;
}
.app-form-section:first-child {
  margin-top: 0;
}

.app-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}
.app-form-actions .d-flex {
  gap: 0.5rem;
}

@media (min-width: 992px) {
  .app-form-actions-sticky .app-form-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
  }
}

/* ---------------------------------------------------------------------------
   Empty states
   --------------------------------------------------------------------------- */
.app-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--app-muted);
}
.app-empty i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.45;
}
.app-empty p {
  margin-bottom: 1rem;
}

/* ---------------------------------------------------------------------------
   Autocompletar (cliente en OT / citas)
   --------------------------------------------------------------------------- */
.app-autocomplete {
  position: relative;
}
.input-group > .app-autocomplete {
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}
.input-group > .app-autocomplete .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.app-autocomplete-list {
  position: absolute;
  z-index: 1050;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  margin: 0;
  padding: 0.35rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(15, 23, 42, 0.12);
  max-height: 260px;
  overflow-y: auto;
}
.app-autocomplete-item {
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.app-autocomplete-item:hover,
.app-autocomplete-item.is-active {
  background: #e0f2fe;
}
.app-autocomplete-title {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.95rem;
}
.app-autocomplete-meta {
  font-size: 0.8rem;
  color: var(--app-muted);
}
.app-autocomplete-empty {
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------------------
   Pestañas de edición de OT
   --------------------------------------------------------------------------- */
.app-ot-tabs {
  border-bottom-color: var(--app-border);
}
.app-ot-tabs .nav-link {
  color: var(--app-muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.app-ot-tabs .nav-link:hover {
  color: #0f172a;
}
.app-ot-tabs .nav-link.active {
  color: #0f172a;
}

/* ---------------------------------------------------------------------------
   Login público · contadores de plataforma
   --------------------------------------------------------------------------- */
.app-login-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.app-login-stats-item {
  text-align: center;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  padding: 0.8rem 0.35rem 0.7rem;
}
.app-login-stats-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  color: #0f172a;
}
.app-login-stats-label {
  font-size: 0.72rem;
  color: var(--app-muted);
  margin-top: 0.2rem;
}

/* ---------------------------------------------------------------------------
   Dashboard admin · tarjetas de métrica
   --------------------------------------------------------------------------- */
.app-stat-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  padding: 1.05rem 1.15rem;
  height: 100%;
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
a.app-stat-card:hover {
  border-color: #bae6fd;
  box-shadow: 0 0.35rem 1rem rgba(15, 23, 42, 0.06);
  color: inherit;
}
.app-stat-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.app-stat-icon.is-sky { background: #e0f2fe; color: #0369a1; }
.app-stat-icon.is-emerald { background: #d1fae5; color: #047857; }
.app-stat-icon.is-amber { background: #fef3c7; color: #b45309; }
.app-stat-icon.is-violet { background: #ede9fe; color: #6d28d9; }
.app-stat-icon.is-slate { background: #e2e8f0; color: #334155; }
.app-stat-icon.is-rose { background: #ffe4e6; color: #be123c; }
.app-stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
  color: #0f172a;
}
.app-stat-label {
  font-size: 0.82rem;
  color: var(--app-muted);
  margin: 0;
}
.app-stat-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 0.15rem 0 0;
}

.app-panel {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  height: 100%;
}
.app-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--app-border);
}
.app-panel-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  color: #0f172a;
}
.app-panel-body {
  padding: 0;
}
.app-panel .table {
  margin-bottom: 0;
}
.app-panel .table > :not(caption) > * > * {
  padding-left: 1.1rem;
  padding-right: 1.1rem;
}

.app-status-bar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem 1.1rem;
}
.app-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.875rem;
}
.app-status-row span:first-child {
  color: #475569;
}
.app-status-track {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  min-width: 80px;
}
.app-status-fill {
  height: 100%;
  border-radius: 99px;
  background: #38bdf8;
}
.app-status-fill.is-warning { background: #f59e0b; }
.app-status-fill.is-info { background: #0ea5e9; }
.app-status-fill.is-success { background: #10b981; }
.app-status-fill.is-muted { background: #94a3b8; }

/* ---------------------------------------------------------------------------
   Accesibilidad / foco
   --------------------------------------------------------------------------- */
.app-nav-link:focus-visible,
.app-topbar-toggler:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--app-sidebar-active);
  outline-offset: 2px;
}