/* ============================================
   ASH Design System — v2.0
   Modern, professional dark theme
   ============================================ */

/* === Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* === CSS Custom Properties === */
:root {
  /* Background layers */
  --bg-base: #09090b;
  --bg-surface: #131316;
  --bg-elevated: #1a1a1f;
  --bg-overlay: #222228;
  --bg-hover: #2a2a32;
  --bg-active: #32323c;

  /* Borders */
  --border-subtle: #1f1f26;
  --border-default: #2a2a34;
  --border-strong: #3f3f4a;

  /* Text */
  --text-primary: #f0f0f3;
  --text-secondary: #a0a0b0;
  --text-muted: #666675;
  --text-inverse: #09090b;

  /* Accent — brand blue */
  --accent: #4f8ff7;
  --accent-hover: #6ba1ff;
  --accent-muted: rgba(79, 143, 247, 0.12);
  --accent-strong: rgba(79, 143, 247, 0.24);

  /* Semantic colors */
  --success: #34d399;
  --success-muted: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-muted: rgba(251, 191, 36, 0.12);
  --error: #f87171;
  --error-muted: rgba(248, 113, 113, 0.12);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(79, 143, 247, 0.15);

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-default: 200ms ease;
  --transition-slow: 300ms ease;
}

/* === Reset === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === Base === */
html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* === Layout Shell === */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

.page-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: var(--space-8);
  max-width: 1400px;
  overflow-x: hidden;
  transition: margin-left var(--transition-slow);
}

body.sidebar-collapsed .page-content {
  margin-left: var(--sidebar-collapsed);
}

/* === Page Header === */
.page-header {
  margin-bottom: var(--space-8);
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-header .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* === Cards === */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color var(--transition-default), box-shadow var(--transition-default);
}

.card:hover {
  border-color: var(--border-default);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* === Stat Cards === */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.stat-card .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  font-size: 1.1rem;
}

.stat-card .stat-icon.blue { background: var(--accent-muted); color: var(--accent); }
.stat-card .stat-icon.green { background: var(--success-muted); color: var(--success); }
.stat-card .stat-icon.amber { background: var(--warning-muted); color: var(--warning); }
.stat-card .stat-icon.red { background: var(--error-muted); color: var(--error); }

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.stat-card .stat-trend {
  font-size: 0.75rem;
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.stat-card .stat-trend.up { color: var(--success); }
.stat-card .stat-trend.down { color: var(--error); }
.stat-card .stat-trend.neutral { color: var(--text-muted); }

/* === Grid Layouts === */
.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge.online, .badge.success { background: var(--success-muted); color: var(--success); }
.badge.offline, .badge.error { background: var(--error-muted); color: var(--error); }
.badge.warn, .badge.warning { background: var(--warning-muted); color: var(--warning); }
.badge.info { background: var(--accent-muted); color: var(--accent); }
.badge.neutral { background: var(--bg-overlay); color: var(--text-secondary); }

/* Badge dot indicator */
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge.no-dot::before { display: none; }

/* === Section Headers === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  margin-top: var(--space-8);
}

.section-header:first-child {
  margin-top: 0;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-action {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.section-action:hover {
  color: var(--accent-hover);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-default);
  color: var(--text-secondary);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

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

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

.btn-success:hover {
  background: #2bc489;
}

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

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

.btn-warning {
  background: var(--warning);
  color: var(--text-inverse);
}

.btn-warning:hover {
  background: #e6ac1f;
}

.btn:disabled {
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: transparent;
}

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

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* === Tables === */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-elevated);
}

tbody td {
  padding: 10px 14px;
  color: var(--text-secondary);
}

/* === Form Elements === */
input, select, textarea {
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

input::placeholder {
  color: var(--text-muted);
}

select {
  cursor: pointer;
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-5);
}

.tab {
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  margin-bottom: -1px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* === Toggle Switch === */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: #3a3a46;
  border-radius: 12px;
  transition: background var(--transition-default);
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform var(--transition-default);
  pointer-events: none;
}

.toggle input:checked ~ .toggle-thumb {
  transform: translateX(20px);
}

/* === Collapsible Sections === */
.collapsible-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}

.collapsible-header .chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform var(--transition-default);
}

.collapsible-header.collapsed .chevron {
  transform: rotate(-90deg);
}

.collapsible-body {
  overflow: hidden;
  transition: max-height var(--transition-slow), opacity var(--transition-default);
  max-height: 2000px;
  opacity: 1;
}

.collapsible-body.collapsed {
  max-height: 0;
  opacity: 0;
}

/* === Service Status Dot === */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--error); }
.status-dot.warning { background: var(--warning); }

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

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

/* === Utility === */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

.font-mono {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* === Responsive === */
@media (max-width: 1024px) {
  .page-content {
    margin-left: var(--sidebar-collapsed);
    padding: var(--space-5);
  }

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

@media (max-width: 768px) {
  .page-content {
    margin-left: 0;
    padding: var(--space-4);
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 100vw;
  }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }

  .page-header h1 {
    font-size: 1.4rem;
  }
}

/* === Animations === */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 143, 247, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(79, 143, 247, 0.15); }
}

.animate-in {
  animation: fade-in 0.3s ease forwards;
}

/* === Cost-specific === */
.cost-hero {
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.cost-hero .cost-amount {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.cost-hero .cost-period {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}
