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

:root {
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-bg: #ffffff;
  --color-bg-alt: #f9fafb;
  --color-border: #e5e7eb;
  --font-sans: 'Segoe UI', system-ui, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===== Nav ===== */
header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

nav ul a {
  color: var(--color-text);
  font-weight: 500;
}

nav ul a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

/* ===== Hero ===== */
.hero {
  max-width: 1100px;
  margin: 5rem auto;
  padding: 0 1.5rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.125rem;
  color: var(--color-text-light);
  margin-bottom: 2rem;
}

/* ===== Button ===== */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  transition: background 0.2s;
}

button:hover {
  background: var(--color-primary-dark);
}

/* ===== Rates Section ===== */
.rates-section {
  background: var(--color-bg-alt);
  padding: 4rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

.rates-container {
  max-width: 1100px;
  margin: 0 auto;
}

.rates-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rates-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
}

.rates-updated {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.rates-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tab-btn {
  background: transparent;
  color: var(--color-text-light);
  border: 1px solid var(--color-border);
  padding: 0.45rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 999px;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.tab-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.tab-panel {
  display: none;
}

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

.rates-base {
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-bottom: 1rem;
}

.rates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.rate-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rate-card .rate-symbol {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rate-card .rate-name {
  font-size: 0.78rem;
  color: var(--color-text-light);
}

.rate-card .rate-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 0.25rem;
}

.rate-card.skeleton {
  min-height: 96px;
  animation: pulse 1.4s ease-in-out infinite;
}

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

.rates-error {
  text-align: center;
  color: #dc2626;
  font-size: 0.9rem;
  margin-top: 1rem;
}

.rates-source {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--color-text-light);
  text-align: right;
}

.hidden {
  display: none !important;
}

/* ===== Chat Widget ===== */
.chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.45);
  transition: background 0.2s, transform 0.2s;
}

.chat-toggle:hover {
  background: var(--color-primary-dark);
  transform: scale(1.07);
}

.chat-icon-close {
  display: none;
}

.chat-widget.open .chat-icon-open {
  display: none;
}

.chat-widget.open .chat-icon-close {
  display: block;
}

.chat-panel {
  width: 320px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  display: none;
  flex-direction: column;
  overflow: hidden;
  max-height: 440px;
}

.chat-widget.open .chat-panel {
  display: flex;
}

.chat-header {
  background: var(--color-primary);
  color: #fff;
  padding: 0.85rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 400;
  opacity: 0.9;
}

.chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-msg {
  max-width: 80%;
  font-size: 0.875rem;
  line-height: 1.45;
}

.chat-msg p {
  padding: 0.55rem 0.85rem;
  border-radius: 16px;
  margin: 0;
}

.chat-msg--received {
  align-self: flex-start;
}

.chat-msg--received p {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.chat-msg--sent {
  align-self: flex-end;
}

.chat-msg--sent p {
  background: var(--color-primary);
  color: #fff;
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--color-border);
}

.chat-input {
  flex: 1;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  outline: none;
  background: var(--color-bg-alt);
  color: var(--color-text);
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: var(--color-primary);
}

.chat-send {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: #fff;
  flex-shrink: 0;
}

.chat-send:hover {
  background: var(--color-primary-dark);
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-light);
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
}
