/* Modern CSS Design System: Sleek Dark Mode with Glassmorphic Elements */
:root {
  --bg: #0b0f19;
  --bg-gradient: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.08) 0%, rgba(20, 184, 166, 0.04) 40%, rgba(11, 15, 25, 1) 90%);
  --panel-bg: rgba(22, 29, 45, 0.6);
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-hover-border: rgba(16, 185, 129, 0.3);
  
  --primary: #10b981; /* Emerald */
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.3);
  
  --secondary: #14b8a6; /* Teal */
  --secondary-hover: #0d9488;
  
  --text: #f3f4f6; /* Slate 100 */
  --text-muted: #9ca3af; /* Slate 400 */
  --text-dark: #111827;
  
  --accent-blue: #3b82f6;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Base resets & typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-image: var(--bg-gradient);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #ffffff;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Initial loader screens */
.initial-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 20px;
  font-family: var(--font-heading);
  color: var(--text-muted);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(16, 185, 129, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* Sidebar navigation */
.sidebar {
  width: 280px;
  background: rgba(13, 18, 30, 0.96);
  border-right: 1px solid var(--panel-border);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  padding-left: 8px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  box-shadow: 0 0 15px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--text-dark);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(to right, #ffffff, #a7f3d0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  font-size: 0.95rem;
}

.nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.router-link-active {
  color: #ffffff;
  background: rgba(16, 185, 129, 0.15);
  border-left: 3px solid var(--primary);
  box-shadow: inset 5px 0 15px rgba(16, 185, 129, 0.05);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 20px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

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

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  margin-left: 280px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-navbar {
  height: 80px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(11, 15, 25, 0.92);
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.page-title-section h1 {
  font-size: 1.5rem;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.company-selector {
  background: rgba(22, 29, 45, 0.9);
  border: 1px solid var(--panel-border);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
}

.company-selector:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.btn-logout {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--accent-red);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: var(--transition-fast);
}

.btn-logout:hover {
  background: var(--accent-red);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.22);
}

.content-container {
  padding: 40px;
  flex-grow: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Custom UI Panels and Cards (Glassmorphism) */
.glass-panel {
  background: rgba(22, 29, 45, 0.88);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-md);
  margin-bottom: 30px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  content-visibility: auto;
  contain-intrinsic-size: 1px 480px;
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

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

.form-label {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.form-control {
  width: 100%;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.25);
  background: rgba(17, 24, 39, 0.9);
}

.form-error {
  font-size: 0.8rem;
  color: var(--accent-red);
  margin-top: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-family: var(--font-heading);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--text-dark);
  box-shadow: 0 3px 10px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.38);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 15px;
}

.custom-table th {
  background: rgba(17, 24, 39, 0.5);
  padding: 16px 20px;
  font-family: var(--font-heading);
  font-weight: 600;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--panel-border);
}

.custom-table td {
  padding: 16px 20px;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text);
  vertical-align: middle;
}

.custom-table tr:hover td {
  background: rgba(255, 255, 255, 0.015);
  color: #ffffff;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 99px;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-yellow);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

/* Alert Boxes */
.alert {
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
}

/* Global Toast */
.app-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10050;
  width: min(420px, calc(100vw - 32px));
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  border: 1px solid transparent;
  animation: toast-in 180ms ease-out;
}

.app-toast-success {
  background: rgba(15, 118, 110, 0.96);
  border-color: rgba(45, 212, 191, 0.32);
  color: #ecfeff;
}

.app-toast-danger {
  background: rgba(127, 29, 29, 0.96);
  border-color: rgba(248, 113, 113, 0.32);
  color: #fff1f2;
}

.app-toast__icon {
  flex: 0 0 auto;
  font-size: 1.1rem;
  line-height: 1;
  margin-top: 2px;
}

.app-toast__body {
  flex: 1;
  min-width: 0;
}

.app-toast__title {
  font-weight: 700;
  margin-bottom: 4px;
}

.app-toast__message {
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.app-toast__close {
  flex: 0 0 auto;
  margin-left: 4px;
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.82;
}

.app-toast__close:hover {
  opacity: 1;
}

/* Login Screen specific */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(22, 29, 45, 0.94);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 35px;
}

.login-header .brand-logo {
  margin: 0 auto 16px;
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
}

.login-header h2 {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Animations */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.2s ease;
}
.fade-enter-from, .fade-leave-to {
  opacity: 0;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) {
  .app-toast {
    top: 16px;
    left: 16px;
    right: 16px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
