/* ==========================================================================
   TabloTala - Admin Dashboard Stylesheet (Light Theme)
   استایل تم روشن پنل مدیریت تابلوی طلا و ارز
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

/* ==========================================================================
   Admin Typography Definitions (cinema برای عناوین، kalame برای بقیه)
   ========================================================================== */
@font-face {
  font-family: 'cinema';
  src: url('../fonts/Cinema.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cinema';
  src: url('../fonts/Cinema.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'kalame';
  src: url('../fonts/Kalameh-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'kalame';
  src: url('../fonts/Kalameh-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'kalame';
  src: url('../fonts/Kalameh-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'kalame';
  src: url('../fonts/Kalameh-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kalameh';
  src: url('../fonts/Kalameh-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kalameh';
  src: url('../fonts/Kalameh-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kalameh';
  src: url('../fonts/Kalameh-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kalameh';
  src: url('../fonts/Kalameh-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-title: 'kalame', 'Kalameh', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'kalame', 'Kalameh', -apple-system, BlinkMacSystemFont, sans-serif;

  --admin-bg: #f4f6fa;
  --admin-surface: #ffffff;
  --admin-surface-light: #f8fafc;
  --admin-border: #e2e8f0;
  --admin-border-focus: #c59b27;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --gold-primary: #d4af37;
  --gold-secondary: #b38728;
  --gold-dark: #8c6817;
  --gold-light: #fef9c3;
  --gold-border: #fde047;

  --green-gain: #15803d;
  --green-gain-bg: #dcfce7;
  --red-loss: #b91c1c;
  --red-loss-bg: #fee2e2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--admin-bg);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.6;
}

/* عناوین پنل ادمین */
h1, h2, h3, h4, h5, h6,
.section-title,
.admin-card-title,
.admin-title-area h1,
.modal-header h2 {
  font-family: var(--font-title) !important;
  letter-spacing: normal !important;
}

/* سایر متون و دکمه‌های اعلام قیمت و تنظیمات */
button,
input,
select,
textarea,
.btn-primary-gold,
.btn-secondary,
.spread-mode-btn,
.btn-trend,
.price-unit,
.preview-row,
.admin-card,
.stat-pill {
  font-family: var(--font-body) !important;
  letter-spacing: normal !important;
}

.admin-wrapper {
  max-width: 1350px;
  margin: 0 auto;
  padding: 20px 20px 80px 20px;
}

/* Header */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.admin-title-area {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.admin-title-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #d4af37, #b38728);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #121008;
  box-shadow: 0 3px 10px rgba(180, 140, 39, 0.25);
}

.admin-title-area h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
}

.admin-title-area p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.admin-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-header-actions .btn-secondary,
.admin-header-actions .btn-primary-gold {
  white-space: nowrap;
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--admin-border);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-primary-gold {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #d4af37, #b38728);
  border: none;
  color: #121008;
  padding: 9px 20px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 12px var(--gold-glow);
  transition: all 0.2s ease;
}

.btn-primary-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(180, 140, 39, 0.35);
}

/* Smart Calculation Bar */
.smart-toolbar {
  background: #fffdf5;
  border: 1.5px solid #fef3c7;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.toolbar-desc {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-desc svg {
  color: var(--gold-main);
  flex-shrink: 0;
}

.toolbar-desc strong {
  color: #0f172a;
  font-size: 0.95rem;
}

.toolbar-desc p {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  border: 1px solid #94a3b8;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--gold-main);
  border-color: var(--gold-main);
}

input:checked + .slider:before {
  transform: translateX(22px);
  background-color: #ffffff;
}

/* Main Admin Sections Grid */
.admin-section {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--admin-border);
}

.admin-section-header h2 {
  font-size: 1.12rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-section-header h2 span.section-icon {
  color: var(--gold-main);
}

/* Item Edit Cards Grid */
.items-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}

.item-edit-card {
  background: #ffffff;
  border: 1.5px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  transition: border-color 0.2s ease;
  position: relative;
}

.item-edit-card:hover {
  border-color: rgba(180, 140, 39, 0.4);
}

.item-edit-card.featured-card {
  border-color: #fde68a;
  background: #fffefb;
}

.item-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.item-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-badge-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-main);
  font-weight: 800;
}

.item-title-box h3 {
  font-size: 1.02rem;
  font-weight: 800;
  color: #0f172a;
}

.item-category-tag {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Form Group inside Card */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
  display: flex;
  justify-content: space-between;
}

.input-with-affix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-affix input {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid var(--admin-border);
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 800;
  font-family: inherit;
  padding: 8px 12px;
  padding-left: 55px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
  font-variant-numeric: tabular-nums;
}

.input-with-affix input:focus {
  border-color: var(--gold-main);
  box-shadow: 0 0 0 2px rgba(180, 140, 39, 0.15);
}

.input-affix-label {
  position: absolute;
  left: 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  pointer-events: none;
  font-weight: 600;
}

/* Locked Base Price Inputs (غیرقابل ویرایش دستی توسط کاربر) */
.input-with-affix input.ref-locked,
.input-with-affix input[readonly] {
  background: #f8fafc !important;
  color: #334155 !important;
  border-color: #cbd5e1 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  border-style: dashed !important;
}

.ref-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Spread Mode Selector Pills */
.spread-mode-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--admin-border);
}

.spread-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.spread-mode-btn.active {
  background: #ffffff;
  color: var(--gold-main);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Auto-calculated Buy & Sell Price Result Box */
.calculated-preview-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.preview-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-item span {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 600;
}

.preview-item.sell-preview strong {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.preview-item.buy-preview strong {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--color-success);
  font-variant-numeric: tabular-nums;
}

.calculated-buy-box {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.buy-box-label {
  font-size: 0.8rem;
  color: #047857;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}

.buy-box-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: #047857;
  font-variant-numeric: tabular-nums;
}

/* Trend Selector */
.trend-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.trend-buttons {
  display: flex;
  gap: 5px;
}

.btn-trend {
  border: 1px solid var(--admin-border);
  background: #f8fafc;
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.btn-trend.active[data-trend="up"] {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.btn-trend.active[data-trend="down"] {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.btn-trend.active[data-trend="flat"] {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}

/* Ticker & Notice Section */
.notice-form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.textarea-custom {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid var(--admin-border);
  color: #0f172a;
  font-size: 0.95rem;
  font-family: inherit;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  outline: none;
  min-height: 80px;
  resize: vertical;
}

.textarea-custom:focus {
  border-color: var(--gold-main);
  box-shadow: 0 0 0 2px rgba(180, 140, 39, 0.15);
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider-group input[type="range"] {
  flex: 1;
  accent-color: var(--gold-main);
}

/* Toast Notification */
.toast-notice {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  border: 1px solid var(--gold-main);
  color: #ffffff;
  padding: 10px 24px;
  border-radius: 30px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  z-index: 1000;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Fixed Bottom Action Bar */
.bottom-floating-bar {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--admin-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 99;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04);
}

@media (max-width: 768px) {
  .items-edit-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Admin Authentication Gate (محافظت ورود به پنل با رمز عبور)
   ========================================================================== */
.admin-wrapper.auth-locked {
  display: none !important;
}

.bottom-floating-bar.auth-locked {
  display: none !important;
}

#adminAuthGate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  backdrop-filter: blur(16px);
}

.auth-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(212, 175, 55, 0.4);
  text-align: center;
  position: relative;
  animation: authCardFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardFadeIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.auth-icon-circle {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid #f59e0b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px auto;
  color: #b45309;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.25);
}

.auth-card h2 {
  font-family: 'cinema', 'kalame', sans-serif;
  font-size: 1.45rem;
  color: #0f172a;
  margin-bottom: 8px;
}

.auth-card p {
  color: #64748b;
  font-size: 0.95rem;
  margin-bottom: 24px;
  line-height: 1.5;
}

.auth-input-group {
  position: relative;
  margin-bottom: 18px;
  text-align: right;
}

.auth-input-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 8px;
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input {
  width: 100%;
  padding: 13px 44px 13px 14px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  font-size: 1.05rem;
  font-family: 'kalame', -apple-system, sans-serif;
  direction: ltr;
  text-align: left;
  outline: none;
  transition: all 0.2s;
  background: #f8fafc;
  color: #0f172a;
}

.auth-input:focus {
  border-color: #d4af37;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.18);
}

.auth-toggle-pwd {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.auth-toggle-pwd:hover {
  color: #0f172a;
}

.auth-error {
  display: none;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: right;
}

.auth-error.show {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: authShake 0.35s ease-in-out;
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.auth-submit-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #d4af37, #b38728);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: 'kalame', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(179, 135, 40, 0.35);
}

.auth-submit-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(179, 135, 40, 0.45);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  color: #64748b;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.auth-back-link:hover {
  color: #0f172a;
}

