/* Univista Dashboard v2 — Shell Layout (Sprint 2 MVP)
 * Desktop: sidebar 64px + topbar + main
 * Mobile (<768px): topbar + main + bottom-tab 5 icon, sidebar ẩn hamburger
 */

.uv-shell {
  display: grid;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  grid-template-columns: 96px 1fr;
  grid-template-rows: 48px 1fr;
  min-height: 100vh;
}

/* === TOPBAR === */
.uv-topbar {
  grid-area: topbar;
  background: var(--uv-charcoal);
  color: var(--uv-white);
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.uv-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.uv-hamburger {
  background: none;
  border: none;
  color: var(--uv-white);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  display: none; /* chỉ hiện mobile */
}
.uv-logo {
  font-weight: 700;
  font-size: 16px;
  color: var(--uv-gold);
  text-decoration: none;
  letter-spacing: 0.5px;
}
.uv-logo:hover { text-decoration: none; opacity: 0.9; }

.uv-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--uv-gray-400);
  overflow: hidden;
  white-space: nowrap;
}
.uv-breadcrumb a {
  color: var(--uv-gray-400);
  text-decoration: none;
}
.uv-breadcrumb a:hover { color: var(--uv-white); }
.uv-crumb-sep { color: var(--uv-gray-600); }
.uv-crumb-current { color: var(--uv-white); font-weight: 500; }

.uv-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.uv-user-name { color: var(--uv-gray-400); }
.uv-logout {
  color: var(--uv-white);
  text-decoration: none;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
}
.uv-logout:hover { background: rgba(255,255,255,0.1); text-decoration: none; }


/* === SIDEBAR — TEXT-ONLY MINIMALIST PREMIUM === */
.uv-sidebar {
  grid-area: sidebar;
  background: linear-gradient(180deg, #1C1C2E 0%, #1A2138 100%);
  border-right: none;
  overflow-y: auto;
  padding: 12px 0 60px;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  scrollbar-width: thin;
}
.uv-sidebar::-webkit-scrollbar { width: 4px; }
.uv-sidebar::-webkit-scrollbar-track { background: transparent; }
.uv-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
.uv-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.uv-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; }

.uv-nav-item {
  display: block;
  text-align: center;
  padding: 12px 6px;
  margin: 0;
  text-decoration: none;
  color: rgba(255,255,255,0.95);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.3;
  border-radius: 8px;
  position: relative;
  transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
  word-wrap: break-word;
  hyphens: none;
}
.uv-nav-item:hover {
  background: rgba(249,194,20,0.15);
  text-decoration: none;
  color: #F9C214;
  transform: translateX(2px);
}
.uv-nav-item.is-active {
  background: linear-gradient(135deg, rgba(249,194,20,0.22) 0%, rgba(154,120,32,0.14) 100%);
  color: #F9C214;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(249,194,20,0.3);
}
.uv-nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: linear-gradient(180deg, #F9C214, #9A7820);
  border-radius: 0 3px 3px 0;
}
.uv-nav-item.is-coming { opacity: 0.4; cursor: not-allowed; }
.uv-nav-item.is-coming:hover { transform: none; background: transparent; color: rgba(255,255,255,0.55); }

.uv-nav-icon { display: none; }

.uv-nav-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  white-space: normal;
  text-align: center;
  width: 100%;
}

.uv-nav-badge {
  position: absolute; top: 4px; right: 4px;
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  color: #FFF;
  font-size: 7.5px;
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(220,38,38,0.4);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  z-index: 3;
}

@media (max-width: 767px) {
  .uv-sidebar { background: linear-gradient(180deg, #1C1C2E 0%, #1A2138 100%); }
  .uv-nav-item {
    text-align: left;
    padding: 14px 18px;
    border-radius: 8px;
    margin: 1px 8px;
    font-size: 14px;
  }
  .uv-nav-label { text-align: left; font-size: 14px; }
}


/* === MAIN === */
.uv-main {
  grid-area: main;
  overflow-y: auto;
  padding: 16px;
  max-width: 1200px;
  width: 100%;
}

/* === BOTTOM TAB (mobile only) === */
.uv-bottom-tab {
  display: none;
}


/* === MOBILE (<768px) === */
@media (max-width: 767px) {
  .uv-shell {
    grid-template-areas:
      "topbar"
      "main"
      "bottomtab";
    grid-template-columns: 1fr;
    grid-template-rows: 48px 1fr 56px;
  }

  .uv-hamburger { display: block; }

  .uv-breadcrumb { display: none; }

  .uv-sidebar {
    position: fixed;
    top: 48px;
    left: -240px;
    width: 240px;
    height: calc(100vh - 48px);
    z-index: 40;
    transition: left 0.2s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  }
  .uv-sidebar.is-open { left: 0; }

  .uv-nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 16px;
    font-size: 14px;
    border-left: none;
    border-bottom: 1px solid var(--uv-gray-200);
  }
  .uv-nav-item.is-active {
    background: var(--uv-gray-50);
    border-left: 3px solid var(--uv-gold);
  }
  .uv-nav-icon { font-size: 20px; }
  .uv-nav-label { text-align: left; font-size: 14px; }

  .uv-main {
    padding: 12px;
    padding-bottom: 70px; /* chừa cho bottom tab */
  }

  .uv-user-name { display: none; }

  /* Bottom tab mobile */
  .uv-bottom-tab {
    grid-area: bottomtab;
    display: flex;
    background: var(--uv-white);
    border-top: 1px solid var(--uv-gray-200);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    height: 56px;
  }
  .uv-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--uv-gray-600);
    font-size: 10px;
    padding: 6px 4px;
  }
  .uv-tab-item:hover { text-decoration: none; }
  .uv-tab-item.is-active { color: var(--uv-gold); font-weight: 600; }
  .uv-tab-item.is-coming { opacity: 0.5; }
  .uv-tab-icon { font-size: 20px; line-height: 1; }
  .uv-tab-label { line-height: 1.1; }
}

/* Desktop ≥768 hide bottom tab, show sidebar */
@media (min-width: 768px) {
  .uv-sidebar.is-open { left: 0; } /* no-op on desktop */
  .uv-bottom-tab { display: none !important; }
}

/* Overlay khi sidebar mở mobile */
.uv-shell::after {
  content: '';
  display: none;
}


/* === MOBILE REFINEMENT === */
@media (max-width: 767px) {
  .uv-logo { font-size: 15px; }
  .uv-topbar { padding: 0 12px; }
  .uv-topbar-right { gap: 8px; }
  .uv-logout {
    font-size: 20px;
    padding: 6px 10px;
    min-width: 44px; /* touch target */
    text-align: center;
  }
  .uv-hamburger {
    font-size: 22px;
    padding: 8px 10px;
    min-width: 44px;
  }

  /* Overlay khi sidebar mở mobile */
  .uv-sidebar.is-open::before {
    content: '';
    position: fixed;
    top: 48px;
    left: 240px;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: -1;
  }

  .uv-tab-item {
    min-height: 56px; /* bottom tab height */
    padding: 6px 2px;
  }
  .uv-tab-icon { font-size: 22px; }
  .uv-tab-label { font-size: 10px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* iPhone SE / small screen */
@media (max-width: 375px) {
  .uv-main { padding: 10px; padding-bottom: 70px; }
  .uv-tab-icon { font-size: 20px; }
  .uv-tab-label { font-size: 9px; }
}

/* Safe area cho iPhone notch */
@supports (padding: env(safe-area-inset-bottom)) {
  .uv-bottom-tab {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(56px + env(safe-area-inset-bottom));
  }
  .uv-main {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
}
