/**
 * Layout Architecture: Header, Live Tracker Bar, Sidebar, Filter Bar, Views Container
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  height: 100vh;
  display: flex;
}

/* App Wrapper */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Navigation */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
}

.sidebar-header {
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-badge {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--brand-500), #1e40af);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-info span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-3) var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.55rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-surface-active);
  color: #ffffff;
  border-color: var(--border-medium);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item.active svg {
  opacity: 1;
  color: var(--brand-500);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--brand-500);
  color: #ffffff;
}

.nav-badge.danger {
  background: var(--rose-500);
}

/* Sidebar Footer / User Profile */
.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--brand-500);
}

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

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
}

/* Main Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

/* Top Header Bar */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-shrink: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.view-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Live Attendance / Tracker Widget in Header */
.header-tracker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  padding: 4px 10px;
  border-radius: var(--radius-lg);
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.status-indicator-dot.active {
  background: var(--emerald-500);
  box-shadow: 0 0 8px var(--emerald-500);
}

.status-indicator-dot.break {
  background: var(--amber-500);
  box-shadow: 0 0 8px var(--amber-500);
}

.status-indicator-dot.idle {
  background: var(--sky-500);
}

.status-indicator-dot.offline {
  background: var(--text-muted);
}

.tracker-time {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Role Simulator Dropdown */
.role-switcher-container {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-md);
}

.role-switcher-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--brand-500);
}

.role-switcher-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.role-switcher-select option {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

/* Global Multi-Level Filter Bar */
.app-filter-bar {
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-2) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  overflow-x: auto;
  flex-shrink: 0;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.filter-select, .filter-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--border-focus);
}

.filter-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Main Viewport Container */
.app-viewport {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  position: relative;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .app-sidebar {
    width: 72px;
  }
  .brand-info, .nav-item span, .nav-section-title, .user-meta {
    display: none;
  }
  .sidebar-header {
    justify-content: center;
    padding: var(--space-4) 0;
  }
  .nav-item {
    justify-content: center;
  }
}
