/* ===========================
   GMAIL-STYLE LAYOUT
   =========================== */

:root {
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 64px;
  --gap: 16px;
}

/* Dashboard View Container */
.dashboard-view {
  display: none;
  height: 100vh;
  overflow: hidden;
}

.dashboard-view.active {
  display: block;
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: var(--gap);
  padding: 0 16px;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
}

.icon-btn {
  height: 40px;
  width: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: #f1f3f4;
}

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 18px;
  height: 2px;
  background: #5f6368;
  content: "";
  margin: 0 auto;
  position: relative;
}

.hamburger {
  top: 0;
}

.hamburger::before {
  position: absolute;
  top: -6px;
}

.hamburger::after {
  position: absolute;
  top: 6px;
}

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

.logo-placeholder {
  height: 40px;
  width: 40px;
  border-radius: 8px;
  background: #336699;
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
}

.brand-name {
  font-weight: 600;
  font-size: 20px;
  color: #1a4d7a;
  letter-spacing: 0.2px;
}

.search {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  padding: 6px 8px 6px 16px;
  background: #f8f9fa;
}

.search-form input {
  flex: 1;
  height: 32px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
}

.search-btn {
  height: 32px;
  padding: 0 16px;
  border: none;
  background: #336699;
  color: white;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.search-btn:hover {
  background: #2a5580;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Account Dropdown */
.account-dropdown {
  position: relative;
}

.avatar {
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
  background: #fafafa;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}

.avatar:hover {
  border-color: #336699;
}

.avatar-initial {
  font-weight: 600;
  font-size: 14px;
  color: #336699;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  display: none;
  z-index: 1000;
}

.dropdown-menu.active {
  display: block;
}

.dropdown-email {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
  color: #666;
}

.dropdown-item {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: #333;
}

.dropdown-item:hover {
  background: #f8f9fa;
}

/* Main App Layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  border-right: 1px solid #e0e0e0;
  padding: 16px 8px;
  background: #fff;
  overflow-y: auto;
  transition: width 0.22s ease;
}

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

.nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav li {
  margin: 2px 0;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #333;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.nav a:hover {
  background: #f1f3f4;
}

.nav a.active {
  background: #e8f0fe;
  color: #1967d2;
}

.nav .nav-section {
  font-size: 11px;
  color: #5f6368;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 12px 6px;
  font-weight: 600;
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bdbdbd;
  flex-shrink: 0;
}

.collapse-header {
  font-size: 13px;
  color: #3c4043;
  padding: 10px 12px;
  font-weight: 600;
}

.sub a {
  padding-left: 32px;
  font-size: 13px;
}

/* Workspace */
.workspace {
  padding: 24px;
  overflow-y: auto;
  background: #f5f5f5;
}

.summary {
  display: none; /* Hidden for now - can bring back later */
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  margin-bottom: 24px;
}

.kpi {
  padding: 20px;
}

.kpi-label {
  font-size: 12px;
  color: #5f6368;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: #202124;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Responsive - Tablet */
@media (max-width: 960px) {
  .search {
    max-width: 400px;
  }
  .summary {
    grid-template-columns: 1fr;
  }
}

/* Responsive - Mobile Landscape and Portrait */
@media (max-width: 720px) {
  /* Hide sidebar by default, make it slide-out */
  .app {
    grid-template-columns: 0 1fr;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 50;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Topbar adjustments for mobile */
  .topbar {
    grid-template-columns: auto auto 1fr auto;
    gap: 8px;
    padding: 0 8px;
    height: 56px;
  }

  :root {
    --topbar-h: 56px;
  }

  .brand-name {
    display: none;
  }

  .logo-placeholder {
    height: 36px;
    width: 36px;
    font-size: 18px;
  }

  /* Make search responsive */
  .search {
    max-width: 100%;
  }

  .search-form {
    padding: 4px 6px 4px 12px;
  }

  .search-form input {
    font-size: 13px;
    min-width: 0;
  }

  .search-btn {
    font-size: 12px;
    padding: 0 12px;
  }

  /* Compact workspace */
  .workspace {
    padding: 12px;
  }

  /* Make cards more compact */
  .analysis-card {
    padding: 16px;
  }

  .analysis-meta {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
}

/* Extra small screens - Portrait phones */
@media (max-width: 480px) {
  .topbar {
    padding: 0 4px;
    gap: 4px;
  }

  .icon-btn {
    height: 36px;
    width: 36px;
  }

  .logo-placeholder {
    height: 32px;
    width: 32px;
    font-size: 16px;
  }

  .search-form {
    padding: 4px 4px 4px 10px;
  }

  .search-form input {
    font-size: 12px;
    min-width: 0;
  }

  .search-btn {
    padding: 0 8px;
    font-size: 11px;
  }

  .avatar {
    height: 36px;
    min-width: 36px;
  }

  .avatar-initial {
    font-size: 13px;
  }

  .workspace {
    padding: 8px;
  }

  .analysis-card {
    padding: 12px;
    font-size: 13px;
  }

  .takeaway-list li {
    font-size: 13px;
  }

  .feed {
    gap: 12px;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  html, body {
    height: auto;
    overflow-y: auto;
  }

  .dashboard-view {
    height: auto;
    overflow-y: auto;
  }

  .app {
    display: block;
    height: auto;
    overflow: visible;
  }

  .workspace {
    padding-bottom: 80px;
    overflow: visible;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    z-index: 200;
  }

  .analysis-card {
    width: 100%;
    box-sizing: border-box;
  }

  /* --- Fix topbar overflow and clipping on portrait --- */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }

  .search {
    flex: 1;
    min-width: 0; /* prevent input from forcing overflow */
  }

  .search-form input {
    min-width: 0; /* ensures input shrinks properly */
  }

  .topbar-actions {
    flex-shrink: 0; /* keep avatar visible */
  }

  .brand {
    flex-shrink: 0;
  }
}