/* =====================================================
   RESET / BASE
===================================================== */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; /* 🔑 El scroll vive en el main */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#layout-root,
#app-layout {
  height: 100vh;
  width: 100%;
}

/* =====================================================
   LAYOUT PRINCIPAL
===================================================== */
#app-layout {
  display: flex;
  flex-direction: row;
}

/* =====================================================
   SIDEBAR
===================================================== */
.sidebar {
  width: 240px;
  height: 100vh;              /* 🔑 Fijo */
  background-color: #212529;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.08);
}

.sidebar-header {
  padding: 1.5rem 1rem;
}

.sidebar .nav {
  flex: 1;
}

.sidebar .nav-link {
  color: #cfd8dc;
  border-radius: 6px;
  margin-bottom: 4px;
  padding: 10px 12px;
  transition: background-color .15s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background-color: #1f3a5f;
  color: #ffffff;
}

/* =====================================================
   MAIN (TOPBAR + CONTENIDO)
===================================================== */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;              /* 🔑 */
  flex: 1;
  overflow: hidden;           /* 🔑 */
  background-color: #f8f9fa;
}

/* =====================================================
   TOPBAR
===================================================== */
.topbar {
  height: 64px;
  flex-shrink: 0;
  background: #ffffff;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* =====================================================
   CONTENIDO (SCROLL INTERNO)
===================================================== */
#page-content {
  flex: 1;                    /* 🔑 Ocupa el resto */
  overflow-y: auto;           /* 🔑 Scroll real */
  padding: 1.5rem;
}

/* =====================================================
   CARDS
===================================================== */
.card {
  border-radius: 12px;
}

/* =====================================================
   BOTONES
===================================================== */
.btn-primary {
  background-color: #1f3a5f;
  border-color: #1f3a5f;
}

.btn-primary:hover {
  background-color: #162c49;
  border-color: #162c49;
}

/* =====================================================
   CAMARAS
===================================================== */
.camera-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
}

.camera-label {
  padding: 6px 8px;
  font-size: 12px;
  text-align: center;
  background: #111;
  color: #e0e0e0;
  border-top: 1px solid #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* cámara activa */
.camera-box.active .camera-label {
  background: #1e3a5f;
  color: #fff;
}

.camera-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Indicador LIVE */
.camera-box::after {
  content: "LIVE";
  position: absolute;
  top: 6px;
  left: 6px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 600;
}

/* Cámara enfocada */
.camera-box.active {
  border-color: #22c55e;
}



/* =========================
   PREVIEW PRINCIPAL
========================= */
.camera-preview {
  width: 100%;
}

.camera-preview-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b0b0b;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #2a2a2a;
}

/* Imagen real */
.camera-preview-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 2;
}

/* Placeholder cuando no hay stream */
.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 13px;
  background:
    repeating-linear-gradient(
      45deg,
      #0b0b0b,
      #0b0b0b 10px,
      #111827 10px,
      #111827 20px
    );
  z-index: 1;
}

/* Label inferior */
.camera-label {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}

.camera-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-modal-body .camera-media {
  width: auto;
  height: auto;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain; /* 🔑 CLAVE */
  background: #000;
}

.camera-preview {
  position: relative;
}


/* ========================= */
/* MODAL FULLSCREEN */
/* ========================= */

.camera-modal {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

.camera-modal.hidden {
  display: none;
}

.camera-modal-header {
  height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: rgba(0,0,0,0.8);
  color: #fff;
}

.camera-modal-body {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
}

.camera-modal-body video,
.camera-modal-body img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}



/* =====================================================
   UTILIDADES
===================================================== */
.text-muted {
  color: #6c757d !important;
}

.small {
  font-size: 0.875rem;
}


/* =====================================================
   AUTOCOMPLETE
===================================================== */
.autocomplete-box {
  position: absolute;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: .375rem;
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  z-index: 1050;
  box-shadow: 0 4px 10px rgba(0,0,0,.08);
  top:38px;
}

.autocomplete-item {
  padding: .5rem .75rem;
  cursor: pointer;
  font-size: .9rem;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: #0d6efd;
  color: #fff;
}



/* ===========================
   GLOBAL LOADING OVERLAY
   =========================== */

.global-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;

  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);

  /* 🔥 CLAVE: centrado real */
  display: flex;
  align-items: center;
  justify-content: center;
}

.global-loading.hidden {
  display: none;
}

/* Caja del loading */
.loading-box {
  background: #ffffff;
  padding: 26px 30px;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);

  display: flex;
  align-items: center;
  gap: 14px;

  min-width: 220px;
}

/* Texto */
.loading-text {
  font-size: 14px;
  color: #334155;
  white-space: nowrap;
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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


.capture-card {
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.capture-image {
  width: 100%;
  display: block;
}

.capture-caption {
  background: #0f0f0f;
  color: #fff;
  font-size: 0.85rem;
  padding: 6px 10px;
  text-align: center;
  font-weight: 500;
}


.capture-card {
  position: relative;
}

.capture-badge-mobile {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(13, 110, 253, 0.95); /* bootstrap primary */
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
}

.capture-badge-mobile i {
  font-size: 12px;
}


.camera-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.mute-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
}

.mute-btn:hover {
  background: rgba(0,0,0,.85);
}


.contact-card {
  border: 1px dashed #dee2e6;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  background: #fafafa;
}

.contact-card canvas {
  max-width: 100%;
}

.contact-label {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}


/* Sidebar fijo */
.sidebar {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  flex-shrink: 0; /* 🔒 evita que Bootstrap lo reduzca */
}

/* Contenedor principal */
.main-content {
  min-width: 0; /* 🔑 CLAVE para Flexbox */
  overflow: hidden;
}

/* Sidebar base */
.sidebar {
  width: 260px;
  transition: transform 0.3s ease;
}

/* Mobile behavior */
@media (max-width: 767.98px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1030;
}

.sidebar {
  width: 260px;
  transition: transform 0.3s ease;
}

.sidebar .nav-link {
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
}

.sidebar .nav-link.active {
  background-color: rgba(255,255,255,0.15);
  font-weight: 600;
}

.sidebar .nav-link:hover {
  background-color: rgba(255,255,255,0.08);
}

.sidebar .text-muted {
  opacity: 0.7;
}

.global-loading {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.global-loading .loading-box {
  background: #fff;
  padding: 1.5rem 2rem;
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
}





