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

:root {
  --primary-color: #FF4500;
  --primary-hover: #E63D00;
  --accent-color: #FF6B35;
  --secondary-color: #6b7280;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --background: #F0F2F8;
  --card-background: #FFFFFF;
  --text-primary: #0A0F2C;
  --text-secondary: #4A5578;
  --border-color: #D8DCE8;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.12);
  --sidebar-width: 200px;
  --navbar-bg: #0A0F2C;
  --sidebar-bg: #0D1433;
  --sidebar-text: #8892B0;
  --sidebar-text-active: #FFFFFF;
  --sidebar-accent: #FF4500;
  --sidebar-hover: #1E2A4A;
}

/* Dark Theme */
body.dark-theme {
  --background: #060A1A;
  --card-background: #0D1433;
  --text-primary: #F0F2F8;
  --text-secondary: #8892B0;
  --border-color: #1E2A4A;
  --shadow: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.6);
  --navbar-bg: #060A1A;
  --sidebar-bg: #060A1A;
  --sidebar-hover: #0D1433;
}

body.dark-theme .form-group input,
body.dark-theme .form-group textarea,
body.dark-theme .form-group select,
body.dark-theme .filter-select {
  background: #0D1433;
  color: var(--text-primary);
  border-color: var(--border-color);
}

body.dark-theme .login-container {
  background: linear-gradient(135deg, #060A1A 0%, #0D1433 100%);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Pages */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0A0F2C 0%, #1a2456 100%);
}

.login-card {
  background: var(--card-background);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 10px;
  color: var(--primary-color);
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.demo-credentials {
  margin-top: 20px;
  padding: 15px;
  background: var(--background);
  border-radius: 8px;
  font-size: 14px;
}

.demo-credentials code {
  background: var(--card-background);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--primary-color);
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.3s ease;
  flex-shrink: 0;
  z-index: 50;
}

.sidebar.collapsed {
  width: 60px;
  padding: 20px 10px;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sidebar-brand {
  font-size: 14px;
  font-weight: 700;
  color: var(--sidebar-accent);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
  letter-spacing: 0.5px;
}

.sidebar-logo {
  display: none;
  font-size: 17px;
  font-weight: 800;
  color: var(--sidebar-accent);
}

.sidebar.collapsed .sidebar-brand {
  display: none;
}

.sidebar.collapsed .sidebar-logo {
  display: block;
}

.sidebar-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 12px 0;
  border-top: 1px solid #1E2A4A;
  border-bottom: 1px solid #1E2A4A;
}

.sidebar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  flex-shrink: 0;
}

.sidebar-profile-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--sidebar-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.sidebar-profile-role {
  font-size: 11px;
}

.sidebar.collapsed .sidebar-profile-name,
.sidebar.collapsed .sidebar-profile-role {
  display: none;
}

.sidebar-divider {
  border-top: 1px solid #1E2A4A;
  margin: 0 -4px;
}

.sidebar-theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar.collapsed .sidebar-theme-label {
  display: none;
}

.sidebar.collapsed .sidebar-theme {
  justify-content: center;
}

.theme-label {
  font-size: 13px;
  color: var(--sidebar-text);
  white-space: nowrap;
}

/* Toggle Switch */
.theme-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.theme-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #1E2A4A;
  border-radius: 22px;
  transition: 0.3s;
}

.theme-toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--sidebar-text);
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .theme-toggle-slider {
  background: var(--primary-color);
}

input:checked + .theme-toggle-slider:before {
  background: white;
  transform: translateX(18px);
}

.sidebar-collapse-btn {
  background: none;
  border: 1px solid #1E2A4A;
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 12px;
  align-self: flex-end;
  margin-top: auto;
  transition: transform 0.3s, background 0.2s;
}

.sidebar.collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
  align-self: center;
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

/* Main Area */
.main-area {
  flex: 1;
  overflow: auto;
  min-width: 0;
}

/* Navbar */
.navbar {
  background: var(--navbar-bg);
  padding: 12px 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  padding: 4px 8px;
  border-radius: 4px;
}

.navbar-menu-btn:hover {
  color: #FFFFFF;
  background: rgba(255,255,255,0.1);
}

