:root {
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E5E7EB;

  --brand-dark: #0F172A;
  --accent: #16A34A;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);

  --radius: 12px;
  --pill: 999px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f6f7fb;
  color: var(--text);
}

body.menu-open {
  overflow: hidden;
}

/* =========================
   HEADER
   ========================= */

.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  position: relative;
}


.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  cursor: pointer;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand-dark);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.logo svg path {
  stroke: #FFFFFF;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-text .name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text .tag {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* Navigation Center (Loc + Nav) */
.nav-center {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Location Trigger */
.loc-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: var(--pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s ease, color .15s ease;
}

.loc-btn:hover {
  background: #F1F5F9;
}

.loc-btn svg.chevron {
  color: var(--muted);
  width: 14px;
  height: 14px;
}

/* Separator */
.nav-sep {
  width: 1px;
  height: 20px;
  background: #E2E8F0;
}

/* Main Navigation (Tabs/Links) */
.main-nav {
  display: flex;
  gap: 16px;
}

.nav-link {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 0;
  position: relative;
  transition: color .15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--brand-dark);
  font-weight: 700;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  /* Adjust based on container padding */
  left: 0;
  right: 0;
  height: 2.5px;
  background: var(--brand-dark);
  border-radius: 99px;
}

.actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.btn:hover {
  background: #F8FAFC;
  border-color: #D1D5DB;
}

.btn-primary {
  background: #15BBD1;
  color: #FFFFFF;
  border-color: #15BBD1;
}

.btn-primary:hover {
  background: #12A4B8;
  border-color: #12A4B8;
  box-shadow: var(--shadow-sm);
}

.btn-primary:active {
  background: #0E8A9B;
  border-color: #0E8A9B;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.iconbtn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, border-color .15s ease;
  position: relative;
}

.mobile-menu-btn {
  display: none;
}

.iconbtn:hover {
  background: #F8FAFC;
  border-color: #D1D5DB;
}

.iconbtn:active {
  background: #F1F5F9;
}

.iconbtn.user-active {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  /* Optional: if you want the avatar itself to cast shadow, add to .avatar */
}

.iconbtn.user-active:hover {
  transform: none;
  opacity: 0.8;
  /* Simple feedback for image buttons */
}

.notif-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #EF4444;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface), 0 6px 18px rgba(239, 68, 68, .18);
  letter-spacing: -0.01em;
}

.notif-count[data-hidden="true"] {
  display: none;
}

.btn:focus-visible,
.nav-link:focus-visible,
.iconbtn:focus-visible,
.loc-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, .2);
  border-color: #cbd5e1;
}

@media (max-width: 720px) {
  .topbar {
    /* Mobile: single clean row (Brand | Location | Profile) */
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand nav actions";
    row-gap: 0;
  }

  .brand {
    grid-area: brand;
  }

  .actions {
    grid-area: actions;
  }

  .nav-center {
    grid-area: nav;
    width: 100%;
    justify-content: center;
    gap: 12px;
  }

  .nav-sep {
    display: none;
  }

  /* Maybe hide separator on mobile */
  .main-nav {
    gap: 20px;
  }

  .brand-text .tag {
    display: none;
  }

  .btn-primary span {
    display: none;
  }

  .btn-primary {
    padding: 10px 12px;
  }
}

/* =========================
   VIEWS (Home vs Search)
   ========================= */
.view {
  display: none;
}

.view.active {
  display: block;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
}

.page .view {
  padding: 18px 16px 80px;
}

/* =========================
   LAYOUT GRID
   ========================= */

.layout-wrapper {
  max-width: 1280px;
  /* Industry standard container */
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  /* Yields ~650px center feed (FB/X Standard) */
  gap: 20px;
  padding: 24px 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .layout-wrapper {
    grid-template-columns: 1fr 320px;
    /* Hide left sidebar on medium screens */
  }

  .sidebar-col.left-sidebar {
    display: none;
  }
}

@media (max-width: 900px) {
  .layout-wrapper {
    grid-template-columns: 1fr;
    /* Single column on mobile */
  }

  .sidebar-col {
    display: none;
    /* Hide all sidebars on small screens */
  }

  /* Avoid double side gutters on mobile: layout-wrapper already provides padding */
  .page .view {
    padding-left: 0;
    padding-right: 0;
  }
}

.sidebar-col {
  position: sticky;
  top: 80px;
  /* Adjust based on header height */
  height: calc(100vh - 100px);
  overflow-y: auto;
}

/* Footer Links in Sidebar */
.footer-links {
  padding: 0 8px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 8px;
}

.footer-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.footer-link:hover {
  text-decoration: underline;
  color: var(--text);
}

.copyright {
  font-size: 12px;
  color: #94A3B8;
}

/* Redefine .page max-width within the grid */
.page {
  width: 100%;
  max-width: 100%;
  /* Let grid control width */
  margin: 0;
  padding: 0;
}


/* =========================
   SEARCH VIEW STYLES
   ========================= */
/* Search View styles moved to search module */


/* =========================
   Modal (Common)
   ========================= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.overlay.show {
  display: flex;
}

.modal {
  width: min(680px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  border-bottom: 1px solid #F1F5F9;
  background: #FFFFFF;
  flex: 0 0 auto;
}

.modal-head .h {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.close {
  border: 1px solid var(--border);
  background: #FFFFFF;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.close:hover {
  background: #F8FAFC;
}

.modal-body {
  padding: 14px;
}

/* =========================
   Post Detail Modal
   ========================= */
/* Post Detail styles moved to posts module */


