/* ============================================================
   Codex Usage Monitor - Modern SaaS Dashboard Styles
   Dark theme, developer tool aesthetic
   ============================================================ */

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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a25;
  --bg-card-hover: #222230;
  --border-color: #2a2a3a;
  --border-subtle: #1e1e2e;
  --text-primary: #e8e8ed;
  --text-secondary: #9090a0;
  --text-muted: #606070;
  --accent-blue: #4a8eff;
  --accent-green: #22c55e;
  --accent-yellow: #eab308;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --accent-cyan: #06b6d4;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* --- Header --- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-blue);
}

.logo-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.logo-subtitle span {
  color: var(--accent-blue);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent-green);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Status Grid --- */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1.5rem 2rem;
}

.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  transition: border-color 0.2s, background 0.2s;
}

.status-card:hover {
  border-color: var(--text-muted);
  background: var(--bg-card-hover);
}

.status-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.status-card-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1.4;
}

/* --- Latest Event Highlight --- */
.latest-event {
  padding: 0 2rem 1.5rem;
}

.highlight-empty {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.event-highlight-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.event-highlight-card:hover {
  border-color: var(--accent-blue);
  background: var(--bg-card-hover);
}

.event-highlight-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.event-highlight-title {
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
}

.event-highlight-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.event-highlight-meta a {
  color: var(--accent-blue);
  text-decoration: none;
}

.event-highlight-meta a:hover {
  text-decoration: underline;
}

.event-highlight-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Category Badges --- */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.category-badge svg {
  width: 12px;
  height: 12px;
}

.category-RESET_PLANNED {
  background: rgba(234, 179, 8, 0.12);
  color: var(--accent-yellow);
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.category-RESET_COMPLETED {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.category-RESET_TIME_CHANGED {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.category-POLICY_CHANGE {
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, 0.25);
}

/* --- Timeline Section --- */
.timeline-section {
  padding: 0 2rem 2rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.filter-bar {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.filter-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
  background: var(--bg-card);
}

.filter-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

/* --- Timeline Items --- */
.timeline {
  position: relative;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 1rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-color);
}

.timeline-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.timeline-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.timeline-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0 0.75rem 0;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: var(--radius);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  margin-left: 0;
}

.timeline-item:hover {
  background: var(--bg-card);
}

.timeline-dot {
  flex-shrink: 0;
  width: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.timeline-dot-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: var(--bg-primary);
  margin-top: 0.375rem;
  z-index: 1;
}

.timeline-item.RESET_PLANNED .timeline-dot-marker {
  border-color: var(--accent-yellow);
  background: rgba(234, 179, 8, 0.15);
}

.timeline-item.RESET_COMPLETED .timeline-dot-marker {
  border-color: var(--accent-green);
  background: rgba(34, 197, 94, 0.15);
}

.timeline-item.RESET_TIME_CHANGED .timeline-dot-marker {
  border-color: var(--accent-red);
  background: rgba(239, 68, 68, 0.15);
}

.timeline-item.POLICY_CHANGE .timeline-dot-marker {
  border-color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.15);
}

.timeline-content {
  flex: 1;
  min-width: 0;
  padding-bottom: 0.5rem;
}

.timeline-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 0.25rem;
}

.timeline-title {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.125rem;
}

.timeline-summary {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.modal-content {
  padding: 1.5rem;
}

.modal-section {
  margin-bottom: 1.25rem;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.modal-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.modal-value.source-text {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.modal-value.ai-summary {
  background: rgba(74, 142, 255, 0.05);
  border: 1px solid rgba(74, 142, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.8rem;
}

.modal-tag {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.modal-tag.source {
  color: var(--accent-blue);
  border: 1px solid rgba(74, 142, 255, 0.2);
}

.modal-tag.ai {
  color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.modal-link {
  color: var(--accent-blue);
  text-decoration: none;
  font-size: 0.875rem;
}

.modal-link:hover {
  text-decoration: underline;
}

.confidence-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.confidence-track {
  flex: 1;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-green);
  transition: width 0.5s ease;
}

.confidence-fill.medium {
  background: var(--accent-yellow);
}

.confidence-fill.low {
  background: var(--accent-red);
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
  margin-top: 2rem;
}

.footer-content {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-links {
  margin-top: 0.5rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent-blue);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .header {
    padding: 0.75rem 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .status-grid {
    padding: 1rem;
    grid-template-columns: 1fr 1fr;
  }
  
  .latest-event {
    padding: 0 1rem 1rem;
  }
  
  .timeline-section {
    padding: 0 1rem 1rem;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .filter-bar {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .footer {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .status-grid {
    grid-template-columns: 1fr;
  }
}
/* --- Language Switcher --- */
.lang-switch {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  min-width: 48px;
  text-align: center;
}

.lang-switch:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(74, 142, 255, 0.1);
}

.lang-switch:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .lang-switch {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    min-width: 40px;
  }
}
/* --- Reset Countdown Section --- */
.countdown-section {
  padding: 1rem 2rem 0.5rem;
}

.countdown-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.countdown-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.countdown-status-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-mono);
}

.status-scheduled {
  background: rgba(234, 179, 8, 0.12);
  color: var(--accent-yellow);
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.status-due, .status-confirming {
  background: rgba(74, 142, 255, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(74, 142, 255, 0.25);
}

.status-confirmed {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.status-expired_unconfirmed {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.countdown-display {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.countdown-time {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-blue);
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
}

.countdown-approx {
  font-size: 1rem;
  color: var(--accent-yellow);
}

.countdown-due {
  font-size: 0.9rem;
  color: var(--accent-blue);
  font-weight: 600;
}

.countdown-due-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.countdown-due-text.dim {
  color: var(--text-muted);
  font-style: italic;
}

.countdown-info {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.countdown-info-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.countdown-info-label {
  color: var(--text-muted);
  min-width: 80px;
  flex-shrink: 0;
}

.countdown-info-value {
  color: var(--text-secondary);
}

.countdown-link {
  color: var(--accent-blue);
  text-decoration: none;
  font-size: 0.7rem;
}

.countdown-link:hover {
  text-decoration: underline;
}

.countdown-confirmed-badge {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  display: inline-block;
}

.countdown-confirmed-badge.direct {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.countdown-confirmed-badge.community {
  background: rgba(234, 179, 8, 0.12);
  color: var(--accent-yellow);
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.countdown-empty {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .countdown-section {
    padding: 0.75rem 1rem 0.5rem;
  }
  .countdown-time {
    font-size: 1.5rem;
  }
  .countdown-info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
  }
}
