/* SGB Agro App Layout (SPA Shell) - High Density Compact Enterprise Layout */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Compact Sidebar - Coordinated Brand Palette with Lush Leaves Graphic */
.app-sidebar {
  width: 218px;
  background-color: #043326;
  background-image: url('../assets/images/banners/sidebar_leaves_bg.png');
  background-position: left bottom;
  background-size: cover;
  background-repeat: no-repeat;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: transform var(--transition-normal);
}

.sidebar-brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
}

.brand-badge-logo {
  width: 26px;
  height: 26px;
  background: #059669;
  color: #ffffff;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.brand-badge-logo svg {
  width: 15px;
  height: 15px;
}

.brand-title-wrap h2 {
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
}

.brand-title-wrap span {
  font-size: 0.6rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #a7f3d0;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.6rem 0.45rem;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.575rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #6ee7b7;
  padding: 0.45rem 0.5rem 0.2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-xs);
  color: #d1fae5;
  font-size: 0.785rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  margin-bottom: 0.15rem;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-item span {
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  text-decoration: none;
}

.nav-item.active {
  background: #059669;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-footer span {
  font-size: 0.725rem;
  color: #a7f3d0 !important;
  font-weight: 500;
}

.sidebar-footer .btn-danger {
  background: rgba(220, 38, 38, 0.22);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
  padding: 0.2rem 0.5rem;
  font-size: 0.725rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-footer .btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

/* Main Content Area */
.app-content {
  margin-left: 218px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f4f7f6;
  min-height: 100vh;
}

/* Top App Bar with Nature Panoramic Sunrise Banner */
.app-header {
  height: 72px;
  background-color: #f0fdf4;
  background-image: url('../assets/images/banners/banner_fields_sunrise.png');
  background-position: right center;
  background-size: cover;
  background-repeat: no-repeat;
  border-bottom: 1px solid rgba(5, 150, 105, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header-brand-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(5, 150, 105, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #064e3b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #064e3b;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}

.page-subtitle {
  font-size: 0.775rem;
  color: #475569;
  font-weight: 500;
  margin-top: 2px;
  line-height: 1.2;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Live Auto-Sync Status Pill Indicator */
.live-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(5, 150, 105, 0.35);
  border-radius: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  cursor: default;
  user-select: none;
  transition: all 0.2s ease;
}

.live-sync-pill:hover {
  background: #ffffff;
  border-color: #059669;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.18);
}

.live-sync-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: livePulse 2s infinite;
  flex-shrink: 0;
}

.live-sync-pill.offline .live-sync-indicator-dot {
  background-color: #ef4444;
  box-shadow: none;
  animation: none;
}

.live-sync-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: #065f46;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.live-sync-pill.offline .live-sync-label {
  color: #991b1b;
}

@keyframes livePulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Glass-Morphism Header Controls matching Mockup */
.header-glass-btn {
  background: rgba(4, 51, 38, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.9rem;
  font-size: 0.775rem;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.header-glass-btn:hover {
  background: rgba(4, 51, 38, 0.65);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
}

.header-glass-icon-btn {
  background: rgba(4, 51, 38, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.header-glass-icon-btn:hover {
  background: rgba(4, 51, 38, 0.65);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
}

.header-notify-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  border: 1.5px solid #043326;
}

/* Interactive User Menu Wrapper */
.user-menu-wrapper {
  position: relative;
  display: inline-block;
}

.header-glass-user,
.user-pill.header-glass-user {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.75rem 0.25rem 0.35rem;
  background: #ffffff !important;
  border: 1px solid rgba(226, 232, 240, 0.9) !important;
  border-radius: 24px;
  color: #0f172a !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-pill.header-glass-user:hover {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
  transform: translateY(-1px);
}

.user-pill.header-glass-user.active {
  background: #f1f5f9 !important;
  border-color: #059669 !important;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15) !important;
}

.user-pill.header-glass-user.active #headerUserChevron {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  z-index: 1050;
  transform-origin: top right;
  animation: dropdownFade 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 0.4rem;
}

.user-dropdown-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #059669;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
  flex-shrink: 0;
}

.user-dropdown-meta {
  flex: 1;
  min-width: 0;
}

.user-dropdown-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.user-dropdown-email {
  font-size: 0.72rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin-top: 1px;
}

.user-dropdown-role-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  color: #059669;
  background: #d1fae5;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 4px;
}

.user-dropdown-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 0.35rem 0;
}

.user-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.user-dropdown-item svg {
  color: #64748b;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.user-dropdown-item:hover {
  background: #f0fdf4;
  color: #059669;
}

.user-dropdown-item:hover svg {
  color: #059669;
}

.user-dropdown-item.danger {
  color: #dc2626;
}

.user-dropdown-item.danger svg {
  color: #dc2626;
}

.user-dropdown-item.danger:hover {
  background: #fef2f2;
  color: #b91c1c;
}

.user-dropdown-item.danger:hover svg {
  color: #b91c1c;
}

/* Profile Modal Tabs & Layout */
.profile-nav-tabs {
  display: flex;
  gap: 0.35rem;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.profile-tab-btn {
  flex: 1;
  padding: 0.45rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.profile-tab-btn.active {
  background: #ffffff;
  color: #059669;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-tab-pane {
  display: none;
}

.profile-tab-pane.active {
  display: block;
}

.permission-role-banner {
  background: linear-gradient(135deg, #043326 0%, #064e3b 100%);
  color: #ffffff;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.permission-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.65rem;
  background: #ffffff;
}

.permission-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.4rem;
}

.permission-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: #475569;
}

.permission-check {
  color: #059669;
  font-weight: 800;
  font-size: 0.85rem;
}

.header-glass-user .user-avatar-circle {
  width: 28px;
  height: 28px;
  background: #059669;
  color: #ffffff;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
}

.header-glass-user .user-info-text {
  display: flex;
  flex-direction: column;
}

.header-glass-user .user-info-text p:first-child,
#headerUserName {
  color: #0f172a !important;
  font-weight: 700 !important;
  font-size: 0.82rem;
  line-height: 1.1;
}

.header-glass-user .user-role-tag,
#headerUserRole {
  color: #059669 !important;
  font-weight: 800 !important;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
  margin-top: 2px;
}

