/* ================================================================
   EDUTRACK V5 — LAYOUT (App Shell, Topbar, Sidebar, Mobile Nav)
================================================================ */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .4s var(--ease-out), visibility .4s; z-index: 200;
}
.screen.is-active { opacity: 1; visibility: visible; }

.app-shell { display: flex; flex-direction: row; background: var(--c-bg); position: fixed; inset: 0; }

.sidebar {
  width: var(--sidebar-w); background: var(--c-surface); border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column; flex-shrink: 0; height: 100dvh; z-index: 150;
  transition: transform .35s var(--ease-out), background .3s;
}

.sidebar-top { flex: 1; padding: 24px 18px 16px; overflow-y: auto; }
.sb-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 32px; padding: 0 8px; }
.sb-logo { width: 40px; height: 40px; border-radius: 12px; background: var(--c-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.sb-name { font-weight: 800; font-size: 1.25rem; letter-spacing: -.4px; }

.sb-section-label { font-size: .75rem; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: .8px; margin: 12px 10px 8px; display: block; }
.sb-link {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: var(--radius-m);
  color: var(--c-muted); font-size: .95rem; font-weight: 600; transition: all var(--t); margin-bottom: 4px;
}
.sb-link i { width: 20px; text-align: center; font-size: 1.1rem; transition: color var(--t); }
.sb-link:hover { background: var(--c-surface-2); color: var(--c-text); }
.sb-link.is-active { background: var(--c-primary-l); color: var(--c-primary); }

/* Improved User Block & Action Buttons (Sidebar Bottom) */
.sidebar-bottom {
  padding: 20px 18px; border-top: 1px solid var(--c-border);
  display: flex; flex-direction: column; gap: 16px;
  background: var(--c-bg); /* Slight contrast from sidebar surface */
}
.user-block { display: flex; align-items: center; gap: 14px; padding: 4px; }
.sb-avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--c-primary);
  color: #fff; font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden; border: 1px solid var(--c-border);
}
.sb-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sb-user-info { flex: 1; min-width: 0; }
.sb-user-info strong { display: block; font-size: 0.95rem; font-weight: 700; line-height: 1.2; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-info small { color: var(--c-muted); font-size: .75rem; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.dot-online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c-ok); }

.action-grid { display: flex; align-items: stretch; gap: 10px; width: 100%; }
.action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 10px; border-radius: var(--radius-m);
  background: var(--c-surface-2); color: var(--c-muted);
  font-size: .9rem; font-weight: 700; transition: all var(--t);
  border: 1px solid var(--c-border); line-height: 1; height: 42px;
}
.action-btn i { font-size: 1.05rem; display: flex; align-items: center; }
.action-btn:hover { background: var(--c-surface-3); color: var(--c-text); border-color: var(--c-border-2); transform: translateY(-2px); }
.action-btn.danger:hover { background: var(--c-danger-l); color: var(--c-danger); border-color: var(--c-danger); }

/* Main wrap & Topbar */
.main-wrap { flex: 1; display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; background: var(--c-surface);
  border-bottom: 1px solid var(--c-border); gap: 16px; z-index: 100;
  padding-top: var(--safe-top); height: calc(var(--topbar-h) + var(--safe-top));
}
.tb-left { display: flex; align-items: center; gap: 16px; }
.tb-menu-btn { display: none; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--c-border); color: var(--c-muted); font-size: 1.1rem; align-items: center; justify-content: center; transition: all var(--t); }
.tb-title { font-size: 1.1rem; font-weight: 800; letter-spacing: -.2px; }

.tb-right { display: flex; align-items: center; gap: 16px; }
.tb-search-wrap {
  position: relative; display: flex; align-items: center; background: var(--c-surface-2);
  border: 1px solid var(--c-border); border-radius: var(--radius-l); padding: 0 16px; gap: 10px;
  transition: all var(--t); width: 300px;
}
.tb-search-wrap:focus-within { border-color: var(--c-primary); box-shadow: 0 0 0 4px var(--c-primary-l); background: var(--c-surface-3); width: 340px; }
.tb-search-wrap i { color: var(--c-muted); font-size: .95rem; flex-shrink: 0; }
.tb-search-wrap input { background: transparent; border: none; outline: none; color: var(--c-text); font-family: inherit; font-size: .95rem; width: 100%; padding: 12px 0; }
.tb-clear-search { color: var(--c-muted); font-size: .9rem; cursor: pointer; }
.tb-date { font-size: .88rem; font-weight: 600; color: var(--c-muted); white-space: nowrap; }

