/* Base Styles and Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #667eea;
  --primary-dark: #5a67d8;
  --secondary-color: #718096;
  --success-color: #48bb78;
  --warning-color: #f6ad55;
  --danger-color: #f56565;
  --info-color: #4299e1;

  --bg-primary: #ffffff;
  --bg-secondary: #f7fafc;
  --bg-tertiary: #edf2f7;

  --text-primary: #2d3748;
  --text-secondary: #4a5568;
  --text-tertiary: #718096;

  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  --sidebar-width: 260px;
  --sidebar-collapsed-width: 80px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #00146d 0%, #1f1f1f 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-header h2 {
  opacity: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
  min-width: 32px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  opacity: 1;
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: white;
  transition: all 0.3s;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.2s;
  position: relative;
  min-height: 48px;
  font-size: 15px;
}

.nav-item:hover,
.nav-item:active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: white;
}

.nav-icon {
  width: 22px;
  height: 22px;
  margin-right: 12px;
  flex-shrink: 0;
}

.sidebar.collapsed .nav-item span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}

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

.sidebar.collapsed .user-details {
  display: none;
}

.user-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  opacity: 0.8;
  text-transform: capitalize;
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s;
  min-height: 48px;
}

.logout-btn:hover,
.logout-btn:active {
  background: rgba(255, 255, 255, 0.1);
}

.logout-btn .nav-icon {
  margin-right: 8px;
}

.sidebar.collapsed .logout-btn span {
  display: none;
}

.sidebar.collapsed .logout-btn .nav-icon {
  margin-right: 0;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
  min-width: 0;
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.content-wrapper {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Flash Messages */
.flash-messages {
  margin-bottom: 20px;
}

.alert {
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.3s ease;
}

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

.alert-success {
  background-color: #c6f6d5;
  color: #22543d;
  border: 1px solid #68d391;
}

.alert-danger {
  background-color: #fed7d7;
  color: #742a2a;
  border: 1px solid #fc8181;
}

.alert-warning {
  background-color: #feebc8;
  color: #744210;
  border: 1px solid #f6ad55;
}

.alert-info {
  background-color: #bee3f8;
  color: #2c5282;
  border: 1px solid #63b3ed;
}

.alert-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  padding: 4px 8px;
  margin-left: 12px;
  min-width: 32px;
  min-height: 32px;
}

.alert-close:hover,
.alert-close:active {
  opacity: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: rgb(0, 0, 100);
  color: white;
}

.btn-primary:hover,
.btn-primary:active {
  background: rgb(0, 0, 100);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover,
.btn-secondary:active {
  background: var(--bg-secondary);
  border-color: var(--secondary-color);
}

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

.btn-danger:hover,
.btn-danger:active {
  background: #e53e3e;
}

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

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 100px;
}

.stat-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 28px;
  height: 28px;
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Dashboard Content */
.dashboard-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.dashboard-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.dashboard-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.quick-actions {
  display: grid;
  gap: 10px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s;
  min-height: 56px;
  font-size: 15px;
}

.action-btn:active {
  background: var(--bg-tertiary);
  transform: translateX(4px);
}

.action-btn svg {
  width: 22px;
  height: 22px;
  color: var(--primary-color);
  flex-shrink: 0;
}

/* Activity List */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon svg {
  width: 18px;
  height: 18px;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: 14px;
  color: var(--text-primary);
}

.activity-time {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-header h2,
  .nav-item span,
  .user-details,
  .logout-btn span {
    display: none;
  }

  .sidebar.mobile-open .sidebar-header h2,
  .sidebar.mobile-open .nav-item span,
  .sidebar.mobile-open .user-details,
  .sidebar.mobile-open .logout-btn span {
    display: block;
  }

  .sidebar.mobile-open {
    width: var(--sidebar-width);
  }

  .nav-icon {
    margin-right: 0;
  }

  .sidebar.mobile-open .nav-icon {
    margin-right: 12px;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .content-wrapper {
    padding: 16px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 20px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .header-actions {
    width: 100%;
  }

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

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .dashboard-content {
    grid-template-columns: 1fr;
    gap: 16px;
  }

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

  /* Mobile overlay for sidebar */
  .sidebar.mobile-open::before {
    content: "";
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--sidebar-width);
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
  }
}

/* Tablet Responsive */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar-header h2,
  .nav-item span,
  .user-details,
  .logout-btn span {
    display: none;
  }

  .nav-icon {
    margin-right: 0;
  }

  .main-content {
    margin-left: var(--sidebar-collapsed-width);
  }

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

/* Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  width: 48px;
  height: 48px;
  background: var(--primary-color);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn span {
  display: block;
  width: 24px;
  height: 3px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-menu-btn:active {
  transform: scale(0.95);
}

.sidebar.mobile-open ~ .mobile-menu-btn span:nth-child(1) {
  transform: rotate(45deg) translate(7px, 7px);
}

.sidebar.mobile-open ~ .mobile-menu-btn span:nth-child(2) {
  opacity: 0;
}

.sidebar.mobile-open ~ .mobile-menu-btn span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

/* Show mobile menu button only on mobile */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }

  /* Add padding to content so menu button doesn't cover anything */
  .content-wrapper {
    padding-top: 72px;
  }
}

/* Touch-friendly scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}
