/* =====================================================
   ViDA VBS Dashboard - iPhone / Mobile RWD Fix
   Paste before 
===================================================== */

@media screen and (max-width: 768px) {

  html,
  body {
    width: 100%;
    height: auto;
    min-height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body {
    background:
      radial-gradient(circle at 20% -10%, #122b5f 0, #020514 46%, #01020b 100%);
  }

  body::after {
    display: none;
  }

  /* ===== Topbar ===== */

  .topbar {
    height: auto !important;
    min-height: 86px;
    padding: 14px 18px !important;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 14px;
    flex-direction: column;
    overflow: hidden;
  }

  .brand {
    width: 100%;
    gap: 12px;
    align-items: center;
  }

  .brand img.nav-logo {
    max-width: 82px !important;
    height: auto !important;
    flex: 0 0 auto;
  }

  .brand-title {
    min-width: 0;
    flex: 1;
  }

  .brand-title span:first-child {
    font-size: 20px !important;
    line-height: 1.2;
    letter-spacing: .12em !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .brand-title span:last-child {
    font-size: 12px !important;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .city-switch {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow: visible;
  }

  .city-switch span {
    width: 100%;
    margin-right: 0;
  }

  .city-switch button {
    flex: 1 1 30%;
    min-width: 82px;
    padding: 8px 10px;
    font-size: 12px;
  }

  /* ===== Main layout unlock ===== */

  .main {
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    display: block !important;
    padding: 16px 14px 28px !important;
    overflow: visible !important;
  }

  .row-arch,
  .row-log,
  .row-cms {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    gap: 16px !important;
  }

  .row-log {
    margin-top: 16px;
  }

  /* ===== Panels ===== */

  .panel,
  .cms-wall,
  .panel-kpi,
  .log-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 16px 16px !important;
    border-radius: 18px !important;
    overflow: hidden !important;
  }

  .panel-header {
    display: block !important;
  }

  .panel-title {
    align-items: flex-start;
    gap: 8px;
  }

  .panel-title span:first-child {
    display: block;
    font-size: 12px !important;
    letter-spacing: .16em;
    line-height: 1.5;
  }

  .panel-title span:last-child {
    display: block;
    font-size: 18px !important;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .pills {
    margin-top: 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .pill {
    max-width: 100%;
    white-space: normal;
    line-height: 1.3;
  }

  /* ===== Ingest nodes ===== */

  .node-list {
    gap: 10px;
  }

  .node-item {
    width: 100%;
    display: block !important;
    padding: 12px 12px !important;
  }

  .node-item-main {
    align-items: flex-start;
  }

  .node-item-label span,
  .node-item-label small {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.45;
  }

  .badge {
    display: inline-flex;
    margin-top: 10px;
  }

  /* ===== VBS Core ===== */

  .vbs-core {
    margin-top: 16px;
    padding: 18px 16px !important;
  }

  .vbs-core h3 {
    font-size: 20px !important;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .vbs-core p {
    font-size: 13px !important;
    line-height: 1.65;
  }

  .vbs-metrics {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: left;
  }

  .vbs-metrics span {
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,.05);
  }

  /* ===== CMS wall ===== */

  .cms-wall {
    min-height: auto !important;
  }

  .cms-wall-header {
    display: block !important;
    line-height: 1.5;
  }

  .cms-wall-header > div + div {
    margin-top: 8px;
  }

  .cms-wall-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: none !important;
    gap: 12px !important;
    height: auto !important;
  }

  .cms-screen {
    width: 100%;
    height: auto !important;
    aspect-ratio: 16 / 9;
    min-height: 160px;
  }

  .VBS1-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
  }

  .cms-info {
    height: auto;
    min-height: 26px;
    padding: 5px 8px;
    font-size: 11px;
  }

  /* ===== KPI ===== */

  .kpi-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .kpi-item {
    min-width: 0;
    padding: 10px 10px;
    font-size: 12px;
    line-height: 1.4;
  }

  .kpi-item span.value {
    font-size: 16px;
    overflow-wrap: anywhere;
  }

  /* ===== Logs ===== */

  .log-list {
    max-height: 220px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    font-size: 12px !important;
    line-height: 1.55;
  }

  .log-line {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word;
    padding: 4px 0;
  }

  .log-line span {
    overflow-wrap: anywhere;
  }

  /* ===== Footer ===== */

  .footer-meta {
    position: static !important;
    width: 100%;
    margin-top: 18px;
    padding: 0 4px 8px;
    font-size: 13px;
    line-height: 1.6;
    color: #e7f4ff;
  }
}


/* iPhone 14 Pro Max / 430px  */
@media screen and (min-width: 391px) and (max-width: 430px) {

  .main {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .panel,
  .cms-wall,
  .panel-kpi,
  .log-panel {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  .brand-title span:first-child {
    font-size: 21px !important;
  }
}


/* iPhone 12 / 390px  */
@media screen and (max-width: 390px) {

  .main {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .topbar {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .brand-title span:first-child {
    font-size: 18px !important;
  }

  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
}

/* =====================================================
   CMS Wall Image Fix
   Fix image appears as thin strip
===================================================== */

.cms-screen {
  position: relative;
  overflow: hidden;
}

.VBS1-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: .78;
  z-index: 0;
}

.cms-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      to bottom,
      rgba(2,5,20,.15),
      rgba(2,5,20,.28)
    );
  pointer-events: none;
  z-index: 1;
}

.cms-scan,
.cms-overlay {
  z-index: 2;
}

.cms-info {
  z-index: 3;
}

/* Mobile CMS preview height */
@media screen and (max-width: 768px) {
  .cms-screen {
    aspect-ratio: 16 / 9;
    min-height: 180px;
  }

  .cms-wall-grid {
    gap: 14px ;
  }

  .cms-info {
    min-height: 30px;
    font-size: 12px;
  }
}