/* ========================================
   AWS Billing System - Theme Variables
   ======================================== */

/* ---------- Dark Theme ---------- */
:root,
[data-theme="dark"] {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1629;
  --bg-card: #141c2e;
  --bg-hover: #1a2540;
  --border-color: #1e2d4a;
  --border-glow: #2a4080;
  --accent-primary: #4f8ef7;
  --accent-secondary: #7b5cf0;
  --accent-gradient: linear-gradient(135deg, #4f8ef7 0%, #7b5cf0 100%);
  --accent-danger: #f56565;
  --accent-success: #48bb78;
  --accent-warning: #ed8936;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #4a5568;
  --sidebar-width: 220px;
  --header-height: 64px;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(79, 142, 247, 0.15);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* ---------- Light Theme ---------- */
[data-theme="light"] {
  --bg-primary: #f0f4ff;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef2fb;
  --border-color: #dce4f5;
  --border-glow: #b8ccf8;
  --accent-primary: #3b6fd4;
  --accent-secondary: #6246c9;
  --accent-gradient: linear-gradient(135deg, #3b6fd4 0%, #6246c9 100%);
  --accent-danger: #e53e3e;
  --accent-success: #2f855a;
  --accent-warning: #c05621;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #a0aec0;
  --shadow-card: 0 4px 24px rgba(59, 111, 212, 0.10);
  --shadow-glow: 0 0 20px rgba(59, 111, 212, 0.10);
}

/* ---------- Light theme specific overrides ---------- */
[data-theme="light"] body {
  background: var(--bg-primary);
}

[data-theme="light"] .el-aside {
  box-shadow: 4px 0 16px rgba(59, 111, 212, 0.08) !important;
}

[data-theme="light"] .el-menu-item.is-active {
  background: linear-gradient(90deg, rgba(59,111,212,0.10) 0%, rgba(59,111,212,0.03) 100%) !important;
}

[data-theme="light"] .el-table {
  box-shadow: var(--shadow-card) !important;
}

[data-theme="light"] .el-table th.el-table__cell {
  background: #f7f9ff !important;
}

[data-theme="light"] .login-wrapper::before {
  background: radial-gradient(circle, rgba(59,111,212,0.07) 0%, transparent 70%);
}

[data-theme="light"] .login-wrapper::after {
  background: radial-gradient(circle, rgba(98,70,201,0.05) 0%, transparent 70%);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

/* ========================================
   ELEMENT UI OVERRIDES - LAYOUT
   ======================================== */

.el-container {
  height: 100vh !important;
  border: none !important;
  background: var(--bg-primary);
}

/* SIDEBAR */
.el-aside {
  width: var(--sidebar-width) !important;
  background: var(--bg-secondary) !important;
  border-right: 1px solid var(--border-color) !important;
  display: flex;
  flex-direction: column;
  color: var(--text-primary) !important;
  box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}

.el-menu {
  background: transparent !important;
  border-right: none !important;
  padding: 12px 0;
  width: 100% !important;
}

.el-menu-item,
.el-submenu__title {
  color: var(--text-secondary) !important;
  background: transparent !important;
  border-radius: var(--radius-sm);
  margin: 2px 10px !important;
  width: calc(100% - 20px) !important;
  transition: all 0.2s ease;
  height: 42px !important;
  line-height: 42px !important;
  font-size: 13px !important;
}

.el-submenu__title {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin: 8px 10px !important;
  padding-left: 16px !important;
}

.el-submenu__title i {
  color: var(--accent-primary) !important;
}

.el-menu-item:hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
}

.el-menu-item.is-active {
  background: linear-gradient(90deg, rgba(79,142,247,0.15) 0%, rgba(79,142,247,0.05) 100%) !important;
  color: var(--accent-primary) !important;
  border-left: 3px solid var(--accent-primary);
}

.el-menu-item .el-link {
  color: inherit !important;
  font-size: 13px;
  width: 100%;
  display: block;
  text-decoration: none;
}

.el-menu-item .el-link:hover {
  text-decoration: none !important;
  color: var(--accent-primary) !important;
}

.el-menu-item .el-link.el-link--default:after {
  display: none;
}

/* HEADER */
.el-header {
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  height: var(--header-height) !important;
  line-height: var(--header-height) !important;
  padding: 0 24px !important;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

/* MAIN CONTENT */
.el-main {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  padding: 24px !important;
}

/* FOOTER */
.el-footer {
  background: var(--bg-secondary) !important;
  border-top: 1px solid var(--border-color) !important;
  color: var(--text-secondary) !important;
  height: 56px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px !important;
}

/* ========================================
   ELEMENT UI OVERRIDES - TABLE
   ======================================== */

.el-table {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.el-table::before {
  display: none;
}

.el-table th.el-table__cell {
  background: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border-color) !important;
  padding: 14px 0 !important;
}

.el-table td.el-table__cell {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  padding: 12px 0 !important;
}

.el-table--border .el-table__cell {
  border-right: 1px solid var(--border-color) !important;
}

.el-table tr:hover > td.el-table__cell {
  background: var(--bg-hover) !important;
}

.el-table .el-table__empty-block {
  background: var(--bg-card) !important;
}

.el-table .el-table__empty-text {
  color: var(--text-muted) !important;
}

/* row highlight colors */
.el-table .a1-row td.el-table__cell { background: rgba(245, 101, 101, 0.08) !important; }
.el-table .a2-row td.el-table__cell { background: rgba(237, 137, 54, 0.08) !important; }
.el-table .a3-row td.el-table__cell { background: rgba(79, 142, 247, 0.05) !important; }
.el-table .a4-row td.el-table__cell { background: var(--bg-card) !important; }

/* ========================================
   ELEMENT UI OVERRIDES - FORM
   ======================================== */

.el-form-item__label {
  color: var(--text-secondary) !important;
  font-size: 13px !important;
}

.el-input__inner {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-primary) !important;
  font-size: 13px;
  transition: all 0.2s ease;
}

.el-input__inner:focus {
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 2px rgba(79, 142, 247, 0.15) !important;
}

.el-input__inner::placeholder {
  color: var(--text-muted) !important;
}

.el-select .el-input__inner {
  background: var(--bg-primary) !important;
}

.el-select-dropdown {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow-card) !important;
}

.el-select-dropdown__item {
  color: var(--text-secondary) !important;
  font-size: 13px;
}

.el-select-dropdown__item:hover,
.el-select-dropdown__item.hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
}

.el-select-dropdown__item.selected {
  color: var(--accent-primary) !important;
  font-weight: 600;
}

/* ========================================
   ELEMENT UI OVERRIDES - BUTTONS
   ======================================== */

.el-button {
  border-radius: var(--radius-sm) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
  border: none !important;
  cursor: pointer;
}

.el-button--primary {
  background: var(--accent-gradient) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(79, 142, 247, 0.3) !important;
}

.el-button--primary:hover {
  opacity: 0.9 !important;
  box-shadow: 0 4px 14px rgba(79, 142, 247, 0.45) !important;
  transform: translateY(-1px);
}

.el-button--default {
  background: var(--bg-hover) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border-color) !important;
}