.nav-brand {
  font-size: 17px;
  font-weight: 600;
  color: #FFFFFF;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Avatar */
.avatar-wrapper {
  position: relative;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s;
  border: 2px solid rgba(255,255,255,0.2);
}

.avatar:hover {
  opacity: 0.85;
  border-color: rgba(255,255,255,0.5);
}

.avatar-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--card-background);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
}

.avatar-dropdown.open {
  display: block;
}

.dropdown-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.dropdown-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.dropdown-user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dropdown-user-role {
  font-size: 11px;
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 0;
}

.dropdown-item {
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: var(--background);
}

.dropdown-item-danger {
  color: var(--danger-color);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-background);
  padding: 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  text-align: center;
  border-left: 3px solid var(--primary-color);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 6px;
  line-height: 1;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-color);
}

.tab-btn {
  padding: 10px 22px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: var(--primary-color);
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--card-background);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
}

/* My Tasks Toggle */
.btn-toggle {
  background: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-toggle.active,
.btn-toggle:hover {
  background: var(--primary-color);
  color: white;
}

/* List Container */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Cards */
.sprint-card, .task-card, .user-card {
  background: var(--card-background);
  padding: 18px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.sprint-card:hover, .task-card:hover, .user-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 10px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.card-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.card-description {
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-size: 14px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

/* Sprint Progress Bar */
.sprint-progress {
  margin-top: 10px;
}

.sprint-progress-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.progress-bar {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Due Date Badge */
.due-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.due-badge.overdue {
  background: #fee2e2;
  color: #991b1b;
}

.due-badge.due-soon {
  background: #fef3c7;
  color: #92400e;
}

.due-badge.on-track {
  background: #d1fae5;
  color: #065f46;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-superAdmin {
  background: rgba(255,69,0,0.15);
  color: #FF4500;
}

.badge-employee {
  background: rgba(10,15,44,0.12);
  color: var(--text-primary);
}

body.dark-theme .badge-employee {
  background: #1E2A4A;
  color: #8892B0;
}

.badge-planning {
  background: #fef3c7;
  color: #92400e;
}

.badge-active {
  background: #d1fae5;
  color: #065f46;
}

.badge-completed {
  background: #e5e7eb;
  color: #374151;
}

.badge-todo {
  background: #fee2e2;
  color: #991b1b;
}

.badge-doing {
  background: #fef3c7;
  color: #92400e;
}

.badge-done {
  background: #d1fae5;
  color: #065f46;
}

.badge-low {
  background: #e0e7ff;
  color: #4338ca;
}

.badge-medium {
  background: #fef3c7;
  color: #92400e;
}

.badge-high {
  background: #fee2e2;
  color: #991b1b;
}

/* Buttons */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255,69,0,0.3);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--card-background);
  color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255,69,0,0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card-background);
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.close-btn:hover {
  background: var(--background);
  color: var(--text-primary);
}

/* Cancel buttons in modal footers share .close-btn for JS but need btn styling */
.btn.close-btn {
  font-size: 14px;
  width: auto;
  height: auto;
  padding: 8px 16px;
  color: white;
}

.btn.close-btn:hover {
  background: #4b5563;
  color: white;
}

.modal form {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

/* Messages */
.error-message {
  color: var(--danger-color);
  font-size: 13px;
  margin-top: 10px;
  display: none;
}

.error-message.active {
  display: block;
}

.success-message {
  color: var(--success-color);
  font-size: 13px;
  margin-top: 10px;
  display: none;
}

.success-message.active {
  display: block;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

/* SuperAdmin Only Elements */
.superAdmin-only {
  display: none;
}

body.is-superAdmin .superAdmin-only {
  display: inline-flex;
}

body.is-superAdmin .tab-btn.superAdmin-only {
  display: block;
}

body.is-superAdmin .filter-select.superAdmin-only {
  display: block;
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--card-background);
  padding: 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.chart-card h3 {
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-full {
  grid-column: 1 / -1;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transition: left 0.3s ease;
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .navbar-menu-btn {
    display: flex;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .filters {
    flex-direction: column;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .card-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .card-actions {
    justify-content: stretch;
  }

  .card-actions .btn {
    flex: 1;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .navbar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .nav-user {
    width: 100%;
    justify-content: flex-end;
  }
}