.header-glass-user svg {
  color: #64748b !important;
  stroke: #64748b !important;
  opacity: 0.85;
}

.app-page {
  flex: 1;
  padding: 1rem 1.25rem;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}

/* Top-Level Authentication Screen Toggles */
#loginViewSection {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0fdf4 0%, #f8fafc 50%, #eff6ff 100%);
  padding: 1.5rem;
}

#loginViewSection.hidden {
  display: none !important;
}

#appShellSection {
  display: flex;
  min-height: 100vh;
}

#appShellSection.hidden {
  display: none !important;
}

/* View Section Toggle */
.view-panel {
  display: none !important;
  animation: fadeIn 0.15s ease-in-out;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   PAGE 5: PROFILE & SECURITY (3-IN-1 SCREEN) STYLES
   ========================================================================== */
.profile-hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border: 1.5px solid #d1fae5;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.05);
  flex-wrap: wrap;
}

.profile-hero-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

#heroUserAvatar,
.user-profile-hero-avatar {
  width: 76px !important;
  height: 76px !important;
  min-width: 76px !important;
  min-height: 76px !important;
  max-width: 76px !important;
  max-height: 76px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  background: #059669;
  color: #ffffff;
  font-size: 1.75rem !important;
  font-weight: 800;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.25);
  border: 3px solid #ffffff !important;
  flex: 0 0 76px !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  position: relative !important;
  overflow: visible !important;
  user-select: none;
}

.profile-hero-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.profile-hero-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.profile-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #059669;
  background: #ecfdf5;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid #a7f3d0;
}

.profile-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.profile-hero-details {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.775rem;
  color: #64748b;
  flex-wrap: wrap;
}

.profile-hero-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.profile-sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
}

.profile-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.profile-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #f1f5f9;
}

.profile-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.profile-card-icon.green {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.profile-card-icon.blue {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
}

.profile-card-icon.purple {
  background: #ede9fe;
  border: 1px solid #ddd6fe;
}

.profile-card-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.profile-card-subtitle {
  font-size: 0.725rem;
  color: #64748b;
  margin: 2px 0 0 0;
}

.profile-permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
}