.tb-user { display: none; align-items: center; gap: 12px; }
.tb-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--c-primary); color: #fff; font-size: .9rem; font-weight: 800; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tb-theme-btn { background: transparent; border: none; font-size: 1.15rem; color: var(--c-muted); cursor: pointer; padding: 4px; display: flex; align-items: center; }
.tb-ai-btn { background: var(--c-primary-l); color: var(--c-primary); width: 34px; height: 34px; border-radius: 10px; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; }
.tb-logout-btn { background: transparent; border: none; font-size: 1.1rem; color: var(--c-danger); cursor: pointer; padding: 4px; display: flex; align-items: center; margin-left: 4px; }

.more-menu { display: none; }

.views-container { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; padding: 32px; display: flex; flex-direction: column; }
.view { display: none; flex-direction: column; gap: 28px; }
.view.is-active { display: flex; animation: fadeUp .45s var(--ease-out) both; }

/* ─── BOTTOM NAV (NATIVE APP MOBILE UX) ─── */
.bottom-nav {
  display: none;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding-bottom: var(--safe-bottom);
  padding-top: 8px;
  z-index: 180;
  position: fixed; bottom: 0; left: 0; right: 0;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.03);
}

.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 12px 0 10px; color: var(--c-muted); font-size: 0.62rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .5px; transition: color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.bn-item i { font-size: 1.25rem; transition: transform var(--t); opacity: 0.6; }
.bn-item.is-active { color: var(--c-primary); }
.bn-item.is-active i { transform: translateY(-2px); color: var(--c-primary); opacity: 1; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 140; }

/* ─── RESPONSIVE / APP MOBILE OVERRIDES ─── */
@media (max-width: 1100px) {
  .tb-search-wrap { width: 220px; } .tb-search-wrap:focus-within { width: 260px; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .tb-menu-btn { display: none; }
  .bottom-nav { display: flex; } /* Show App Bottom Bar */
  
  .topbar { 
    padding: 0 16px; 
    border-bottom: 1px solid var(--c-border); 
    background: var(--c-surface); 
    padding-top: var(--safe-top); 
    height: calc(52px + var(--safe-top)); 
  }
  .views-container { padding: 12px 14px calc(var(--bottom-h) + var(--safe-bottom) + 8px); }
  
  .tb-search-wrap { display: none; }
  .tb-date { display: none; }
  .tb-title { font-size: 1.1rem; font-weight: 900; }
  .tb-menu-btn { width: 34px; height: 34px; border-radius: 8px; }
  .tb-user { display: flex; gap: 8px; }
  .tb-avatar { width: 30px; height: 30px; }
  .tb-ai-btn { width: 32px; height: 32px; font-size: 1rem; }
  .ai-fab { display: none !important; }
  
  .bottom-nav { 
    height: calc(72px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    border-top: 1px solid var(--c-border);
    padding-top: 4px;
  }

  /* More Menu Overlay */
  .more-menu {
    display: block;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--c-surface);
    border-top-left-radius: 24px; border-top-right-radius: 24px;
    z-index: 1000; padding: 24px 20px calc(24px + var(--safe-bottom));
    transform: translateY(100%); transition: transform 0.4s var(--ease-spring);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
  }
  .more-menu.is-active { transform: translateY(0); }
  
  .more-menu-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding: 0 4px; }
  .more-menu-header h3 { font-size: 1.1rem; font-weight: 800; }
  .more-menu-header button { font-size: 1.2rem; color: var(--c-muted); }

  .more-menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .mm-item {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px 8px; border-radius: 16px; background: var(--c-surface-2);
    color: var(--c-text); font-size: 0.78rem; font-weight: 700; transition: background var(--t);
  }
  .mm-item i { font-size: 1.4rem; color: var(--c-primary); }
  .mm-item:active { background: var(--c-surface-3); }
}

/* ─── MARCO LA VALLE MODE (MEME) ─── */
body.marco-mode {
    animation: chaoticShake 0.1s infinite alternate;
    overflow-x: hidden;
}

body.marco-mode * {
    transition: all 0.05s ease-in-out !important;
}

@keyframes chaoticShake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

#marco-mode-btn.is-active {
    color: #ff00ff !important;
    background: rgba(255, 0, 255, 0.2) !important;
    animation: flash 0.5s infinite alternate;
}

@keyframes flash {
    from { opacity: 0.5; }
    to { opacity: 1; }
}
