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

:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;
  --color-success: #16a34a;
  --color-warning: #f59e0b;
  --color-error: #dc2626;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.06);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Scroll Content ===== */
.scroll-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ===== Header ===== */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 20px;
  text-align: center;
  flex-shrink: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
}

.header-logo {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  text-decoration: none;
}

.header-logo img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.header-logo:hover img {
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
}

.header-text {
  flex: 1;
  text-align: center;
}

.site-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

.site-header p {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* ===== Language Switcher ===== */
.lang-switcher {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.lang-switcher-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
  overflow: hidden;
}

.lang-switcher-btn:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: scale(1.05);
}

.lang-switcher-btn:active {
  transform: scale(0.95);
}

.lang-switcher-btn img {
  border-radius: 2px;
  object-fit: cover;
  pointer-events: none;
}

.lang-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 220px;
  max-height: 420px;
  overflow-y: auto;
  padding: 6px 0;
  animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lang-dropdown.open {
  display: block;
}

/* Scrollbar styling for dropdown */
.lang-dropdown::-webkit-scrollbar {
  width: 6px;
}
.lang-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.lang-dropdown::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-size: 0.875rem;
  color: var(--color-text);
  transition: background var(--transition);
  text-align: left;
}

[dir="rtl"] .lang-option {
  text-align: right;
}

.lang-option:hover {
  background: var(--color-bg);
}

.lang-option.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-primary);
  font-weight: 600;
}

.lang-option.active::after {
  content: '\2713';
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--color-primary);
}

[dir="rtl"] .lang-option.active::after {
  margin-left: 0;
  margin-right: auto;
}

.lang-flag {
  border-radius: 2px;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.lang-name {
  white-space: nowrap;
}

/* ===== Main Layout (3-column grid) ===== */
.main-layout {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  min-height: 0;
}

.converter-main {
  min-width: 0;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 16px 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  z-index: 100;
}

/* ===== Common Components ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

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

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover {
  opacity: 0.9;
}

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

.btn-outline:hover {
  background: var(--color-primary);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ===== Responsive ===== */

/* Tablet and below */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 10px;
  }

  .site-footer {
    padding-bottom: 70px; /* Space for fixed bottom ad */
  }
}

/* Mobile */
@media (max-width: 640px) {
  .site-header h1 {
    font-size: 1.25rem;
  }

  .site-header p {
    font-size: 0.8rem;
  }

  .lang-switcher-btn {
    width: 36px;
    height: 36px;
  }

  .lang-switcher-btn img {
    width: 22px !important;
    height: 16px !important;
  }

  .lang-dropdown {
    min-width: 190px;
    right: -8px;
  }
}
