/* ===== СБРОС И БАЗОВЫЕ СТИЛИ ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0a0a;
  color: #ffffff;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== ШАПКА ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem 1rem;
  background: #111;
  border-bottom: 1px solid #222;
  position: relative;
}

.logo {
  height: 120px;
  padding: 4px;
}

.logo img {
  height: 100%;
  width: auto;
  object-fit: contain;
  border: 2px solid #333;
  border-radius: 12px;
  padding: 6px;
}

/* ===== БУРГЕР-КНОПКА ===== */
.burger-btn {
  position: absolute;
  left: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 2px solid #333;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color 0.2s;
  z-index: 1001;
}

.burger-btn:hover {
  border-color: #00d2ff;
}

.burger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: #888;
  border-radius: 2px;
  transition: all 0.3s;
}

.burger-btn:hover span {
  background: #00d2ff;
}

.burger-btn.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
  background: #00d2ff;
}

.burger-btn.open span:nth-child(2) {
  opacity: 0;
}

.burger-btn.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
  background: #00d2ff;
}

/* ===== БОКОВОЕ МЕНЮ ===== */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
}

.sidebar {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100%;
  background: #111;
  border-right: 1px solid #222;
  z-index: 1000;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
  padding-top: 1rem;
}

.sidebar.open {
  left: 0;
}

.sidebar-header {
  padding: 1rem 1.5rem 1.5rem;
  border-bottom: 1px solid #222;
  text-align: center;
}

.sidebar-header .mini-logo {
  height: 60px;
}

.sidebar-header .mini-logo img {
  height: 100%;
  width: auto;
  object-fit: contain;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 4px;
}

.sidebar-menu {
  flex: 1;
  padding: 1rem 0;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  color: #888;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  color: #fff;
  background: #1a1a1a;
}

.menu-item.active {
  color: #00d2ff;
  border-left-color: #00d2ff;
  background: #1a2a3a;
}

.menu-item .icon {
  font-size: 1.3rem;
  width: 28px;
  text-align: center;
}

.menu-divider {
  height: 1px;
  background: #222;
  margin: 0.5rem 1.5rem;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #222;
  font-size: 0.75rem;
  color: #444;
  text-align: center;
}

/* ===== ПОЛОСА ВАЛЮТ ===== */
.currency-bar {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  padding: 1rem 1.5rem;
  overflow-x: auto;
  background: #111;
  border-bottom: 1px solid #222;
  scrollbar-width: none;
}

.currency-bar::-webkit-scrollbar {
  display: none;
}

.currency-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  background: #1a1a1a;
  border-radius: 10px;
  border: 2px solid #333;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 72px;
  flex-shrink: 0;
}

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

.currency-card.active {
  border-color: #00d2ff;
  background: #1a2a3a;
}

.currency-card img {
  width: 40px;
  height: 30px;
  border-radius: 3px;
  object-fit: cover;
}

.currency-card span {
  font-weight: 600;
  font-size: 0.75rem;
  color: #999;
}

.currency-card.active span {
  color: #00d2ff;
}

/* ===== ВЕРХНЯЯ ЧАСТЬ КАЛЬКУЛЯТОРА ===== */
.calc-top {
  max-width: 480px;
  margin: 2rem auto 0;
  padding: 0 1.5rem;
}

.direction-tabs {
  display: flex;
  background: #1a1a1a;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 1.5rem;
  border: 1px solid #333;
}

.dir-tab {
  flex: 1;
  padding: 0.7rem 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: #888;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.dir-tab:hover {
  color: #ccc;
}

