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

:root {
  --background: #0a0a0a;
  --foreground: #fafafa;
  --card: #141414;
  --card-hover: #1a1a1a;
  --muted: #262626;
  --muted-foreground: #a3a3a3;
  --border: #262626;
  --primary: #fafafa;
  --primary-foreground: #0a0a0a;
  --accent: #1f1f1f;
  --emerald: #10b981;
  --rose: #f43f5e;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  width: 380px;
  min-height: 500px;
  max-height: 600px;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 600px;
}

/* Header */
.header {
  padding: 16px 16px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.header-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}

.header-icon {
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 8px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header-subtitle {
  font-size: 13px;
  color: var(--muted-foreground);
}

/* Tabs */
.tabs {
  display: flex;
  padding: 8px 16px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  background: var(--muted);
  color: var(--foreground);
}

.tab.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

/* Tab Content */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.tab-content.active {
  display: block;
}

/* Filter Toggle */
.filter-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 12px;
}

.filter-toggle:hover {
  background: var(--muted);
  color: var(--foreground);
}

.filter-toggle .chevron {
  transition: transform 0.2s;
}

.filter-toggle.open .chevron {
  transform: rotate(180deg);
}

/* Filter Panel */
.filter-panel {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.filter-panel.open {
  display: block;
}

.filter-group {
  margin-bottom: 12px;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-group h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 12px;
}

.filter-option:hover {
  background: var(--accent);
}

.filter-option input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Currency Grid */
.currency-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Currency Card */
.currency-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.currency-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.2s;
}

.currency-card:hover {
  border-color: var(--muted);
  transform: translateY(-1px);
}

.currency-card:hover::before {
  opacity: 1;
}

.currency-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.currency-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
}

.currency-card-icon {
  background: var(--muted);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
}

.currency-card-icon svg {
  width: 14px;
  height: 14px;
}

.currency-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--muted);
  border-radius: 8px;
  margin-bottom: 6px;
}

.currency-row:last-child {
  margin-bottom: 0;
}

.currency-row-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted-foreground);
}

.currency-row-label svg {
  width: 14px;
  height: 14px;
}

.currency-row-label .buy-icon {
  color: var(--emerald);
}

.currency-row-label .sell-icon {
  color: var(--rose);
}

.currency-row-value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--foreground);
}

.currency-card.loading .currency-row-value {
  background: var(--accent);
  color: transparent;
  border-radius: 4px;
  animation: pulse 1.5s infinite;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted-foreground);
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 4px;
}

.empty-state small {
  font-size: 12px;
}

/* Last Update */
.last-update {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  font-size: 12px;
  color: var(--muted-foreground);
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

/* Converter */
.converter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 8px;
}

.form-group select,
.form-group input {
  width: 100%;
  padding: 12px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input:focus {
  border-color: var(--primary);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.input-wrapper {
  position: relative;
}

.input-wrapper input {
  padding-right: 50px;
}

.input-suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--muted-foreground);
}

/* Direction Toggle */
.direction-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.2s;
}

.direction-toggle:hover {
  background: var(--accent);
  color: var(--foreground);
  transform: scale(1.05);
}

.direction-toggle:active {
  transform: scale(0.95);
}

/* Result Box */
.result-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#converter-result {
  font-size: 20px;
  font-weight: 600;
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
}

.result-suffix {
  font-size: 12px;
  color: var(--muted-foreground);
}

/* Rate Info */
.rate-info {
  margin-top: 16px;
  padding: 12px;
  background: var(--muted);
  border-radius: var(--radius);
}

.rate-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.rate-row span:first-child {
  color: var(--muted-foreground);
}

.rate-row span:last-child {
  font-weight: 500;
  color: var(--foreground);
}

.rate-update {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted-foreground);
}

/* Footer */
.footer {
  padding: 10px 16px;
  text-align: center;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted-foreground);
}

.footer a {
  color: var(--foreground);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer a:hover {
  text-decoration: none;
}

/* Scrollbar */
.tab-content::-webkit-scrollbar {
  width: 6px;
}

.tab-content::-webkit-scrollbar-track {
  background: transparent;
}

.tab-content::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 3px;
}

.tab-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