.el-button--default:hover {
  background: var(--border-glow) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-primary) !important;
}

.el-button--danger {
  background: rgba(245, 101, 101, 0.15) !important;
  color: var(--accent-danger) !important;
  border: 1px solid rgba(245, 101, 101, 0.3) !important;
}

.el-button--danger:hover {
  background: var(--accent-danger) !important;
  color: #fff !important;
  border-color: var(--accent-danger) !important;
}

.el-button--mini {
  padding: 5px 10px !important;
  font-size: 12px !important;
}

.el-button--small {
  padding: 7px 14px !important;
}

/* ========================================
   ELEMENT UI OVERRIDES - PAGINATION
   ======================================== */

.el-pagination {
  color: var(--text-secondary) !important;
}

.el-pagination .btn-prev,
.el-pagination .btn-next {
  background: var(--bg-card) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
}

.el-pagination .btn-prev:hover,
.el-pagination .btn-next:hover {
  color: var(--accent-primary) !important;
  border-color: var(--accent-primary) !important;
}

.el-pager li {
  background: var(--bg-card) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  margin: 0 2px !important;
  min-width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
}

.el-pager li.active {
  background: var(--accent-gradient) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.el-pager li:hover {
  color: var(--accent-primary) !important;
  border-color: var(--accent-primary) !important;
}

.el-pagination__sizes .el-input__inner {
  height: 30px !important;
  line-height: 30px !important;
}

.el-pagination__jump {
  color: var(--text-secondary) !important;
}

.el-pagination__jump .el-input__inner {
  height: 30px !important;
  line-height: 30px !important;
}

/* ========================================
   ELEMENT UI OVERRIDES - DIALOG
   ======================================== */

.el-dialog {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6) !important;
}