/* Location Modal styles moved to modules/locations/frontend/style.css per AGENTS.md Rule 7 */

/* =========================
   Profile Dropdown
   ========================= */
.dropdown-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  flex-direction: column;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.dropdown-menu.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.dropdown-item {
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  /* Reset button styles */
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.dropdown-item:hover {
  background: #F8FAFC;
  color: var(--brand-dark);
}

.dropdown-item-danger:hover {
  background: #FEF2F2;
  color: #DC2626;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* =========================
   Create Post Modal
   ========================= */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input,
.form-textarea {
  appearance: none;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
  background-color: #FFFFFF;
}

select.form-input {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 200px;
  line-height: 1.6;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}

/* Legacy Filter Input compatibility */
.filter-input {
  appearance: none;
  background-color: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

select.filter-input {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}

.filter-input:hover {
  background-color: #F8FAFC;
  border-color: #CBD5E1;
}

.filter-input:focus {
  outline: none;
  border-color: var(--brand-dark);
}

/* =========================
   DASHBOARD & PROFILE STYLES
   ========================= */

/* Dashboard and Profile styles moved to respective modules */


/* =========================
   Dashboard Manage Toolbar
   ========================= */
/* Dashboard control styles moved to posts module */

/* =========================
   MOBILE REDESIGN (Browser Only)
   ========================= */

/* Bottom Navigation Bar (Mobile Only) */
.bottom-nav {
  display: none;
}

@media (max-width: 720px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 1000;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom);
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }

  /* Hide desktop navigation elements on mobile */
  .topbar .main-nav,
  .topbar .nav-sep {
    display: none !important;
  }

  .topbar .btn-primary,
  .topbar #btnNotifications {
    display: none !important;
  }

  /* Mobile header: use a dedicated hamburger, keep it clean */
  .topbar #btnNavLogin,
  .topbar #profileWrapper {
    display: none !important;
  }

  .topbar #btnMobileMenu {
    display: grid !important;
  }

  /* Adjust location button for mobile */
  .loc-btn {
    background: #F1F5F9;
    padding: 6px 12px;
    border-radius: var(--pill);
    max-width: 220px;
    font-size: 12px;
  }

  #locLabel {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    display: inline-block;
    vertical-align: bottom;
  }

  /* Add bottom padding to main content to avoid bottom nav overlap */
  .layout-wrapper {
    padding-bottom: 80px;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 8px 12px;
    flex: 1;
    max-width: 80px;
    transition: color 0.2s ease;
    font-family: inherit;
    position: relative;
  }

  .bottom-nav-badge {
    position: absolute;
    top: 6px;
    right: 18px;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: #EF4444;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.98);
    letter-spacing: -0.01em;
    display: none;
  }

  .bottom-nav-badge[data-hidden="true"] {
    display: none;
  }

  .bottom-nav-item.active {
    color: var(--brand-dark);
  }

  .bottom-nav-item span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    stroke: none;
  }

  /* Hamburger Menu Overlay */
  .hamburger-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: flex-end;
  }

  .hamburger-overlay.show {
    display: flex;
  }

  .hamburger-menu {
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    max-height: 100vh;
    background: var(--surface);
    box-shadow: -4px 0 20px rgba(15, 23, 42, 0.15);
    overflow-y: auto;
    animation: slideInRight 0.3s ease;
    display: flex;
    flex-direction: column;
  }

  /* Fix mobile browser address-bar viewport issues */
  @supports (height: 100dvh) {
    .hamburger-menu {
      height: 100dvh;
      max-height: 100dvh;
    }
  }

  /* Older iOS Safari fallback */
  @supports (-webkit-touch-callout: none) {
    .hamburger-menu {
      height: -webkit-fill-available;
      max-height: -webkit-fill-available;
    }
  }

  @keyframes slideInRight {
    from {
      transform: translateX(100%);
    }

    to {
      transform: translateX(0);
    }
  }

  .hamburger-user-section {
    /* Rendered as a button in nav.html; reset button chrome */
    appearance: none;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;

    padding: 12px 12px;
    margin: 6px;
    border-radius: 10px;

    display: flex;
    align-items: center;
    gap: 12px;
  }

  .hamburger-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
  }

  .hamburger-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .hamburger-user-info {
    flex: 1;
    min-width: 0;
  }

  .hamburger-user-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hamburger-user-handle {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hamburger-user-section:hover {
    background: #F8FAFC;
    color: var(--brand-dark);
  }

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

  .hamburger-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: var(--text);
  }

  .hamburger-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.15s ease;
  }

  .hamburger-close:hover {
    background: #F8FAFC;
  }

  .hamburger-body {
    flex: 1;
    padding: 6px;
  }

  .hamburger-item {
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
  }

  .hamburger-item:hover {
    background: #F8FAFC;
    color: var(--brand-dark);
  }

  .hamburger-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }

  .hamburger-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
  }

  .hamburger-item-danger:hover {
    background: #FEF2F2;
    color: #DC2626;
  }

  /* Guest vs auth menu visibility */
  .hamburger-overlay.is-guest .hamburger-auth-only {
    display: none !important;
  }

  .hamburger-overlay.is-auth .hamburger-guest-only {
    display: none !important;
  }

  /* Make footer page links behave like the rest of the menu items */
  a.hamburger-item.hamburger-link {
    text-decoration: none;
  }
}

/* Hide mobile elements on desktop */
@media (min-width: 721px) {

  .bottom-nav,
  .mobile-hamburger,
  .mobile-menu-btn,
  .hamburger-overlay {
    display: none !important;
  }
}
