/* THEME VARIABLES */
:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --text: #1f2937;
  --muted: #64748b;
  --border: #e5e7eb;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .06);
  --result-empty-color: #cbd5e1;

}

body {
  background-color: var(--bg);
  color: var(--text);
  transition: background 0.3s ease;
  margin: 0;
}

/* --- Common Settings Styles (Consistent font weight in both themes) --- */
.settings-title {
  font-size: 20px !important;
  font-weight: 850 !important;
}

.settings-section h3 {
  font-size: 13px !important;
  font-weight: 700 !important;
  margin-top: 18px;
  margin-bottom: 10px;
}

/* --- Light Theme Settings (Default/Light) --- */
body:not([data-theme="dark"]) .settings-title {
  color: #0f172a !important;
}

body:not([data-theme="dark"]) .settings-section h3 {
  color: #64748b !important;
}

/* --- Modified Unit Styles in Results (Text to the left of the number) --- */
.value-wrap {
  display: flex;
  align-items: center;
  gap: 0px;
  width: auto !important;   /* اصلاح شده: حذف عرض ثابت پیکسلی */
  flex: 1 !important;       /* اصلاح شده: تصاحب هوشمند فضای باقی‌مانده */
  min-width: 0 !important;   /* اصلاح شده: اجازه به فشرده شدن جهت اعمال سه نقطه */
}

.result-unit {
  color: var(--muted);
  font-weight: normal;
  font-weight: bold !important;
  font-size: 12px !important;
}

.result-box {
  justify-content: space-between;
  display: flex;
  align-items: center;
}


/* Dark Mode Configuration */
body[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f5f5f5;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --border: #334155;
  --result-empty-color: #64748b;
  background-color: var(--bg);
  color: var(--text);
}

/* Inputs and Units (Dark) */
body[data-theme="dark"] .input-wrap {
  background-color: #0f172a;
  border: 1px solid var(--border) !important;
  display: flex;
  align-items: stretch;
  border-radius: 12px;
  overflow: hidden;
  height: 50px;
}

body[data-theme="dark"] .unit {
  background-color: #334155;
  color: var(--muted);
  border-left: 1px solid var(--border) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  min-width: auto !important;
  width: auto !important;
  flex: 0 0 auto;
  white-space: nowrap;
}

/* SVG Arrows in Dark Mode */
body[data-theme="dark"] input[type="number"]::-webkit-inner-spin-button,
body[data-theme="dark"] input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  background: transparent !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 14l5-5 5 5H7z'/%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  width: 20px;
  height: 100%;
  cursor: pointer;
  opacity: 0.7;
  display: block !important;
}

/* Panel Settings (Dark) */
body[data-theme="dark"] .settings-panel {
  background-color: var(--card);
  border-color: var(--border);
}

body[data-theme="dark"] .settings-title {
  color: #ffffff !important;
}

body[data-theme="dark"] .settings-section h3 {
  color: var(--muted) !important;
}

/* App Info Box (Compressed) */
.app-info {
  padding: 2px 10px !important;
  border-radius: 12px;
  border: 1px solid var(--border);
}

body:not([data-theme="dark"]) .app-info {
  background-color: #f8fafc;
}

body[data-theme="dark"] .app-info {
  background-color: #0f172a !important;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0 !important;
}

.info-value {
  margin-left: 10px;
  font-weight: bold;
  font-size: 13px;
}

/* Other Components (Dark) */
body[data-theme="dark"] .result-box {
  background-color: var(--card) !important;
  border: 1px solid var(--border) !important;
}

body[data-theme="dark"] .option-btn {
  background-color: #334155;
  color: var(--text);
  border: 1px solid var(--border);
}

body[data-theme="dark"] .option-btn.active {
  background-color: var(--primary);
  color: #ffffff;
}

body[data-theme="dark"] .card {
  background-color: var(--card);
  border: 1px solid var(--border);
}

