/* ============================================
   BAOGIA.MMCORP — Layout Styles
   ============================================ */

/* ─── App Shell ──────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: var(--z-sticky);
  transition: width var(--transition-slow);
  overflow: hidden;
}

#sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  height: var(--header-height);
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: var(--color-brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
}

.sidebar-logo-text {
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo-name {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-logo-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-disabled);
  padding: 0 var(--space-2);
  margin-bottom: var(--space-2);
  margin-top: var(--space-4);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-base);
}

#sidebar.collapsed .sidebar-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-brand-primary);
  border-color: rgba(245, 158, 11, 0.2);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--color-brand-gradient);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar.collapsed .nav-label { display: none; }
#sidebar.collapsed .sidebar-section-label { display: none; }

.nav-badge {
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

#sidebar.collapsed .nav-badge { display: none; }

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-3);
  flex-shrink: 0;
}

.user-widget {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  overflow: hidden;
}

.user-widget:hover { background: var(--bg-card); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-brand-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { overflow: hidden; flex: 1; }
.user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

#sidebar.collapsed .user-info { display: none; }

/* ─── Main Content ────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

#sidebar.collapsed ~ #main-content { margin-left: var(--sidebar-collapsed); }

/* ─── Header ─────────────────────────────────── */
#app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--header-height);
  background: rgba(8, 14, 28, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  gap: var(--space-4);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
}

.toggle-sidebar {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none; border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.toggle-sidebar:hover { background: var(--bg-elevated); color: var(--text-primary); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breadcrumb-sep { color: var(--text-disabled); }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }

.header-search {
  max-width: 340px;
  flex: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.header-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.header-btn:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-default); }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--color-danger);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--bg-base);
}

/* ─── Page Content ───────────────────────────── */
#page-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max);
  width: 100%;
}

/* ─── Grids ──────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.ratecards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

/* ─── Dashboard Layout ───────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-6);
}

.dashboard-main { min-width: 0; }
.dashboard-side { min-width: 0; }

/* ─── Quotation Builder ──────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-6);
  align-items: start;
}

.builder-main { min-width: 0; }
.builder-ai-panel { min-width: 0; }

/* ─── Login Screen ───────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: var(--space-4);
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(245,158,11,0.08) 0%, transparent 70%);
  top: -100px; right: -200px;
}

#login-screen::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(59,130,246,0.06) 0%, transparent 70%);
  bottom: -100px; left: -100px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  z-index: 1;
  animation: fadeInScale 0.4s ease;
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-logo-icon {
  width: 64px; height: 64px;
  border-radius: var(--radius-xl);
  background: var(--color-brand-gradient);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-brand);
}

.login-title {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ─── Section Wrapper ────────────────────────── */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.section-header {
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.section-title {
  font-family: var(--font-heading);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-body { padding: var(--space-5); }
.section-body-flush { }

/* ─── Quotation Export Preview ───────────────── */
.export-preview {
  background: #fff;
  color: #1a1a2e;
  min-height: 100vh;
  padding: 40px;
  font-family: var(--font-body);
}

.export-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 2px solid #E2E8F0;
}

.export-company-info h2 {
  font-size: 28px;
  font-weight: 800;
  color: #0F172A;
  font-family: var(--font-heading);
}

.export-table th { background: #F8FAFC; color: #475569; padding: 12px 16px; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.export-table td { padding: 12px 16px; border-bottom: 1px solid #F1F5F9; color: #334155; }
.export-table tr:last-child td { border-bottom: none; }

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .builder-layout { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .packages-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  #page-content { padding: var(--space-4); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .products-grid { grid-template-columns: 1fr; }
  .packages-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}
