/* =========================
   Fonts
========================= */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --bg-body: #f4f7fe;
  --card-bg: #ffffff;
  --primary: #4318ff;
  --success: #05cd99;
  --danger: #ee5d50;
  --warning: #ffb547;
  --text-main: #1b2559;
  --text-sec: #a3aed0;
  --border: #edf2f7;
}

* {
  box-sizing: border-box;
}

/* اعمال فونت روی همه المان‌های اصلی */
html,
body,
button,
input,
select,
textarea,
option,
table,
th,
td,
a,
span,
div,
p,
h1,
h2,
h3,
h4,
h5,
h6,
label {
  font-family: "Vazirmatn", "Tahoma", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  direction: rtl;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 20px;
  line-height: 1.7;
}

/* اعداد جدولی برای قیمت‌ها */
table,
.mono,
.badge,
.status-tag,
.stat-box .value,
.btn,
input,
select,
textarea {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

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

/* Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: var(--card-bg);
  padding: 20px 30px;
  border-radius: 20px;
  margin-bottom: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.logo {
  font-size: 32px;
}

.titles h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.titles p {
  margin: 0;
  color: var(--text-sec);
  font-size: 13px;
  font-weight: 500;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.pulse-orange {
  background: rgba(255, 181, 71, 0.16);
  color: #d97706;
}

.pulse-green {
  background: rgba(5, 205, 153, 0.14);
  color: #059669;
}

/* Stats */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-box {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.02);
}

.stat-box .label {
  color: var(--text-sec);
  font-size: 14px;
  margin-bottom: 5px;
  font-weight: 600;
}

.stat-box .value {
  font-size: 22px;
  font-weight: 800;
}

.success {
  color: var(--success);
}

.warning {
  color: #d97706;
}