.el-dialog__header {
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  padding: 18px 24px !important;
}

.el-dialog__title {
  color: var(--text-primary) !important;
  font-weight: 600;
  font-size: 15px;
}

.el-dialog__headerbtn .el-dialog__close {
  color: var(--text-muted) !important;
}

.el-dialog__headerbtn:hover .el-dialog__close {
  color: var(--text-primary) !important;
}

.el-dialog__body {
  color: var(--text-primary) !important;
  padding: 24px !important;
}

.el-dialog__footer {
  border-top: 1px solid var(--border-color) !important;
  padding: 16px 24px !important;
}

.el-overlay,
.v-modal {
  background: rgba(0, 0, 0, 0.7) !important;
}

/* ========================================
   ELEMENT UI OVERRIDES - TREE
   ======================================== */

.el-tree {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border-color) !important;
  padding: 12px !important;
}

.el-tree-node__content {
  border-radius: var(--radius-sm) !important;
  height: 36px !important;
}

.el-tree-node__content:hover {
  background: var(--bg-hover) !important;
}

.el-tree-node:focus > .el-tree-node__content {
  background: rgba(79, 142, 247, 0.1) !important;
}

.el-tree-node.is-current > .el-tree-node__content {
  background: rgba(79, 142, 247, 0.12) !important;
  color: var(--accent-primary) !important;
}

.el-tree__empty-block {
  background: var(--bg-card) !important;
}

.el-checkbox__inner {
  background: var(--bg-primary) !important;
  border-color: var(--border-glow) !important;
}

.el-checkbox__input.is-checked .el-checkbox__inner {
  background: var(--accent-primary) !important;
  border-color: var(--accent-primary) !important;
}

/* ========================================
   ELEMENT UI OVERRIDES - SWITCH
   ======================================== */

.el-switch__core {
  background: var(--bg-hover) !important;
  border-color: var(--border-color) !important;
}

.el-switch.is-checked .el-switch__core {
  background: var(--accent-primary) !important;
  border-color: var(--accent-primary) !important;
}

.el-switch__label {
  color: var(--text-secondary) !important;
}

.el-switch__label.is-active {
  color: var(--accent-primary) !important;
}

/* ========================================
   ELEMENT UI OVERRIDES - UPLOAD
   ======================================== */

.el-upload-list {
  background: transparent !important;
}

.el-upload-list__item {
  color: var(--text-secondary) !important;
  background: var(--bg-hover) !important;
  border-radius: var(--radius-sm) !important;
}

.el-upload-list__item:hover {
  background: var(--bg-hover) !important;
}

/* ========================================
   SIDEBAR LOGO / BRAND AREA
   ======================================== */

.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 8px;
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-right: 10px;
  vertical-align: middle;
}

.sidebar-brand .brand-text {
  display: inline-block;
  vertical-align: middle;
}

.sidebar-brand .brand-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-brand .brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

/* ========================================
   PAGE HEADER BAR
   ======================================== */

