/* App shell: dark sidebar drawer, sticky top bar, alarm banner.
   Ported from CentsysAssetTrackingPortal (AppLayout / Sidebar). */

.shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Sidebar -------------------------------------------------------- */
.drawer {
  width: var(--drawer-width);
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--chrome-800);
  color: #c4ccd2;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--chrome-900);
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.drawer-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
}
.drawer-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.drawer-brand-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}
.drawer-brand-sub {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green-400);
}

.drawer-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #aeb6bd;
  font-weight: 600;
  font-size: 14.5px;
  border-left: 3px solid transparent;
  transition: background-color 0.14s ease, color 0.14s ease;
}
.drawer-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  text-decoration: none;
}
.drawer-link.active {
  background: rgba(129, 195, 65, 0.16);
  color: #fff;
  border-left-color: var(--green-500);
}
.drawer-link.active svg {
  color: var(--green-400);
}
/* Count bubble beside a nav item (open alarms, live access). */
.drawer-count {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.1);
  color: #e7ebee;
}
.drawer-count.danger {
  background: var(--danger);
  color: #fff;
}
.drawer-count.pulse {
  animation: countPulse 1.6s ease-in-out infinite;
}
@keyframes countPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(217, 75, 70, 0.6);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(217, 75, 70, 0);
  }
}

.drawer-footer {
  padding: 14px 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.drawer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 4px;
}
.drawer-user-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: #cfd6db;
}
.drawer-user-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.drawer-user-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #e7ebee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-user-company {
  font-size: 12px;
  color: #9aa3aa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-user-role {
  font-size: 11.5px;
  color: var(--green-400);
  font-weight: 600;
}
.drawer-signout {
  margin: 8px 0 0;
}
.drawer-signout .drawer-link {
  width: 100%;
  background: transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
  text-align: left;
}
.drawer-version {
  margin-top: 12px;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.drawer-version-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6f7980;
}
.drawer-version-value {
  font-size: 12.5px;
  color: #9aa3aa;
  font-variant-numeric: tabular-nums;
}

.drawer-close {
  display: none;
  margin-left: auto;
  background: transparent;
  border: none;
  color: #aeb6bd;
  padding: 6px;
  border-radius: var(--radius-sm);
  line-height: 0;
}
.drawer-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* ---- Top bar -------------------------------------------------------- */
.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-title {
  font-size: 20px;
  font-weight: 700;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-menu {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--ink-700);
  padding: 8px;
  margin-left: -6px;
  border-radius: var(--radius-sm);
  line-height: 0;
}
.topbar-menu:hover {
  background: var(--grey-100);
}

/* Status pill (top-right), like the portal's live-feed pill. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  border: none;
  font-family: var(--font-body);
}
.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.pill-ok {
  color: var(--green-700);
  background: rgba(129, 195, 65, 0.16);
}
.pill-ok .pill-dot {
  animation: dotPulse 1.6s ease-in-out infinite;
}
.pill-danger {
  color: var(--danger);
  background: rgba(217, 75, 70, 0.16);
}
.pill-danger .pill-dot {
  animation: dotPulse 0.9s ease-in-out infinite;
}
@keyframes dotPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
[data-theme='dark'] .pill-ok {
  color: #b6e08a;
}
[data-theme='dark'] .pill-danger {
  color: #f0a6a3;
}
a.pill:hover {
  text-decoration: none;
  filter: brightness(0.97);
}

.content {
  flex: 1;
  padding: 28px;
  max-width: 1440px;
  width: 100%;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 33, 37, 0.5);
  z-index: 55;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

/* ---- Alarm banner (every page) -------------------------------------- */
.alarm-banner {
  background: var(--danger);
  color: #fff;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: var(--topbar-height);
  z-index: 19;
  box-shadow: 0 4px 14px rgba(217, 75, 70, 0.3);
}
.alarm-banner.acknowledged {
  background: #8f2e2a;
  box-shadow: none;
}
.alarm-banner-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.alarm-banner:not(.acknowledged) .alarm-banner-icon {
  animation: bannerPulse 1.4s ease-in-out infinite;
}
@keyframes bannerPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.55);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
  }
}
.alarm-banner-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.alarm-banner-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
}
.alarm-banner-detail {
  font-size: 13.5px;
  opacity: 0.92;
  overflow-wrap: anywhere;
}
.alarm-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn-on-danger {
  background: #fff;
  color: var(--danger);
}
.btn-on-danger:hover:not(:disabled) {
  background: #fdeceb;
}
.btn-outline-light {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}
.btn-outline-light:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}
@media (prefers-reduced-motion: reduce) {
  .alarm-banner-icon,
  .drawer-count.pulse,
  .pill-dot {
    animation: none !important;
  }
}

/* ---- Tablet / mobile ------------------------------------------------ */
@media (max-width: 820px) {
  .drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
    z-index: 60;
    width: 280px;
    max-width: 84vw;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    box-shadow: var(--shadow-lg);
  }
  .drawer.open {
    transform: translateX(0);
  }
  .drawer-close {
    display: inline-flex;
  }
  .topbar {
    padding: 0 16px;
  }
  .topbar-menu {
    display: inline-flex;
  }
  .topbar-title {
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .content {
    padding: 18px 16px;
  }
  .alarm-banner {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .alarm-banner-actions {
    width: 100%;
  }
  .alarm-banner-actions .btn {
    flex: 1;
  }
}
@media (min-width: 821px) {
  .backdrop {
    display: none;
  }
}
@media (max-width: 560px) {
  .pill-label {
    display: none;
  }
}

/* ---- Sign-in page ----------------------------------------------------- */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at 15% 10%, rgba(129, 195, 65, 0.14), transparent 45%),
    var(--bg);
}
.auth-panel {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--chrome-800);
}
.auth-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.auth-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.auth-brand-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 17px;
  color: #fff;
}
.auth-brand-sub {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green-400);
}
.auth-card {
  padding: 26px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-title {
  font-size: 22px;
}
.auth-sub {
  margin: -8px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}
.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}
.auth-foot {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
@media (max-width: 480px) {
  .auth {
    align-items: flex-start;
    padding-top: 20px;
  }
  .auth-card {
    padding: 22px 18px 20px;
  }
}
