/* MedSense - shadcn/ui Layout & Responsive Architecture */

.app-viewport {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px 16px;
  background-color: hsl(var(--background));
  background-image: 
    radial-gradient(hsl(var(--muted-foreground) / 0.12) 1px, transparent 1px);
  background-size: 28px 28px;
}

@media (max-width: 640px) {
  .app-viewport {
    padding: 0;
    background-image: none;
    align-items: stretch;
  }
}

/* Modern FarsiUI Application Shell Container */
.device-container {
  width: 100%;
  max-width: 980px;
  height: 94vh;
  max-height: 960px;
  min-height: 700px;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  border-radius: calc(var(--radius) * 1.5);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  box-shadow: 
    0 0 0 1px hsl(var(--border) / 0.6),
    0 24px 48px -12px rgba(0, 0, 0, 0.45);
}

@media (max-width: 640px) {
  .device-container {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
}

/* Hidden fake notch and status bar for clean authentic look */
.device-notch,
.status-bar {
  display: none !important;
}

/* shadcn/ui App Navbar Header */
.app-header {
  height: 60px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid hsl(var(--border));
  z-index: 50;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.brand-icon-wrapper {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.brand-icon-wrapper svg {
  width: 22px;
  height: 22px;
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  color: hsl(var(--foreground));
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.brand-text span {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Header Profile Pill (shadcn Avatar) */
.header-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  background-color: hsl(var(--secondary) / 0.6);
  border: 1px solid hsl(var(--border));
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: hsl(var(--foreground));
}

.header-profile-btn:hover {
  background-color: hsl(var(--secondary));
  border-color: hsl(var(--ring) / 0.3);
}

.avatar-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-summary-text {
  font-size: 12px;
  font-weight: 600;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.header-logout-btn:hover {
  background-color: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  border-color: hsl(var(--destructive) / 0.3);
}

/* Scrollable Main Content Area */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  scroll-behavior: smooth;
  position: relative;
}

@media (max-width: 640px) {
  .app-content {
    padding: 16px 14px 24px 14px;
  }
}

.app-content::-webkit-scrollbar {
  width: 5px;
}
.app-content::-webkit-scrollbar-track {
  background: transparent;
}
.app-content::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 9999px;
}
.app-content::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

.view-panel {
  display: none;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-panel.active {
  display: block;
}

/* shadcn/ui Segmented Bottom Navigation */
.bottom-nav {
  height: 62px;
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 12px;
  z-index: 50;
  flex-shrink: 0;
}

.nav-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 48px;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.15s ease;
  position: relative;
  border-radius: var(--radius);
  max-width: 140px;
}

.nav-item:hover {
  color: hsl(var(--foreground));
  background-color: hsl(var(--accent) / 0.5);
}

.nav-item-icon {
  font-size: 17px;
  line-height: 1;
}

.nav-item-label {
  font-size: 11px;
  font-weight: 500;
  transition: font-weight 0.15s ease;
}

.nav-item.active {
  color: hsl(var(--foreground));
  background-color: hsl(var(--secondary));
}

.nav-item.active .nav-item-label {
  font-weight: 700;
}

.nav-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 8px);
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 9999px;
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Authentication Out-of-Session Hide */
body.is-logged-out .app-header,
body.is-logged-out .bottom-nav {
  display: none !important;
}

body.is-logged-out .app-content {
  padding: 0;
}