/* Card */
.card {
  background: var(--card-bg);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.card-header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  transition: 0.25s ease;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

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

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

.btn-danger {
  background: #fff5f5;
  color: var(--danger);
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 10px;
}

/* Competitors */
.competitors-card {
  margin-bottom: 30px;
}

.competitor-manager {
  padding: 20px 30px 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.competitor-form {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto;
  gap: 14px;
  align-items: end;
}

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

.form-group label {
  font-size: 13px;
  color: var(--text-sec);
  font-weight: 700;
}

.form-group input,
.form-group select {
  width: 100%;
  border: 1px solid #dbe3f0;
  background: #fff;
  color: var(--text-main);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  transition: 0.2s ease;
}

.form-group input::placeholder {
  font-family: "Vazirmatn", "Tahoma", "Segoe UI", sans-serif;
}

.form-group input:focus,
.form-group select:focus {
  border-color: rgba(67, 24, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(67, 24, 255, 0.08);
}

.form-actions {
  display: flex;
  align-items: end;
}

.competitor-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.competitor-product-block {
  background: #f8faff;
  border: 1px solid #edf2f7;
  border-radius: 18px;
  padding: 16px;
}

.competitor-product-block h4 {
  margin: 0 0 14px 0;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 800;
}

.competitor-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.competitor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #edf2f7;
  border-radius: 14px;
  padding: 12px;
}

.competitor-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.competitor-info strong {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
}

.competitor-info a {
  color: #2563eb;
  font-size: 12px;
  text-decoration: none;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.competitor-info a:hover {
  text-decoration: underline;
}

.empty-mini {
  color: #94a3b8;
  font-size: 13px;
  padding: 10px 0;
}

/* Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: right;
  padding: 15px 20px;
  color: var(--text-sec);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 700;
}

td {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: top;
}

.font-bold {
  font-weight: 700;
}

/* قبلاً monospace بود، الان برای هماهنگی فونت اصلی را نگه می‌داریم */
.mono {
  font-family: "Vazirmatn", "Tahoma", "Segoe UI", sans-serif;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.text-blue {
  color: #2563eb;
}

.pos {
  color: var(--success);
  font-weight: 700;
}

.neg {
  color: var(--danger);
  font-weight: 700;
}

.muted {
  color: #94a3b8 !important;
}

.competitor-badge {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.subtle-text {
  margin-top: 4px;
  font-size: 12px;
  color: #94a3b8;
  word-break: break-word;
}

.error-inline {
  color: var(--danger);
}

.status-tag {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-error {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.status-success {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.status-neutral {
  background: rgba(148, 163, 184, 0.15);
  color: #64748b;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* Dots */
.dot {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 5px;
}

.dot-green {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.dot-red {
  background: var(--danger);
}

.dot-gray {
  background: #94a3b8;
}

/* Logs */
.log-toggle {
  cursor: pointer;
  user-select: none;
}

.log-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #1b254b;
  color: #fff;
}

/* برای لاگ‌ها monospace بهتر است */
.terminal {
  height: 300px;
  overflow-y: auto;
  padding: 15px;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New",
    monospace;
  font-size: 12px;
  line-height: 1.8;
  border: 1px solid #2d3748;
  direction: ltr;
  text-align: left;
}

.log-section h4 {
  margin: 10px 15px;
  font-size: 14px;
  color: #c7d2fe;
  font-family: "Vazirmatn", "Tahoma", "Segoe UI", sans-serif;
  direction: rtl;
  text-align: right;
}

.errors .terminal {
  color: #ff8080;
}

.log-row {
  border-bottom: 1px solid #2d3748;
  padding: 4px 0;
}

.error-text {
  color: #fecaca;
}

.empty-state {
  text-align: center;
  padding: 32px;
  color: #94a3b8;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 1100px) {
  .main-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-left {
    justify-content: flex-start;
  }

  .competitor-form {
    grid-template-columns: 1fr 1fr;
  }

  .form-url,
  .form-actions {
    grid-column: span 2;
  }

  .competitor-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  body {
    padding: 12px;
  }

  .main-header,
  .card-header,
  .competitor-manager {
    padding-left: 16px;
    padding-right: 16px;
  }

  .competitor-form {
    grid-template-columns: 1fr;
  }

  .form-url,
  .form-actions {
    grid-column: span 1;
  }

  .log-split {
    grid-template-columns: 1fr;
  }

  td,
  th {
    padding: 12px;
  }
}
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.logout-btn {
  background: #ef4444;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}

.logout-btn:hover {
  background: #dc2626;
  transform: translateY(-1px);
}
.user-profile-section {
  display: flex;
  align-items: center;
  gap: 15px;
  background: #f8fafc;
  padding: 6px 12px;
  border-radius: 50px;
  border: 1px solid #e2e8f0;
}

.user-info-wrapper {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  padding: 4px 8px;
  transition: all 0.3s ease;
}

.user-icon {
  font-style: normal;
  background: #e2e8f0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
}

/* پاپ‌اور (توضیحات نقش) */
.user-details-popover {
  position: absolute;
  top: 130%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1e293b;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

/* مثلث کوچک بالای پاپ‌اور */
.user-details-popover::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #1e293b transparent;
}

/* افکت هاور */
.user-info-wrapper:hover .user-details-popover {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.user-info-wrapper:hover .user-badge {
  color: #2563eb;
}

/* استایل دکمه خروج هماهنگ با طرح جدید */
.logout-btn {
  background: #fee2e2;
  color: #ef4444;
  border: none;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
}

.logout-btn:hover {
  background: #ef4444;
  color: white;
}
/* تنظیم چیدمان بخش چپ هدر */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* کپسول پروفایل کاربر */
.user-profile-capsule {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  padding: 4px 4px 4px 12px;
  border-radius: 50px;
  border: 1px solid #e2e8f0;
  margin-right: 8px;
  position: relative;
}

.user-info-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
}

.user-avatar {
  width: 28px;
  height: 28px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

/* دکمه خروج مینیمال */
.logout-minimal-btn {
  background: #fee2e2;
  color: #ef4444;
  border: none;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.2s;
}

.logout-minimal-btn:hover {
  background: #ef4444;
  color: white;
}

/* تول‌تیپ نقش کاربری */
.user-role-tooltip {
  position: absolute;
  bottom: -35px;
  right: 50%;
  transform: translateX(50%) translateY(10px);
  background: #1e293b;
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.user-info-trigger:hover .user-role-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(50%) translateY(0);
}
* {
  font-family: "Vazirmatn", sans-serif !important;
}