.dir-tab.active {
  background: linear-gradient(135deg, #00d2ff, #7b2ff7);
  color: #fff;
  font-weight: 600;
}

/* ===== ОБЩАЯ ОБЛАСТЬ РАСЧЁТА ===== */
.calc-wrapper {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.calc-frame {
  border: 2px solid #333;
  border-radius: 14px;
  padding: 1rem 1.2rem 1.5rem;
  margin-top: 0.5rem;
  background: #0a0a0a;
  position: relative;
  transition: all 0.3s;
}

.calc-frame.has-result {
  border-color: transparent;
  background-image: linear-gradient(#0a0a0a, #0a0a0a), linear-gradient(135deg, #00d2ff, #7b2ff7);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.calc-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
}

.calc-frame-label {
  font-size: 0.7rem;
  color: #555;
  font-weight: 400;
  padding-left: 0.2rem;
  transition: color 0.3s;
}

.calc-frame.has-result .calc-frame-label {
  background: linear-gradient(135deg, #00d2ff, #7b2ff7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.calc-field {
  border: 1px solid #333;
  border-radius: 10px;
  padding: 1rem;
  background: #0a0a0a;
  transition: all 0.3s;
}

.calc-frame.has-result .calc-field {
  border-color: transparent;
  background-image: linear-gradient(#0a0a0a, #0a0a0a), linear-gradient(135deg, #00d2ff, #7b2ff7);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.calc-field-label {
  font-size: 0.75rem;
  color: #666;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-right: 0.2rem;
  transition: color 0.3s;
}

.calc-field-label-standalone {
  text-align: right;
  margin-bottom: 0.4rem;
}

.calc-frame.has-result .calc-field-label {
  background: linear-gradient(135deg, #00d2ff, #7b2ff7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.give-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.give-input-wrap input {
  flex: 1;
  font-size: 1.5rem;
  font-weight: 600;
  background: transparent;
  border: none;
  color: #fff;
  outline: none;
  min-width: 0;
}

.give-input-wrap input::placeholder {
  color: #444;
}

.give-input-wrap .suffix {
  font-size: 1rem;
  color: #666;
  font-weight: 600;
  flex-shrink: 0;
}

.calc-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1rem 0;
}

.calc-arrow svg {
  color: #555;
  transition: color 0.3s;
}

.calc-frame.has-result .calc-arrow svg {
  color: #00d2ff;
  filter: drop-shadow(0 0 8px rgba(0, 210, 255, 0.4)) drop-shadow(0 0 16px rgba(123, 47, 247, 0.3));
}

/* ===== КНОПКИ ДЕЙСТВИЙ ===== */
.action-buttons {
  position: absolute;
  right: -60px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.action-buttons.visible {
  opacity: 1;
  visibility: visible;
}

.action-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid #333;
  background: #1a1a1a;
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.action-btn:hover {
  border-color: #00d2ff;
  color: #00d2ff;
  transform: scale(1.05);
}

.action-btn.copied {
  border-color: #00ff88;
  color: #00ff88;
}

.action-btn .tooltip {
  position: absolute;
  right: 54px;
  background: #222;
  color: #ccc;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.action-btn:hover .tooltip {
  opacity: 1;
}

/* ===== АДАПТИВ ===== */
@media (max-width: 620px) {
  .action-buttons {
    position: static;
    transform: none;
    flex-direction: row;
    justify-content: center;
    margin-top: 1rem;
  }

  .action-btn .tooltip {
    display: none;
  }
}

@media (max-width: 480px) {
  .logo {
    height: 100px;
  }

  .burger-btn {
    left: 0.8rem;
    padding: 8px;
  }

  .calc-top {
    margin: 1rem auto 0;
  }

  .give-input-wrap input {
    font-size: 1.2rem;
  }

  .dir-tab {
    font-size: 0.75rem;
    padding: 0.6rem 0.3rem;
  }
}

/* ===== МОДАЛЬНОЕ ОКНО АВТОРИЗАЦИИ ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #111;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 2rem;
  width: 90%;
  max-width: 360px;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #00d2ff, #7b2ff7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-field {
  margin-bottom: 1rem;
}

.modal-field label {
  display: block;
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.modal-field input {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 10px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.modal-field input:focus {
  border-color: #00d2ff;
}

.modal-field input::placeholder {
  color: #444;
}

.modal-error {
  color: #ff4444;
  font-size: 0.8rem;
  text-align: center;
  min-height: 1.2rem;
  margin-bottom: 0.5rem;
}

.modal-btn {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  background: linear-gradient(135deg, #00d2ff, #7b2ff7);
  color: #fff;
}

.modal-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  background: none;
  border: none;
  color: #555;
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
}

.modal-close:hover {
  color: #ff4444;
}

.modal {
  position: relative;
}

/* ===== ПАНЕЛЬ ФОРМУЛЫ (только admin) ===== */
.formula-panel {
  max-width: 480px;
  margin: 1rem auto 0;
  padding: 0 1.5rem;
  display: none;
}

.formula-panel.visible {
  display: block;
}

.formula-box {
  border: 1px solid #333;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  background: #111;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #888;
  word-break: break-all;
  line-height: 1.5;
  position: relative;
}

.formula-box::before {
  content: 'ФОРМУЛА';
  position: absolute;
  top: -0.55rem;
  left: 0.8rem;
  background: #111;
  padding: 0 0.4rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.6rem;
  color: #555;
  letter-spacing: 0.1em;
}

.formula-box.has-formula {
  border-color: #7b2ff7;
}

.formula-box.has-formula::before {
  color: #7b2ff7;
}

.formula-text {
  color: #b388ff;
}

/* ===== АДМИН-ПАНЕЛЬ ===== */
.admin-panel {
  max-width: 480px;
  margin: 1rem auto;
  padding: 0 1rem;
}

.admin-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #333;
}

.admin-fiat-name {
  color: #b388ff;
}

.admin-fiat-flag {
  width: 28px;
  height: 20px;
  border-radius: 3px;
  object-fit: cover;
}

/* Секции */
.admin-section {
  margin-bottom: 1rem;
}

.admin-section-title {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #222;
}

/* Строки */
.admin-row {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
}

.admin-row.single {
  max-width: calc(50% - 0.4rem);
}

/* Fieldset-стиль (заголовок на рамке) */
.admin-fieldset {
  flex: 1;
  position: relative;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0;
  min-width: 0;
}

.admin-fieldset-label {
  position: absolute;
  top: -0.5em;
  left: 0.7rem;
  background: #000;
  padding: 0 0.4rem;
  font-size: 0.6rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  z-index: 1;
  transition: color 0.2s;
}

/* Заголовок при фокусе — цвет рамки */
.admin-fieldset:focus-within .admin-fieldset-label {
  color: #7b2ff7;
}

/* Заголовок при изменении — оранжевый */
.admin-fieldset.changed .admin-fieldset-label {
  color: #ff9800;
}

.admin-fieldset input {
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  padding-top: 0.8rem;
  color: #fff;
  font-size: 0.95rem;
  font-family: 'Courier New', monospace;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.admin-fieldset input[readonly] {
  color: #555;
  cursor: default;
}

.admin-fieldset input.changed {
  color: #ff9800;
}

.admin-fieldset.changed {
  border-color: #ff9800;
  background: #1a1400;
}

.admin-fieldset:focus-within {
  border-color: #ffb74d;
}

.admin-fieldset:focus-within .admin-fieldset-label {
  color: #ffb74d;
}

.admin-fieldset.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Переключатель Ручной / Авто */
.admin-mode-tabs {
  display: flex;
  background: #111;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #333;
}

.admin-mode-tab {
  flex: 1;
  text-align: center;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: all 0.3s;
  user-select: none;
}

.admin-mode-tab.active {
  background: #7b2ff7;
  color: #fff;
}

/* Активные поля режима — оранжевый акцент */
.admin-fieldset.mode-active {
  border-color: #ff9800;
}

.admin-fieldset.mode-active .admin-fieldset-label {
  color: #ff9800;
}

.admin-fieldset.mode-active input {
  color: #fff;
}

/* Неактивные поля режима — бледно-оранжевые */
.admin-fieldset.mode-dimmed {
  border-color: #4a3000;
  pointer-events: none;
}

.admin-fieldset.mode-dimmed .admin-fieldset-label {
  color: #4a3000;
}

.admin-fieldset.mode-dimmed input {
  color: #5a4010;
}

/* Кнопка сохранения */
.admin-save-wrap {
  margin-top: 1.5rem;
  text-align: center;
}

.admin-save-btn {
  background: #333;
  color: #555;
  border: none;
  border-radius: 10px;
  padding: 0.8rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: not-allowed;
  transition: all 0.3s;
}

.admin-save-btn.active {
  background: #7b2ff7;
  color: #fff;
  cursor: pointer;
}

.admin-save-btn.active:hover {
  background: #6a1fe0;
}

.admin-save-status {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #888;
  min-height: 1.2em;
}

.admin-save-status.success {
  color: #4caf50;
}

.admin-save-status.error {
  color: #f44336;
}
