/* =========================================================
   Koochino app shell: sidebar (desktop) + top bar + bottom
   nav (mobile/tablet) + slide-in drawer. Port of the React
   AppShell / SideNav / BottomNav prototype.
   ========================================================= */

.koo-app {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-body);
  direction: rtl;
  text-align: right;
}

.koo-app *,
.koo-app *::before,
.koo-app *::after {
  box-sizing: border-box;
}

.koo-app button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.koo-app :focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.koo-contentarea {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.koo-main {
  flex: 1;
  padding: var(--sp-4) var(--sp-4) calc(var(--nav-height) + var(--safe-bottom) + var(--sp-6));
}

.koo-inner {
  max-width: var(--app-max-width);
  margin: 0 auto;
}

/* ========== Side navigation (desktop only) ========== */
.koo-sidenav {
  display: none;
}

.koo-sidenav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2);
  margin-bottom: var(--sp-8);
}

.koo-logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.koo-logo-text {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.koo-sidenav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.koo-sidenav-section {
  margin: var(--sp-4) var(--sp-3) var(--sp-1);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
}

.koo-sidenav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 11px var(--sp-3);
  border: none;
  background: none;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.koo-sidenav-item:hover {
  background: var(--bg-surface-sunken);
  color: var(--text-primary);
}

.koo-sidenav-item.active {
  background: var(--c-green-50);
  color: var(--brand-primary-strong);
}

.koo-sidenav-item-logout {
  color: var(--c-rose-500);
}

.koo-sidenav-item-logout:hover {
  background: var(--c-rose-50);
  color: var(--c-rose-500);
}

.koo-sidenav-footer {
  padding: var(--sp-3) var(--sp-2) 0;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ========== Top bar ========== */
.koo-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding-top: var(--safe-top);
}

.koo-topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
}

.koo-topbar-title {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
}

.koo-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.koo-topbar-actions .notification-wrapper,
.koo-topbar-actions .notification__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.koo-icon-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--r-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s ease;
}

.koo-icon-btn:hover {
  background: var(--bg-surface-sunken);
}

.koo-avatar-btn {
  overflow: hidden;
  padding: 0;
}

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

.koo-identity-badge {
  position: relative;
  font-size: 18px;
  background: #fff7ed;
  border-color: #fdba74;
}

.koo-identity-badge::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f97316;
  border: 2px solid var(--bg-surface, #fff);
}

.koo-reg-gate {
  text-align: center;
  padding: 48px 20px;
  background: #fff;
  border: 1px dashed #fdba74;
  border-radius: 16px;
  margin: 12px 0;
}

.koo-reg-gate-icon {
  font-size: 2.6rem;
  margin-bottom: 12px;
}

.koo-reg-gate h3 {
  margin: 0 0 18px;
  color: #92400e;
  font-size: 1.05rem;
}

.koo-reg-gate-btn {
  background: #0d9488;
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}

.koo-id-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.koo-id-banner-pending {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.koo-id-banner-rejected {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.koo-id-banner-rejected button {
  background: #991b1b;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.koo-points-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--c-green-50);
  color: var(--brand-primary-strong);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.koo-points-chip .koo-points-value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

@media (max-width: 420px) {
  .koo-points-chip .koo-points-label {
    display: none;
  }

  .koo-topbar-row {
    gap: var(--sp-2);
    padding-inline: var(--sp-3);
  }
}

/* ========== Bottom navigation (mobile / tablet) ========== */
.koo-bottomnav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 6px 6px calc(6px + var(--safe-bottom));
  height: calc(var(--nav-height) + var(--safe-bottom));
  z-index: 40;
}

.koo-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  padding: 4px 2px;
  border-radius: var(--r-sm);
  cursor: pointer;
  touch-action: manipulation;
}

.koo-tab.active {
  color: var(--brand-primary-strong);
}

.koo-tab-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
}

.koo-tab-cta .koo-tab-icon {
  width: 34px;
  height: 34px;
  margin-top: -18px;
  border-radius: var(--r-pill);
  background: var(--brand-primary);
  color: var(--text-on-brand);
  box-shadow: 0 6px 14px -4px rgba(14, 148, 72, 0.55);
  border: 4px solid var(--bg-surface);
}

.koo-tab-label {
  font-size: 10.5px;
  font-weight: 600;
}

/* ========== Drawer (mobile menu) ========== */
.koo-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 26, 0.45);
  z-index: 900;
  animation: koo-fade-in 0.2s ease;
}

@keyframes koo-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.koo-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-surface);
  box-shadow: var(--shadow-float);
  z-index: 950;
  transition: right 0.25s ease;
  overflow-y: auto;
  direction: rtl;
  padding: var(--sp-4);
}

.koo-drawer.open {
  right: 0;
}

.koo-drawer-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--brand-primary), var(--c-green-500));
  color: var(--text-on-brand);
  margin-bottom: var(--sp-4);
}

.koo-drawer-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

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

.koo-drawer-user h3 {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.koo-drawer-user p {
  margin: 0;
  font-size: 12.5px;
  opacity: 0.9;
}

.koo-drawer-close {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  border: none;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.koo-drawer-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.koo-drawer-group {
  display: flex;
  flex-direction: column;
}

.koo-drawer-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 11px var(--sp-3);
  border: none;
  background: none;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.koo-drawer-item:hover {
  background: var(--bg-surface-sunken);
  color: var(--text-primary);
}

.koo-drawer-item.active {
  background: var(--c-green-50);
  color: var(--brand-primary-strong);
}

.koo-drawer-item-logout {
  color: var(--c-rose-500);
}

.koo-drawer-item-logout:hover {
  background: var(--c-rose-50);
  color: var(--c-rose-500);
}

.koo-drawer-chevron {
  margin-inline-start: auto;
  display: flex;
  transition: transform 0.2s ease;
}

.koo-drawer-item.open .koo-drawer-chevron {
  transform: rotate(180deg);
}

.koo-drawer-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-inline-start: var(--sp-5);
}

.koo-drawer-submenu .koo-drawer-item {
  font-size: 13px;
  font-weight: 500;
  padding: 9px var(--sp-3);
}

.koo-drawer-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-2) var(--sp-2);
}

/* ========== Tablet ========== */
@media (min-width: 640px) {
  .koo-main {
    padding-inline: var(--sp-6);
  }

  .koo-inner {
    max-width: 640px;
  }

  .koo-bottomnav {
    max-width: 640px;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--shadow-float);
    border: 1px solid var(--border-subtle);
    border-bottom: none;
  }
}

/* ========== Desktop: sidebar replaces bottom nav ========== */
@media (min-width: 1024px) {
  .koo-app {
    display: flex;
    flex-direction: row;
  }

  .koo-contentarea {
    flex: 1;
  }

  .koo-sidenav {
    display: flex;
    flex-direction: column;
    width: var(--side-nav-width);
    flex-shrink: 0;
    background: var(--bg-surface);
    border-inline-end: 1px solid var(--border-subtle);
    padding: var(--sp-6) var(--sp-4);
    position: sticky;
    top: 0;
    height: 100dvh;
  }

  .koo-main {
    padding: var(--sp-8);
  }

  .koo-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
  }

  .koo-bottomnav,
  .koo-menu-btn {
    display: none;
  }

  .koo-topbar {
    position: sticky;
  }

  .koo-topbar-title {
    text-align: right;
  }
}
