/* ==============================
   Global Design System
   ============================== */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #111827;
  --bg-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ==============================
   Login Page
   ============================== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  animation: float 8s ease-in-out infinite;
}

.login-container::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  animation: float 6s ease-in-out infinite reverse;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-30px);
  }
}

.login-card {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 20px;
  padding: 48px 40px;
  width: 420px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 1;
}

.login-card h1 {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 36px;
}

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

.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-header .user-info {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
}

.sidebar-header .user-detail {
  flex: 1;
}

.sidebar-header .user-detail .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-header .user-detail .role {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

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

.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.1));
  color: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-item .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border-color);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--danger);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  min-height: 100vh;
  background: var(--bg-dark);
}

/* ==============================
   Page Header
   ============================== */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

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

/* ==============================
   Cards
   ============================== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.purple::before {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.stat-card.green::before {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.stat-card.blue::before {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.stat-card.orange::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(99, 102, 241, 0.3);
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card .unit {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 4px;
}

/* ==============================
   Content Card
   ============================== */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.content-card .card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==============================
   Element Plus Dark Override
   ============================== */
.el-table {
  --el-table-bg-color: var(--bg-card) !important;
  --el-table-tr-bg-color: var(--bg-card) !important;
  --el-table-header-bg-color: rgba(51, 65, 85, 0.5) !important;
  --el-table-row-hover-bg-color: var(--bg-hover) !important;
  --el-table-text-color: var(--text-primary) !important;
  --el-table-header-text-color: var(--text-secondary) !important;
  --el-table-border-color: var(--border-color) !important;
  --el-fill-color-lighter: var(--bg-hover) !important;
}

.el-dialog {
  --el-dialog-bg-color: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius) !important;
}

.el-dialog__title {
  color: var(--text-primary) !important;
}

.el-form-item__label {
  color: var(--text-secondary) !important;
}

.el-input__wrapper,
.el-select__wrapper,
.el-textarea__inner {
  background-color: var(--bg-dark) !important;
  box-shadow: 0 0 0 1px var(--border-color) inset !important;
  color: var(--text-primary) !important;
}

.el-input__inner,
.el-textarea__inner {
  color: var(--text-primary) !important;
}

.el-input__inner::placeholder {
  color: var(--text-muted) !important;
}

.el-select-dropdown {
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
}

.el-select-dropdown__item {
  color: var(--text-primary) !important;
}

.el-select-dropdown__item.is-hovering {
  background-color: var(--bg-hover) !important;
}

.el-popper.is-light {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
}

/* Date Picker & Date Range Picker Dark Mode Comprehensive Fixes */
.el-picker-panel, 
.el-date-picker, 
.el-date-range-picker {
  --el-datepicker-bg-color: var(--bg-card) !important;
  --el-datepicker-text-color: var(--text-primary) !important;
  --el-datepicker-off-text-color: var(--text-muted) !important;
  --el-datepicker-header-text-color: var(--text-primary) !important;
  --el-datepicker-icon-color: var(--text-secondary) !important;
  --el-datepicker-border-color: var(--border-color) !important;
  --el-datepicker-inner-border-color: var(--border-color) !important;
  --el-datepicker-inrange-bg-color: var(--bg-hover) !important;
  --el-datepicker-inrange-hover-bg-color: rgba(99, 102, 241, 0.2) !important;
  --el-datepicker-active-color: var(--primary) !important;
  --el-datepicker-hover-text-color: var(--primary-light) !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
}

/* Explicitly fix text colors that variables might miss */
.el-date-table th {
  color: var(--text-secondary) !important;
  border-bottom: 1px solid var(--border-color) !important;
}
.el-date-table td .el-date-table-cell__text {
  color: var(--text-primary) !important;
}
.el-date-table td.next-month .el-date-table-cell__text,
.el-date-table td.prev-month .el-date-table-cell__text {
  color: var(--text-muted) !important;
}
/* Range Start and End */
.el-date-table td.start-date .el-date-table-cell__text,
.el-date-table td.end-date .el-date-table-cell__text,
.el-date-table td.current:not(.disabled) .el-date-table-cell__text {
  background: var(--primary) !important;
  color: #ffffff !important;
}
/* Today highlight */
.el-date-table td.today .el-date-table-cell__text {
  color: var(--primary) !important;
  font-weight: bold;
}
/* In-range background override */
.el-date-table td.in-range .el-date-table-cell {
  background-color: var(--bg-hover) !important;
}
/* Disabled dates */
.el-date-table td.disabled .el-date-table-cell {
  background-color: rgba(30, 41, 59, 0.4) !important;
}
.el-date-table td.disabled .el-date-table-cell__text {
  background-color: transparent !important;
  color: var(--text-muted) !important;
  opacity: 0.6;
}

/* Fix Header Icons and Labels */
.el-picker-panel__icon-btn {
  color: var(--text-primary) !important;
}
.el-date-picker__header-label {
  color: var(--text-primary) !important;
  font-weight: bold;
}
.el-date-range-picker__content.is-left {
  border-right: 1px solid var(--border-color) !important;
}

.el-button--primary {
  --el-button-bg-color: var(--primary) !important;
  --el-button-border-color: var(--primary) !important;
  --el-button-hover-bg-color: var(--primary-light) !important;
  --el-button-hover-border-color: var(--primary-light) !important;
}

.el-pagination {
  --el-pagination-bg-color: transparent !important;
  --el-pagination-text-color: var(--text-secondary) !important;
  --el-pagination-button-bg-color: var(--bg-hover) !important;
  --el-pagination-hover-color: var(--primary) !important;
}

.el-tag {
  border-radius: 6px !important;
}

.el-message-box {
  --el-messagebox-bg-color: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
}

/* ==============================
   Filter Bar
   ============================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ==============================
   Chart Container
   ============================== */
.chart-container {
  width: 100%;
  height: 480px;
  margin-top: 16px;
}

/* ==============================
   El-Tabs Overflow Fix
   ============================== */
.el-tabs {
  overflow: visible !important;
}

.el-tabs__content {
  overflow: visible !important;
}

.el-tab-pane {
  overflow: visible !important;
}

.el-tabs--border-card {
  overflow: visible !important;
}

/* ==============================
   Animations
   ============================== */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.slide-enter-active,
.slide-leave-active {
  transition: all 0.3s ease;
}

.slide-enter-from {
  transform: translateX(20px);
  opacity: 0;
}

.slide-leave-to {
  transform: translateX(-20px);
  opacity: 0;
}