/* Modern CSS Reset and Variables */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --background: #0f0f23;
  --surface: #1a1b2e;
  --surface-light: #2d2d44;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #6b7280;
  --border: rgba(255, 255, 255, 0.1);
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-lg: 16px;
  --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, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Glass Morphism Effect */
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  padding: 3rem 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><polygon fill="rgba(255,255,255,0.05)" points="0,1000 1000,0 1000,1000"/></svg>');
  background-size: cover;
}

.logo {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  position: relative;
}

.tagline {
  font-size: 1.2rem;
  opacity: 0.9;
  font-weight: 300;
}

/* Navigation */
.nav {
  @apply glass;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 0;
  overflow-x: auto;
}

.nav-link {
  padding: 0.75rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-weight: 500;
}

.nav-link:hover {
  background: var(--surface-light);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--primary);
  color: white;
}

/* Main Content */
.main {
  flex: 1;
  padding: 3rem 0;
}

.section {
  display: none;
  animation: fadeIn 0.5s ease-in-out;
}

.section.active {
  display: block;
}

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

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.card {
  @apply glass;
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.card h3 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.5rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

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

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.button-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Logs */
.log {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

.log::-webkit-scrollbar {
  width: 6px;
}

.log::-webkit-scrollbar-track {
  background: var(--surface);
}

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

/* Specific Components */
.counter-display {
  text-align: center;
  margin: 2rem 0;
}

.counter-value {
  font-size: 4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat {
  @apply glass;
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.slider {
  width: 100%;
  margin: 1.5rem 0;
}

.user-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
}

.user-info {
  flex: 1;
}

.todo-input {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.todo-input .input {
  flex: 1;
}

.todo-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
}

.todo-list {
  max-height: 300px;
  overflow-y: auto;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.todo-item:hover {
  background: var(--surface-light);
}

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

.todo-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.todo-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}

.todo-checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 0.8rem;
}

.todo-text {
  flex: 1;
}

.todo-text.completed {
  text-decoration: line-through;
  opacity: 0.6;
}

.cart-summary {
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
}

.summary-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
  margin-bottom: 0;
  border-bottom: none;
}

.summary-item.total {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
}

.converter {
  margin: 1.5rem 0;
}

.exchange-rate {
  text-align: center;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  font-weight: 600;
}

.rate-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.search-container {
  margin: 1.5rem 0;
}

.search-input {
  margin-bottom: 1rem;
}

.search-status {
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  text-align: center;
}

.error-message {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  min-height: 1rem;
}

.form-status {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
}

.form-status.valid {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid var(--success);
}

.form-status.invalid {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 1px solid var(--error);
}

.batch-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}

.value-display {
  @apply glass;
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
}

.value-display span:first-child {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.value-display span:last-child {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.update-count {
  text-align: center;
  margin: 1rem 0;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  font-weight: 600;
}

.scope-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.scope-status {
  text-align: center;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 600;
}

.scope-status.active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.scope-status.inactive {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

/* Footer */
.footer {
  @apply glass;
  text-align: center;
  padding: 2rem 0;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
}

/* Responsive Design */
@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    flex-wrap: wrap;
  }

  .button-group {
    flex-direction: column;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .batch-values {
    grid-template-columns: 1fr;
  }

  .header {
    padding: 2rem 0;
  }

  .logo {
    font-size: 2rem;
  }
}

/* Animations */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.pulse {
  animation: pulse 0.5s ease-in-out;
}

/* Utility Classes */
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.hidden { display: none; }

/* Enhanced Logging Styles */
.log-entry {
  padding: 0.5rem;
  margin: 0.25rem 0;
  border-radius: 4px;
  border-left: 3px solid transparent;
  font-size: 0.85rem;
  line-height: 1.3;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.log-info {
  background: rgba(99, 102, 241, 0.1);
  border-left-color: var(--primary);
}

.log-effect {
  background: rgba(139, 92, 246, 0.1);
  border-left-color: #8b5cf6;
}

.log-computed {
  background: rgba(16, 185, 129, 0.1);
  border-left-color: var(--success);
}

.log-watch {
  background: rgba(245, 158, 11, 0.1);
  border-left-color: var(--warning);
}

.log-batch {
  background: rgba(236, 72, 153, 0.1);
  border-left-color: var(--secondary);
}

.log-error {
  background: rgba(239, 68, 68, 0.1);
  border-left-color: var(--error);
}

.log-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.log-icon {
  margin-right: 0.5rem;
  font-size: 0.9rem;
}

.log-message {
  color: var(--text-primary);
}

/* Global log */
.global-log {
  position: fixed !important;
  bottom: 20px;
  right: 20px;
  width: 400px;
  height: 200px;
  background: rgba(15, 15, 35, 0.95) !important;
  backdrop-filter: blur(10px);
  border: 1px solid var(--border) !important;
  z-index: 1000;
  font-size: 0.8rem;
  box-shadow: var(--shadow-lg);
}

.global-log .log-entry {
  padding: 0.35rem 0.5rem;
  margin: 0.2rem 0;
  font-size: 0.75rem;
}

/* Pulse animation for value changes */
@keyframes valueChange {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.value-changing {
  animation: valueChange 0.3s ease-in-out;
}

/* Enhanced mobile responsiveness */
@media (max-width: 768px) {
  .global-log {
    width: calc(100% - 40px);
    height: 150px;
    bottom: 10px;
    right: 10px;
    left: 10px;
  }
}

/* Log scrollbar styling */
.log::-webkit-scrollbar {
  width: 6px;
}

.log::-webkit-scrollbar-track {
  background: var(--surface);
}

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

.log::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* Additional styles for better autofill handling */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  border: 2px solid var(--primary);
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0px 1000px var(--surface) inset;
  transition: background-color 5000s ease-in-out 0s;
}

/* Focus styles for better accessibility */
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Style for valid/invalid inputs based on reactive state */
.input.valid {
  border-color: var(--success);
}

.input.invalid {
  border-color: var(--error);
}

/* Auto-fill detection styles */
.input:autofill {
  background-color: var(--surface) !important;
  color: var(--text-primary) !important;
}
