/**
 * FOMS - Layout Stylesheet
 * Sidebar, Topbar, Main Split Content, Responsive Drawer
 */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* =========================================
   SIDEBAR
   ========================================= */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: width var(--transition-normal), transform var(--transition-normal);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.brand-title {
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-subtitle {
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  letter-spacing: 0.8px;
  padding: 0 10px 4px 10px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  color: var(--color-sidebar-text);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}

.nav-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  background-color: var(--color-sidebar-hover);
  color: #f1f5f9;
}

.nav-item.active {
  background-color: var(--color-sidebar-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-badge {
  margin-left: auto;
  background-color: #334155;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 9999px;
}

.nav-item.active .nav-badge {
  background-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-badge-sidebar {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar-sidebar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: #2563eb;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-info-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 1.2;
}

.user-name-sidebar {
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-sidebar {
  color: #94a3b8;
  font-size: 11px;
}

/* =========================================
   TOPBAR
   ========================================= */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left var(--transition-normal);
}

.app-topbar {
  height: var(--topbar-height);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-xs);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 520px;
}

.sidebar-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-toggle-btn:hover {
  background-color: var(--color-surface-subtle);
  color: var(--color-text-main);
}

.global-search-wrapper {
  position: relative;
  width: 100%;
}

.global-search-input {
  width: 100%;
  height: 38px;
  background-color: var(--color-surface-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 16px 0 38px;
  font-size: 13.5px;
  color: var(--color-text-main);
  transition: all var(--transition-fast);
}

.global-search-input:focus {
  outline: none;
  background-color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-icon-fixed {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.system-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.system-status-pill.demo {
  background-color: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.system-status-pill.live {
  background-color: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
}

.demo .status-indicator-dot { background-color: #f59e0b; }
.live .status-indicator-dot { background-color: #10b981; }

.topbar-action-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  background-color: var(--color-surface-subtle);
  position: relative;
  transition: all var(--transition-fast);
}

.topbar-action-btn:hover {
  color: var(--color-text-main);
  background-color: var(--color-border);
}

.notification-count-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: var(--color-danger);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  width: 17px;
  height: 17px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
}

/* =========================================
   PAGE CONTAINER & 2-COLUMN SPLIT
   ========================================= */
.app-content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.banner-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.banner-subtitle {
  color: #cbd5e1;
  font-size: 13px;
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 2-Column Split for Dashboard (Desktop) */
.dashboard-split-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.dashboard-main-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.dashboard-side-column {
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Backdrop for Mobile Sidebar */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 45;
  display: none;
}

/* =========================================
   RESPONSIVE BREAKPOINTS
   ========================================= */
@media (max-width: 1200px) {
  .dashboard-split-layout {
    grid-template-columns: 1fr;
  }
  .dashboard-side-column {
    position: static;
  }
}

@media (max-width: 860px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.active {
    display: block;
  }
  .app-main {
    margin-left: 0;
  }
  .topbar-left {
    max-width: 280px;
  }
  .app-content {
    padding: 16px;
  }
}
