/* =====================================================================
   سامانه پروژه مهر — سیستم طراحی (Design System)
   ===================================================================== */

:root{
  --primary:        #4f46e5;
  --primary-dark:    #3730a3;
  --primary-light:  #eef2ff;
  --secondary:      #0ea5e9;
  --success:        #10b981;
  --success-light:  #d1fae5;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --danger:         #ef4444;
  --danger-light:   #fee2e2;
  --info:           #8b5cf6;
  --info-light:     #ede9fe;

  --bg:             #f3f4fb;
  --surface:        #ffffff;
  --border:         #e6e8f0;
  --text:           #1e2130;
  --text-muted:     #6b7280;

  --sidebar-w:      270px;
  --topbar-h:       68px;
  --radius:         16px;
  --radius-sm:      10px;
  --shadow-sm:      0 1px 3px rgba(30,33,48,.06), 0 1px 2px rgba(30,33,48,.04);
  --shadow-md:      0 8px 24px rgba(30,33,48,.08);
  --shadow-lg:      0 16px 40px rgba(30,33,48,.14);
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
}

body{
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 14.5px;
}

a{ text-decoration: none; }

/* ===================== ساختار کلی ===================== */

.app-shell{
  display: flex;
  min-height: 100vh;
}

.sidebar{
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(200deg, #201c4e 0%, #362f8a 55%, #4f46e5 100%);
  color: #eceafd;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 1030;
  padding: 22px 16px;
  transition: transform .25s ease;
}

.sidebar-brand{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 18px;
}

.sidebar-brand .logo-badge{
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.sidebar-brand .brand-text strong{
  display: block;
  font-size: 15.5px;
  color: #fff;
}
.sidebar-brand .brand-text span{
  font-size: 11.5px;
  color: #c7c3f7;
}

.nav-section-title{
  font-size: 11px;
  color: #a9a3ee;
  letter-spacing: .04em;
  padding: 14px 12px 6px;
}

.sidebar .nav-link{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #d9d6f9;
  font-size: 13.8px;
  margin-bottom: 3px;
  transition: background .15s ease, color .15s ease;
}

.sidebar .nav-link i{
  font-size: 17px;
  width: 20px;
  text-align: center;
}

.sidebar .nav-link:hover{
  background: rgba(255,255,255,.08);
  color: #fff;
}

.sidebar .nav-link.active{
  background: rgba(255,255,255,.16);
  color: #fff;
  box-shadow: inset 3px 0 0 #fff;
}

.sidebar .nav-badge{
  margin-right: auto;
  background: rgba(255,255,255,.18);
  border-radius: 20px;
  font-size: 10.5px;
  padding: 1px 8px;
}

.main-wrap{
  margin-right: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar{
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar .page-title{
  font-size: 17px;
  font-weight: 700;
}
.topbar .page-title small{
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-user{
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-circle{
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.role-chip{
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.content{
  padding: 26px;
  flex: 1;
}

/* ===================== کارت‌ها ===================== */

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

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

.card-body-clean{
  padding: 22px;
}

.stat-card{
  border-radius: var(--radius);
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover{
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-icon{
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-value{
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}
.stat-label{
  font-size: 12.5px;
  color: var(--text-muted);
}

.bg-tint-primary{ background: var(--primary-light); color: var(--primary); }
.bg-tint-success{ background: var(--success-light); color: var(--success); }
.bg-tint-warning{ background: var(--warning-light); color: #b45309; }
.bg-tint-danger { background: var(--danger-light);  color: var(--danger); }
.bg-tint-info   { background: var(--info-light);    color: var(--info); }
.bg-tint-secondary{ background: #e0f2fe; color: var(--secondary); }

/* ===================== بج‌های وضعیت ===================== */

.badge-status{
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-status::before{
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-gray  { background:#f1f2f6; color:#6b7280; }
.badge-blue  { background:#dbeafe; color:#1d4ed8; }
.badge-green { background:var(--success-light); color:#047857; }
.badge-red   { background:var(--danger-light); color:#b91c1c; }

.wg-chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ===================== جدول‌ها ===================== */

.table-clean{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table-clean thead th{
  background: #f8f9fd;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-clean tbody td{
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.table-clean tbody tr:last-child td{ border-bottom: none; }
.table-clean tbody tr:hover{ background: #fafbff; }

/* ===================== فرم‌ها و دکمه‌ها ===================== */

.form-label{
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}

.form-control, .form-select{
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 13.8px;
  background: #fbfcff;
}
.form-control:focus, .form-select:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: #fff;
}

.btn{
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 18px;
}
.btn-primary{
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover{
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn-outline-primary{
  color: var(--primary);
  border-color: var(--primary);
}
.btn-soft-danger{
  background: var(--danger-light);
  color: var(--danger);
  border: none;
}
.btn-soft-danger:hover{ background:#fecaca; color:#991b1b; }

/* ===================== صفحه ورود ===================== */

.login-shell{
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.12), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(255,255,255,.10), transparent 40%),
    linear-gradient(135deg, #201c4e 0%, #4338ca 50%, #4f46e5 100%);
  padding: 20px;
}

.login-card{
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 40px 34px;
}

.login-logo{
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}

/* ===================== نوار پیشرفت و مقایسه ===================== */

.progress{
  height: 9px;
  border-radius: 20px;
  background: #eef0f8;
}
.progress-bar{
  border-radius: 20px;
}

.county-rank-row{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.county-rank-row:last-child{ border-bottom: none; }

.rank-number{
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12.5px;
  flex-shrink: 0;
}

/* ===================== واکنش‌گرا ===================== */

.sidebar-toggle-btn{ display: none; }

@media (max-width: 991px){
  .sidebar{
    transform: translateX(105%);
  }
  .sidebar.open{
    transform: translateX(0);
  }
  .main-wrap{
    margin-right: 0;
  }
  .sidebar-toggle-btn{ display: inline-flex; }
}

.alert-flash{
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13.5px;
  padding: 13px 18px;
}

.empty-state{
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i{
  font-size: 40px;
  color: #d1d5db;
  margin-bottom: 12px;
  display: block;
}
