/* FalconTech Team Portal v4 – Layout (Black Sidebar + Clean Grid) */

/* === Container === */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* === Sidebar (Dark Gradient) === */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--gradient-sidebar);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow: hidden;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-top {
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--sidebar-text-active);
}

.sidebar-logo-mark {
  width: 38px;
  height: 38px;
  background: var(--color-white);
  color: var(--color-black);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-lg);
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-logo-name {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  color: var(--sidebar-text-active);
}

.sidebar-logo-sub {
  font-size: 11px;
  color: var(--sidebar-text);
  font-weight: var(--font-weight-normal);
}

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

.sidebar-section-label {
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  color: var(--sidebar-section);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.sidebar-section-label:first-child {
  padding-top: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-fast);
  position: relative;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: var(--font-weight-semibold);
  box-shadow: inset 0 0 0 1px rgba(59, 125, 216, 0.3);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--color-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.sidebar-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-link.active .sidebar-link-icon {
  opacity: 1;
}

.sidebar-link-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-link-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* TRAFFICX Premium Link */
.sidebar-link-premium {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(168, 85, 247, 0.08) 100%);
  border: 1px solid rgba(99, 102, 241, 0.15);
  margin-top: 2px;
  margin-bottom: 2px;
}

.sidebar-link-premium:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.sidebar-link-premium.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.15);
}

.sidebar-link-premium .sidebar-link-icon {
  opacity: 1;
  color: #818cf8;
}

.sidebar-link-premium .sidebar-link-label {
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-link-badge {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 4px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  line-height: 1.4;
  flex-shrink: 0;
}

/* Sidebar Bottom (User) */
.sidebar-bottom {
  padding: var(--space-4) var(--space-4);
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

.sidebar-user .avatar {
  width: 34px;
  height: 34px;
  font-size: var(--font-size-xs);
  background: var(--color-accent);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-user-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--sidebar-text-active);
  line-height: 1.2;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--sidebar-text);
}

.sidebar-logout {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.sidebar-logout svg {
  width: 16px;
  height: 16px;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* === Topbar (Mobile only) === */
.topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  z-index: var(--z-header);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  height: 100%;
}

.topbar-menu {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: background var(--transition-fast);
}

.topbar-menu:hover {
  background: var(--color-bg);
}

.topbar-menu svg {
  width: 20px;
  height: 20px;
}

.topbar-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

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

/* === Page Layout with Sidebar === */
.has-sidebar .page {
  margin-left: var(--sidebar-width);
  padding-top: var(--space-8);
  padding-bottom: var(--space-16);
  min-height: 100vh;
}

/* === Grid System === */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Bento Grid */
.bento {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(4, 1fr);
}

.bento-span-2 { grid-column: span 2; }
.bento-span-3 { grid-column: span 3; }
.bento-span-4 { grid-column: span 4; }

/* === Flex Helpers === */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* === Section === */
.section {
  margin-bottom: var(--space-8);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

/* === Login Layout === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-6);
  background: var(--color-bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-10);
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  animation: fadeInUp 0.5s ease;
}

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

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: var(--color-black);
  color: var(--color-white);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-md);
}

.login-logo h1 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-1);
  color: var(--color-text);
}

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

.login-error {
  padding: var(--space-3);
  background: var(--color-danger-light);
  color: var(--color-danger);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
  display: none;
}

.login-error.visible {
  display: block;
}

/* === Two Column Layout (Notes) === */
.two-col {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-6);
  min-height: calc(100vh - var(--space-16));
}

.sidebar-panel {
  position: sticky;
  top: var(--space-8);
  max-height: calc(100vh - var(--space-8));
  overflow-y: auto;
}

/* === Kanban Layout === */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  min-height: 400px;
}

.kanban-column {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  border: none;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-border);
}

.kanban-column-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}

.kanban-count {
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
  background: var(--color-white);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.kanban-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 60px;
}

.kanban-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
  position: relative;
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
  transform: translateY(-2px);
}

.kanban-card-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-3);
  line-height: var(--line-height-tight);
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-text-muted);
}

/* === Drawer (Lead Detail) === */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: var(--z-drawer);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.drawer-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: var(--color-card-solid);
  box-shadow: var(--shadow-xl);
  z-index: calc(var(--z-drawer) + 1);
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.drawer.active {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-card-solid);
  z-index: 1;
}

.drawer-body {
  padding: var(--space-6);
  flex: 1;
}

/* === Responsive === */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .bento-span-3 { grid-column: span 2; }
  .bento-span-4 { grid-column: span 2; }
  .kanban { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .sidebar-panel {
    position: static;
    max-height: none;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .has-sidebar .page {
    margin-left: 0;
    padding-top: calc(var(--topbar-height) + var(--space-6));
  }

  .topbar {
    display: block;
  }
}

@media (max-width: 768px) {
  :root {
    --container-padding: var(--space-4);
    --topbar-height: 56px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .bento {
    grid-template-columns: 1fr;
  }

  .bento-span-2,
  .bento-span-3,
  .bento-span-4 {
    grid-column: span 1;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .drawer {
    width: 100%;
    max-width: 100%;
  }
}
