/* ============================================================
   HOOKIE.NET — Layout
   App shell, nav, sidebar, page wrappers
   ============================================================ */

/* =============================================
   APP SHELL
============================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--nav-height) 1fr;
  min-height: 100vh;
}

/* =============================================
   TOP NAV
============================================= */
.topnav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: rgba(13, 13, 18, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-height);
}

/* Logo (match auth styling) */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--flame);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--glow-flame);
  transition: transform var(--dur-med) var(--ease-bounce);
}

.logo-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.logo:hover .logo-icon {
  transform: rotate(-8deg) scale(1.06);
}

.logo-name { color: var(--text); }
.logo-tld { color: var(--flame); }

/* Search */
.topnav-search {
  flex: 1;
  max-width: 360px;
  margin-left: var(--space-4);
  position: relative;
}

.topnav-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-pill);
  padding: 9px 18px 9px 40px;
  font-size: 0.875rem;
  transition: border-color var(--dur-med), box-shadow var(--dur-med);
}

.topnav-search input:focus {
  border-color: rgba(76, 142, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(76, 142, 255, 0.1);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 0.9rem;
  pointer-events: none;
}

.topnav-spacer {
  flex: 1;
}

/* =============================================
   COUNTRY SELECTOR
============================================= */
.country-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color var(--dur-med), background var(--dur-med);
  user-select: none;
}

.country-selector:hover,
.country-selector.open {
  border-color: rgba(76, 142, 255, 0.4);
  background: var(--surface-2);
}

.cs-flag   { font-size: 1.1rem; }
.cs-label  { font-size: 0.65rem; color: var(--text-3); line-height: 1; }
.cs-name   { font-size: 0.8rem; font-weight: 600; color: var(--text-2); line-height: 1; margin-top: 1px; }
.cs-arrow  { color: var(--text-3); font-size: 0.7rem; transition: transform var(--dur-med); margin-left: 2px; }

.country-selector.open .cs-arrow {
  transform: rotate(180deg);
}

/* Dropdown */
.country-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: var(--space-2);
  min-width: 230px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity var(--dur-med) var(--ease), transform var(--dur-med) var(--ease);
  z-index: 300;
}

.country-dropdown.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.cd-header {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding: 6px 10px 10px;
}

.cd-search {
  padding: 0 6px 8px;
}

.cd-search input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.8rem;
}

.cd-search input:focus {
  border-color: rgba(76, 142, 255, 0.3);
}

.cd-list {
  max-height: 280px;
  overflow-y: auto;
}

.country-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast);
  font-size: 0.875rem;
}

.country-option:hover        { background: var(--surface-2); }
.country-option.active       { background: rgba(76, 142, 255, 0.1); color: var(--flame-2); }

.co-flag                { font-size: 1.1rem; }
.co-name                { flex: 1; font-weight: 500; }
.co-count {
  font-size: 0.68rem;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.cd-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) 0;
}

.cd-add-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--flame);
  font-weight: 600;
  transition: background var(--dur-fast);
  width: 100%;
}

.cd-add-btn:hover {
  background: rgba(76, 142, 255, 0.08);
}

/* =============================================
   NAV ACTIONS
============================================= */
.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 1rem;
  transition: all var(--dur-med) var(--ease);
}

.nav-icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-2);
}

.nav-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 17px;
  height: 17px;
  background: var(--rose);
  border-radius: var(--radius-pill);
  font-size: 0.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
  padding: 0 3px;
}

.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--flame);
  cursor: pointer;
  transition: transform var(--dur-med) var(--ease-bounce), box-shadow var(--dur-med);
  flex-shrink: 0;
}

.nav-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(76, 142, 255, 0.25);
}

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

/* =============================================
   SIDEBAR
============================================= */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: var(--space-6) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow-y: auto;
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
}

.sidebar-section {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-4);
  padding: var(--space-3) var(--space-3) var(--space-2);
  margin-top: var(--space-2);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  text-decoration: none;
  user-select: none;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.active {
  background: rgba(76, 142, 255, 0.1);
  color: var(--flame-2);
}

.nav-item.active .nav-item-icon {
  color: var(--flame);
}

.nav-item-icon {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item-badge {
  margin-left: auto;
  background: var(--rose);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.nav-item-badge.muted {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast);
}

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

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--flame);
  flex-shrink: 0;
}

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

.sidebar-user-name  { font-size: 0.875rem; font-weight: 600; }
.sidebar-user-status {
  font-size: 0.72rem;
  color: var(--online);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =============================================
   MAIN CONTENT AREA
============================================= */
.main-content {
  padding: var(--space-8) var(--space-8);
  overflow-y: auto;
  height: calc(100vh - var(--nav-height));
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.page-header-left h1 {
  line-height: 1.05;
}

.page-header-left h1 span {
  color: var(--flame);
}

.page-header-left p {
  font-size: 0.875rem;
  margin-top: var(--space-2);
}

.page-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.section-count {
  font-size: 0.75rem;
  color: var(--text-3);
  background: var(--surface);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.section-link {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--flame-2);
  font-weight: 600;
  opacity: 0.8;
}

.section-link:hover {
  opacity: 1;
  color: var(--flame-2);
}

/* =============================================
   SORT / VIEW CONTROLS
============================================= */
.sort-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--dur-fast);
}

.sort-select:hover { border-color: var(--border-2); }
.sort-select option { background: var(--surface-2); }

.view-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.view-btn {
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
  color: var(--text-2);
  transition: all var(--dur-fast);
  display: flex;
  align-items: center;
  gap: 5px;
}

.view-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

/* =============================================
   RESPONSIVE
============================================= */
@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    height: calc(100vh - var(--nav-height));
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: var(--space-4);
  }

  .topnav-search {
    display: none;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-right {
    margin-left: 0;
  }
}
