/* M3 Elevated Cards & Components */

.view {
  animation: fadeIn 0.3s ease-out;
}

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

.card {
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--md-sys-elevation-1);
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--md-sys-color-on-surface); /* Explicit text color */
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.card-title .material-symbols-outlined {
  font-size: 20px;
}

.kpi-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.kpi-value {
  font-size: 32px;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
}

.kpi-unit {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  margin-left: 4px;
}

.kpi-trend {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
}

.kpi-trend.up {
  background-color: rgba(46, 125, 50, 0.2);
  color: #81c784;
}

[data-theme="light"] .kpi-trend.up {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.kpi-trend.down {
  background-color: rgba(198, 40, 40, 0.2);
  color: #e57373;
}

[data-theme="light"] .kpi-trend.down {
  background-color: #ffebee;
  color: #c62828;
}

/* Progress Bar */
.progress-container {
  height: 8px;
  width: 100%;
  background-color: var(--md-sys-color-outline-variant);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background-color: var(--md-sys-color-secondary);
  border-radius: 4px;
  transition: width 0.5s ease-out;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: stretch; /* Cards in same row will have same height */
}

@media (min-width: 900px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Force full width for elements that need it */
  .dashboard-grid .card[style*="grid-column: 1 / -1"],
  .dashboard-grid .full-width {
    grid-column: 1 / -1;
  }
}

/* List Items & Interactivity */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin: 0 -16px; /* Offset card padding */
  border-bottom: 1px solid var(--md-sys-color-surface-variant);
  cursor: pointer;
  transition: background-color 0.2s;
}

.list-item:hover {
  background-color: var(--md-sys-color-surface-container-highest);
}

.list-item:active {
  background-color: var(--md-sys-color-surface-variant);
  opacity: 0.8;
}

.list-item:last-child {
  border-bottom: none;
}

.m3-button {
  background-color: var(--md-sys-color-secondary);
  color: var(--md-sys-color-on-secondary);
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
}

.m3-button:disabled {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  cursor: not-allowed;
}

/* Interactive States */
.card.interactive {
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  user-select: none;
}

.card.interactive:active {
  transform: scale(0.98);
  box-shadow: var(--md-sys-elevation-1);
}

/* Macro Bars in Dashboard */
.macro-bars {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.macro-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.macro-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.macro-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.macro-value-text {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
}

.macro-progress-bg {
  width: 100%;
  height: 8px;
  background: var(--md-sys-color-outline-variant);
  border-radius: 4px;
  overflow: hidden;
}

.macro-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning {
  animation: spin 1s linear infinite;
}

.m3-button-icon {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.m3-button-icon:hover {
  background: var(--md-sys-color-surface-variant);
}

.m3-button-icon-small {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
}

.m3-button-icon-small:hover {
  background: var(--md-sys-color-surface-variant);
}

.m3-button {
  transition: transform 0.1s ease, background-color 0.2s ease;
}
.m3-button:active {
  transform: scale(0.95);
}
.m3-button-icon-small:active, .m3-button-icon:active {
  transform: scale(0.90);
}

/* M3 Badge */
.md-badge {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    font-size: 10px;
    font-weight: 500;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    position: absolute;
    top: -4px;
    right: -4px;
}
.md-badge.hidden {
    display: none;
}

/* M3 Elevated Card */
.md-card-elevated {
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: 16px;
    box-shadow: var(--md-sys-elevation-1);
    transition: box-shadow 0.2s, background-color 0.2s;
}
.md-card-elevated:hover {
    box-shadow: var(--md-sys-elevation-2);
    background-color: var(--md-sys-color-surface-container);
}

/* Typing Dots Animation */
.typing-dots {
    display: inline-block;
    width: 24px;
    text-align: left;
    animation: typing 1.5s infinite;
}
@keyframes typing {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}
