/* ==========================================
   360Degree M - Layout (Mobile-First)
   ========================================== */

/* App Shell */
.app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Sidebar - mobile first: hidden */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-shadow: 4px 0 24px rgba(0,0,0,0.1);
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
  z-index: 2;
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--purple);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

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

.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-nav-section {
  margin-bottom: 6px;
}

.sidebar-nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 8px 10px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
  white-space: nowrap;
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

.sidebar-link:active {
  background: var(--border);
}

.sidebar-link.active {
  background: var(--purple-light);
  color: var(--purple);
  font-weight: 600;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-bottom {
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--sidebar-bg);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--border2);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}

.sidebar-user:hover {
  background: var(--border);
}

/* Sidebar Backdrop */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sidebar-backdrop.show {
  opacity: 1;
  visibility: visible;
}

/* Main Content Area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  background: var(--bg);
  min-width: 0;
  margin-left: 0;
  margin-bottom: 60px; /* space for bottom nav */
}

/* Header - mobile */
.header {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.header-breadcrumb {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.header-breadcrumb span {
  color: var(--text3);
  font-weight: 400;
}

/* Page Content */
.page {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

/* Bottom Mobile Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 56px;
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--text3);
  font-size: 9px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  max-width: 64px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
}

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

.bottom-nav-item:active {
  background: var(--border2);
}

/* Modal - Mobile: bottom sheet */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
  animation: fadeIn 0.2s ease forwards;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal {
  position: fixed;
  z-index: 2001;
  background: var(--card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  bottom: 0;
  left: 0;
  width: 100%;
  height: auto;
  max-height: 92vh;
  border-radius: 20px 20px 0 0;
  animation: slideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
  min-height: 52px;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Desktop Layout */
@media (min-width: 1024px) {
  .sidebar {
    transform: translateX(0);
    position: relative;
    flex-shrink: 0;
    box-shadow: none;
  }

  .sidebar-backdrop {
    display: none !important;
  }

  .main {
    margin-left: 0;
    margin-bottom: 0;
  }

  .header {
    height: 56px;
    padding: 0 24px;
  }

  .header-breadcrumb {
    font-size: 14px;
  }

  .page {
    padding: 20px 24px;
  }

  .bottom-nav {
    display: none !important;
  }

  .modal {
    top: 0;
    right: 0;
    left: auto;
    bottom: auto;
    width: 460px;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    animation: slideRight 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  .modal-body {
    padding: 20px;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes slideRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(56px + env(safe-area-inset-bottom));
  }
  .main {
    margin-bottom: calc(56px + env(safe-area-inset-bottom));
  }
  @media (min-width: 1024px) {
    .main { margin-bottom: 0; }
  }
}
