/* ===========================================================================
   APP LAYOUT — Otlo Design System
   Mobile: bottom nav | Desktop: sidebar
   ========================================================================= */

/* ===========================
   APP SHELL — always column
   =========================== */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-canvas);
}

/* ===========================
   HEADER — full width, sticky, offset by sidebar on desktop
   =========================== */
#app-header {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-nav) - 1);
  width: 100%;
}
@media (min-width: 768px) {
  #app-header {
    margin-left: 280px;
    width: calc(100% - 280px);
  }
}

/* ===========================
   DESKTOP SIDEBAR
   =========================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border-subtle);
  z-index: var(--z-nav);
  display: none;
  flex-direction: column;
  padding: var(--space-6);
  overflow-y: auto;
}
@media (min-width: 768px) {
  .sidebar { display: flex; }
}

.sidebar-logo {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: var(--fw-black);
  background: var(--gradient-silk);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: var(--ls-display);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-6);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  text-decoration: none;
  font-weight: var(--fw-medium);
  font-size: var(--fs-body);
}
.sidebar-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.sidebar-item.active {
  background: var(--brand-wash);
  color: var(--text-brand);
  font-weight: var(--fw-semibold);
}

.sidebar-section-title {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: var(--space-3) var(--space-4) var(--space-1);
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) var(--space-4);
}

/* ===========================
   SIDEBAR — More Dropdown Panel
   =========================== */
.sidebar-dropdown {
  position: relative;
}

.sidebar-more-toggle {
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.sidebar-chevron {
  margin-left: auto;
  transition: transform var(--dur-fast) var(--ease-out);
  opacity: 0.5;
}

.sidebar-dropdown.is-open .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-more-panel {
  position: fixed;
  left: calc(280px + 8px);
  top: 50%;
  transform: translateY(-50%) scale(0.96);
  width: 220px;
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0,0,0,0.03);
  z-index: calc(var(--z-nav) + 10);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-normal) var(--ease-out), transform var(--dur-normal) var(--ease-out);
  overflow: hidden;
}

.sidebar-dropdown.is-open .sidebar-more-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.sidebar-panel-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin: var(--space-2);
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
}

.sidebar-panel-search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: var(--fs-small);
  font-family: inherit;
  color: var(--text-primary);
  min-width: 0;
}

.sidebar-panel-search input::placeholder {
  color: var(--text-tertiary);
}

.sidebar-panel-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 0 var(--space-1) var(--space-1);
  scrollbar-width: thin;
}

.sidebar-more-panel-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: var(--fw-medium);
  font-size: var(--fs-small);
  transition: all var(--dur-fast) var(--ease-out);
}

.sidebar-more-panel-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sidebar-more-panel-item.active {
  background: var(--brand-wash);
  color: var(--text-brand);
}

.sidebar-more-panel-item .panel-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-sunken);
  flex-shrink: 0;
}

.sidebar-more-panel-item.active .panel-icon {
  background: var(--brand-wash);
}

/* Backdrop for sidebar panel */
.sidebar-more-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-nav) + 5);
  display: none;
}

.sidebar-dropdown.is-open .sidebar-more-backdrop {
  display: block;
}

/* ===========================
   MOBILE — More Bottom Sheet
   =========================== */
.more-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-nav);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-normal) var(--ease-out);
}

.more-sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.more-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-raised);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  z-index: calc(var(--z-nav) + 1);
  transform: translateY(100%);
  transition: transform var(--dur-normal) var(--ease-out);
  padding-bottom: calc(var(--safe-bottom) + var(--space-4));
  max-height: 55vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.more-sheet.is-open {
  transform: translateY(0);
}

.more-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-default);
  margin: var(--space-3) auto var(--space-1);
  flex-shrink: 0;
}

.more-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter) var(--space-2);
  flex-shrink: 0;
}

.more-sheet-title {
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
}

.more-sheet-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 var(--gutter) var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-sunken);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.more-sheet-search-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.more-sheet-search {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: var(--fs-body);
  font-family: inherit;
  color: var(--text-primary);
  min-width: 0;
}

.more-sheet-search::placeholder {
  color: var(--text-tertiary);
}

.more-sheet-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--gutter);
  scrollbar-width: thin;
}

.more-sheet-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: var(--fw-medium);
  font-size: var(--fs-body);
  transition: all var(--dur-fast) var(--ease-out);
}

.more-sheet-item:active {
  background: var(--surface-hover);
}

.more-sheet-item-label {
  flex: 1;
}

.more-sheet-item-arrow {
  opacity: 0.3;
  flex-shrink: 0;
}

.more-sheet-item .sheet-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===========================
   APP CONTENT
   =========================== */
.app-content {
  flex: 1;
  min-width: 0;
  padding-bottom: calc(var(--nav-height) + var(--nav-inset) * 2 + var(--safe-bottom) + 16px);
}
@media (min-width: 768px) {
  .app-content {
    margin-left: 280px;
    padding-bottom: 0;
  }
}

/* ===========================
   FEED PAGE
   =========================== */
.feed-page {
  background: var(--bg-canvas);
  min-height: 100%;
}

.feed-filters {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-2) var(--gutter);
}

.feed-filter-bar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.feed-select {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 var(--space-3);
  padding-right: var(--space-6);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--surface-sunken);
  color: var(--text-primary);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239CA3AF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.feed-select:focus {
  outline: none;
  border-color: var(--brand-action);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
.feed-select-sort {
  flex: 0 0 auto;
  width: auto;
  min-width: 120px;
}

/* ===========================
   MAP CONTAINER
   =========================== */
.map-container {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--header-height) - var(--nav-height) - var(--safe-bottom));
}
@media (min-width: 768px) {
  .map-container { height: calc(100vh - var(--header-height)); }
}

/* ===========================
   PAGE CONTAINERS
   =========================== */
.page {
  max-width: 720px;
  padding: var(--space-4);
}
@media (min-width: 768px) {
  .page {
    padding: var(--space-4) var(--space-6);
  }
}

/* ===========================
   GRID LAYOUTS
   =========================== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.marketplace-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .marketplace-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===========================
   BOTTOM NAV — hide on desktop
   =========================== */
@media (min-width: 768px) {
  .bottom-nav { display: none !important; }
}

/* ===========================
   FAB — mobile only
   =========================== */
@media (min-width: 768px) {
  .btn-fab, .fab { display: none !important; }
}
