/* ═══════════════════════════════════════════════════════════
   layout.css — Header, Sidebar, Main, Bottom Nav, Grids
   Masri.Cloud Dashboard v2
   ═══════════════════════════════════════════════════════════ */

/* ── Outer layout ────────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  position: relative;
  z-index: 1;
}

/* ═══════════════════ HEADER ══════════════════════════════ */
header {
  height: var(--header-h);
  background: rgba(6,13,31,0.85);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  text-decoration: none;
  user-select: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--grad-accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 0 16px var(--accent-glow);
}

.logo span { color: var(--accent); }

/* Header right */
.hdr-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#hdr-phone {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-2);
  display: none; /* shown on desktop via layout.css media query */
}

/* Plan badge */
.badge-plan {
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border: 1px solid var(--accent-dim);
}
.badge-plan.pro {
  background: rgba(34,197,94,0.12);
  color: var(--success);
  border-color: rgba(34,197,94,0.3);
}

/* Hamburger */
.ham {
  width: 36px;
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  transition: var(--t-fast);
}
.ham:hover { border-color: var(--accent); background: var(--accent-dim); }
.ham span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-2);
  border-radius: 2px;
  transition: var(--t-normal);
}
.ham:hover span { background: var(--accent); }
.ham.open span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.ham.open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.ham.open span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* Logout button */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid rgba(255,85,85,0.25);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  transition: var(--t-fast);
}
.btn-logout:hover {
  background: rgba(255,85,85,0.12);
  border-color: var(--danger);
}

/* ═══════════════════ SIDEBAR ══════════════════════════════ */
aside {
  width: var(--sidebar);
  background: #0f1117;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  padding: 12px 0 12px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 26px;
  z-index: 150;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}

aside::-webkit-scrollbar { width: 3px; }
aside::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }

/* Sidebar sections */
.nav-section {
  padding: 0 0 6px;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: 8px 16px 8px;
}

.nav-divider {
  height: 0.5px;
  background: rgba(255,255,255,0.06);
  margin: 6px 16px;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 16px;
  border-radius: 0;
  border-left: 2px solid transparent;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.52);
  transition: var(--t-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.8);
}

.nav-item.active {
  background: rgba(74,222,128,0.08);
  color: #4ade80;
  font-weight: 600;
  border-left-color: #4ade80;
}

.nav-item-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-item-main span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-main i {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.nav-badge-success {
  background: rgba(74,222,128,0.12);
  color: #4ade80;
}

.nav-badge-warn {
  background: rgba(251,191,36,0.12);
  color: #fbbf24;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 12px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 4px 4px;
}

.sidebar-footer-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #4ade80;
  color: #0f1117;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-footer-meta {
  min-width: 0;
  flex: 1;
}

.sidebar-footer-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  line-height: 1.2;
}

.sidebar-footer-plan {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  line-height: 1.3;
  margin-top: 2px;
}

.sidebar-footer-menu {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.42);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-footer-menu:hover {
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.78);
}

.sidebar-footer-plan {
  word-break: break-word;
}

/* ═══════════════════ MAIN CONTENT ═════════════════════════ */
main {
  flex: 1;
  margin-left: var(--sidebar);
  margin-top: var(--header-h);
  padding: 28px 28px 50px;
  min-height: calc(100vh - var(--header-h));
  position: relative;
  z-index: 1;
}

/* ── Page system ─────────────────────────────────────────── */
.page          { display: none; }
.page.active   { display: block; }

/* Sec header */
.sec-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

.sec-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.sec-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 3px;
}

/* ── Grid system ─────────────────────────────────────────── */
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.grid4 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* ── Iframes ─────────────────────────────────────────────── */
.embed-frame {
  width: 100%;
  height: calc(100vh - var(--header-h) - 28px - 26px);
  border: none;
  border-radius: var(--radius);
  background: var(--bg-2);
  display: block;
}

/* ── Creator Studio full-bleed ── */
#page-creator {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
#page-creator.active {
  display: flex;
}
#creator-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}

/* ── Quiz Battle full-bleed ── */
#page-quiz {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
#page-quiz.active {
  display: flex;
}
#quiz-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}

/* ── Co-Draw Game full-bleed ── */
#page-game {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
#page-game.active {
  display: flex;
}
#game-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}

/* ── AI Wealth Coach full-bleed ── */
#page-ai {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
#page-ai.active {
  display: flex;
}
#ai-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}

/* ── Mentor AI full-bleed ── */
#page-mentor {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
#page-mentor.active {
  display: flex;
}
#mentor-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}

/* ── Full-bleed iframe pages (academy, gpd, mentor, game, quiz, kepsekai) ── */
#page-academy,
#page-gpd {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
#page-academy.active,
#page-gpd.active {
  display: flex;
}

#academy-frame,
#gpd-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}

#page-kepsekai {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
#page-kepsekai.active {
  display: flex;
}

#kepsekai-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}

/* ── MitraCloud library pages ───────────────────── */
#page-library,
#page-mitra,
#page-mitraadmin {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}

#page-library.active,
#page-mitra.active,
#page-mitraadmin.active {
  display: flex;
}

#library-frame,
#mitra-frame,
#mitraadmin-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}

/* ── Iframe top bar (shared by academy + future full-bleed pages) ── */
.iframe-topbar {
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(6,13,31,0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  gap: 12px;
}

.iframe-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.iframe-topbar-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.iframe-topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.iframe-topbar-sub {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iframe-topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--t-fast);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: 'Outfit', sans-serif;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-btn:hover {
  color: var(--text);
  border-color: var(--border-2);
  background: var(--surface);
}
.topbar-btn-accent {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: rgba(0,240,200,0.06);
}
.topbar-btn-accent:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════════════════ SIDEBAR OVERLAY ══════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sidebar-overlay.show { display: block; }

/* ═══════════════════ BOTTOM NAV (MOBILE) ══════════════════ */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--btmnav-h);
  background: rgba(6,13,31,0.95);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  align-items: center;
  justify-content: space-around;
}
/* Hidden on desktop, shown on mobile via mobile.css */
@media (min-width: 701px) {
  #bottom-nav { display: none !important; }
}

.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--t-fast);
  min-width: 52px;
  position: relative;
}
.bn-item:active { transform: scale(0.94); }

.bn-icon {
  font-size: 20px;
  line-height: 1;
  transition: transform var(--t-fast);
}
.bn-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
  transition: color var(--t-fast);
}

.bn-item.active .bn-label { color: var(--accent); }
.bn-item.active .bn-icon  { transform: scale(1.15); }

/* Active pill indicator */
.bn-item::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--grad-accent);
  border-radius: 2px;
  transition: width var(--t-normal);
}
.bn-item.active::after { width: 24px; }

/* ═══════════════════ TABLE ════════════════════════════════ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table th {
  text-align: left;
  color: var(--text-2);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.table tr:hover td { background: var(--surface); }

.status-paid    { color: var(--success); font-weight: 500; }
.status-pending { color: var(--warn); font-weight: 500; }
/* FIX iframe full screen */
iframe {
  width: 100%;
  border: none;
}

/* ── Content Creator full-bleed ── */
#page-content {
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
#page-content.active {
  display: flex;
}
#content-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: block;
}
/* ── Bottom Navigation ───────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 55px;
  background: rgba(10, 15, 30, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 999;
}

.bottom-nav .nav-item {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: #aaa;
  cursor: pointer;
}

.bottom-nav .nav-item.active {
  color: #00f0ff;
}

.bottom-nav .nav-item span {
  display: block;
  font-size: 11px;
}