body[data-theme="dark"] .form-label,
body[data-theme="dark"] .result-label,
body[data-theme="dark"] .result-title {
  color: var(--muted) !important;
}

/* Aligning inputs with result boxes */
.input-minimal {
  background: transparent !important;
  border: none !important;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  text-align: left;
  width: 100px;
  outline: none;
  padding: 0;
  padding-left: 15px !important;
  text-align: left !important;
}

/* Remove default arrows in browsers for number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Adjust labels to match result boxes */
.form-label {
  font-size: 14px;
  color: var(--muted);
}

.result-box {
  margin-bottom: 12px;
  padding: 15px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Dark mode text color for inputs */
body[data-theme="dark"] .input-minimal {
  color: #ffffff;
}

/* Unifying all input and result boxes */


/* Input styles */
.input-minimal {
  background: transparent !important;
  border: none !important;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  text-align: left;
  width: 120px;
  outline: none;
  padding: 0;
}

/* Remove automatic browser blue color */
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0px 1000px var(--card) inset !important;
  -webkit-text-fill-color: var(--text) !important;
}

/* Dark mode consistency */
body[data-theme="dark"] .card .result-box {
  background-color: var(--card) !important;
  border-color: var(--border) !important;
}

/* Aligning input values from the left */
.result-box .value-wrap {
  display: flex !important;
  justify-content: flex-end !important;
  gap: 0px !important;
}

.input-minimal {
  width: 100% !important;
  text-align: left !important;
  padding-left: 0 !important;
}

.result-unit {
  min-width: 35px !important;
  text-align: left !important;
  font-weight: bold !important;
}

/* Fixing input text position in both themes */
.input-minimal,
body[data-theme="dark"] .input-minimal {
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  text-align: left !important;
  direction: ltr;
}

/* Placeholder Style */
.input-minimal::placeholder {
  color: #cbd5e1;
  opacity: 1;
  font-weight: 500;
}

/* Dark Mode Placeholder */
body[data-theme="dark"] .input-minimal::placeholder {
  color: #64748b;
  opacity: 1;
}

.option-btn {
  border: 1px solid transparent !important;
}

/* =========================================================
   FONT SIZE SYSTEM
========================================================= */

/* SMALL */
html[data-font="small"] {
  font-size: 13px;
}

/* MEDIUM */
html[data-font="medium"] {
  font-size: 16px;
}

/* LARGE */
html[data-font="large"] {
  font-size: 18px;
}

/* =========================================================
   GLOBAL SCALE
========================================================= */
body {
  font-size: 1rem;
}

h1 {
  font-size: 1.7rem !important;
}

.hero-value {
  font-size: 1.5rem !important;
}

/* اصلاح شده: هم‌تراز کردن دقیق عرض لیبل‌ها در بخش فرم و نتایج */
.form-label,
.result-label {
  font-size: 0.95rem !important;
  width: 30% !important;     /* تخصیص عرض یکسان جهت ایجاد تراز عمودی */
  flex-shrink: 0 !important; /* جلوگیری از مچاله شدن متن لیبل در موبایل */
  white-space: nowrap;
}

.result-title {
  font-size: 1rem !important;
}

.input-minimal {
  font-size: 1rem !important;
}

.input-minimal, .result-value {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  direction: ltr;
}

/* اصلاح شده: تبدیل عرض ثابت به ۱۰۰٪ پویا */
.result-value {
  font-size: 1rem !important;
  width: 100% !important;     /* حذف ۱۸۵ پیکسل ثابت برای باز شدن فضا در موبایل */
  text-align: left !important;
}

.primary-btn,
.secondary-btn,
.install-link,
.option-btn {
  font-size: 0.95rem !important;
}

.settings-title {
  font-size: 1.25rem !important;
}

.settings-section h3 {
  font-size: 0.9rem !important;
}

.info-label,
.info-value {
  font-size: 0.9rem !important;
}