.page-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.page-header-bar .header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-header-bar .header-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background: var(--accent-gradient);
  border-radius: 2px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-controls .el-form-item {
  margin-bottom: 0 !important;
  margin-right: 0 !important;
}

.header-controls .el-form-item__label {
  color: var(--text-secondary) !important;
  font-size: 12px !important;
  line-height: 32px !important;
}

/* ========================================
   STATS BADGE IN TABLE
   ======================================== */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: rgba(72,187,120,0.15); color: var(--accent-success); }
.badge-primary { background: rgba(79,142,247,0.15); color: var(--accent-primary); }
.badge-danger  { background: rgba(245,101,101,0.15); color: var(--accent-danger); }

/* ========================================
   LOGIN PAGE
   ======================================== */

.login-wrapper {
  min-height: 100vh;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(79,142,247,0.08) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.login-wrapper::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(123,92,240,0.06) 0%, transparent 70%);
  bottom: -50px;
  left: -50px;
  pointer-events: none;
}

.login-card {
  width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px 40px 40px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
}

.login-logo .logo-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-logo .logo-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.login-card .el-form-item {
  margin-bottom: 20px !important;
}

.login-card .el-form-item__label {
  color: var(--text-secondary) !important;
  font-size: 13px !important;
  font-weight: 500;
  padding-bottom: 6px !important;
  line-height: 1.4 !important;
  float: none !important;
  display: block !important;
}

.login-card .el-input__inner {
  height: 44px !important;
  line-height: 44px !important;
  font-size: 14px !important;
  /* 不覆盖 padding，让 Element UI 自己处理 prefix-icon 的缩进 */
}

.login-card .el-button--primary {
  width: 100%;
  height: 46px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  letter-spacing: 1px;
  margin-top: 8px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ========================================
   ROW
   ======================================== */

.el-row {
  margin-bottom: 0 !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  :root { --sidebar-width: 180px; }
  .login-card { width: 90%; padding: 32px 24px; }
}

/* ========================================
   THEME TOGGLE BUTTON
   ======================================== */

.theme-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--accent-gradient);
  box-shadow: 0 4px 16px rgba(79, 142, 247, 0.35), 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s;
  outline: none;
  line-height: 1;
  user-select: none;
}

.theme-toggle-btn:hover {
  transform: scale(1.12) rotate(15deg);
  box-shadow: 0 6px 22px rgba(79, 142, 247, 0.5), 0 3px 8px rgba(0,0,0,0.3);
}

.theme-toggle-btn:active {
  transform: scale(0.95);
  opacity: 0.85;
}

/* tooltip */
.theme-toggle-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 52px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: var(--shadow-card);
}

.theme-toggle-btn:hover::after {
  opacity: 1;
}

/* ========================================
   TABLE ACTION BUTTONS — keep on one line
   ======================================== */

/* action column: flex row, no wrap, enough padding on both sides */
.el-table__body .el-table__cell:last-child .cell,
.el-table__header .el-table__cell:last-child .cell {
  white-space: nowrap !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: nowrap !important;
  justify-content: center !important;
  padding-left: 12px !important;
  padding-right: 12px !important;
  overflow: visible !important;
}

/* make sure the cell itself doesn't clip */
.el-table__body .el-table__cell:last-child,
.el-table__header .el-table__cell:last-child {
  overflow: visible !important;
}

/* ========================================
   TREE — tighten row height
   ======================================== */

.el-tree-node__content {
  height: 30px !important;
}

/* ========================================
   FORM ITEMS — reduce vertical gap
   ======================================== */

.el-form-item {
  margin-bottom: 10px !important;
}

/* ========================================
   TRANSITIONS — suppress on initial load
   ======================================== */

/* class added during page load, removed after first paint */
html.no-transition *,
html.no-transition *::before,
html.no-transition *::after {
  transition: none !important;
}

/* smooth theme transition after load */
*, *::before, *::after {
  transition: background-color 0.25s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.el-button, .theme-toggle-btn {
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease !important;
}
