/* ============================================================
   layout.css - Layout principal, sidebar, navbar (~160 lin)
   Mobile-first: sidebar hidden por defecto en mobile
   ============================================================ */

.app-layout { display: flex; min-height: 100vh; position: relative; }

/* === Sidebar === */
.app-sidebar {
  width: 260px;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.app-sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 45;
  opacity: 0; transition: opacity 0.3s;
}
.sidebar-overlay.open { display: block; opacity: 1; }

.sidebar-logo {
  padding: 16px 20px; display: flex;
  align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo img { height: 32px; }

.sidebar-close {
  background: none; border: none; color: rgba(255,255,255,0.6);
  font-size: 1.2rem; cursor: pointer; padding: 4px;
  display: block;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; -webkit-overflow-scrolling: touch; }
.nav-section { padding: 2px 8px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
  color: rgba(255,255,255,0.7); font-size: 0.85rem;
  font-weight: 500; cursor: pointer;
  transition: all 0.15s; user-select: none;
  min-height: 42px; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active {
  background: rgba(147,193,31,0.18); color: var(--brand-accent);
  font-weight: 600;
}
.nav-item i { width: 20px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }

.nav-children { padding-left: 14px; overflow: hidden; max-height: 0; transition: max-height 0.4s ease; }
.nav-children.open { max-height: 800px; }
.nav-toggle { margin-left: auto; font-size: 0.65rem; transition: transform 0.2s; }
.nav-toggle.open { transform: rotate(90deg); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; }
.sidebar-user-role { font-size: 0.7rem; opacity: 0.6; }
.btn-logout {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
  background: none; color: rgba(255,255,255,0.7); font-size: 0.8rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; transition: all 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* === Main area === */
.app-main { flex: 1; display: flex; flex-direction: column; min-height: 100vh; width: 100%; }

.app-navbar {
  height: 56px; background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
  display: flex; align-items: center; padding: 0 16px;
  position: sticky; top: 0; z-index: 30; gap: 12px;
}
.navbar-title { font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mobile-toggle {
  background: none; border: none; font-size: 1.2rem;
  color: var(--brand-text); cursor: pointer; padding: 8px;
  min-width: 40px; min-height: 40px; display: flex;
  align-items: center; justify-content: center; border-radius: 8px;
  flex-shrink: 0;
}
.mobile-toggle:active { background: var(--brand-border); }

.navbar-user {
  display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0;
}
.navbar-user-text { text-align: right; display: none; }
.user-name { font-size: 0.8rem; font-weight: 600; }
.user-role { font-size: 0.65rem; color: var(--brand-text-muted); }

.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.user-avatar.sm { width: 30px; height: 30px; font-size: 0.65rem; }

.app-content { flex: 1; padding: 16px; }

/* === Module tab strip (sub-nav horizontal) === */
.module-tabs {
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
  position: sticky;
  top: 56px;
  z-index: 25;
  overflow: hidden;
}
.module-tabs-inner {
  display: flex;
  gap: .15rem;
  padding: .35rem .75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.module-tabs-inner::-webkit-scrollbar { display: none; }

.module-tab {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .75rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--brand-text-muted);
  font-size: .76rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}
.module-tab i {
  font-size: .7rem;
  width: 16px;
  text-align: center;
}
.module-tab:hover {
  background: var(--brand-bg);
  color: var(--brand-text);
}
.module-tab--active {
  background: var(--brand-accent);
  color: var(--brand-primary);
  font-weight: 700;
}
.module-tab--active:hover {
  background: var(--brand-accent);
  color: var(--brand-primary);
}

/* === Desktop (>768px) === */
@media (min-width: 769px) {
  .app-sidebar { transform: translateX(0); }
  .sidebar-overlay { display: none !important; }
  .sidebar-close { display: none; }
  .app-main { margin-left: 260px; }
  .mobile-toggle { display: none; }
  .navbar-user-text { display: block; }
  .app-navbar { padding: 0 24px; height: 60px; }
  .module-tabs { top: 60px; }
  .module-tabs-inner { padding: .35rem 1rem; }
  .module-tab { padding: .5rem .85rem; font-size: .78rem; }
  .app-content { padding: 24px; }
  .navbar-title { font-size: 1.1rem; }
}
