/* ═══════════════════════════════════════════════════════════════
   دپارتمان املاک شهریار — سامانه مدیریت فایل
   بازطراحی رابط کاربری — الهام‌گرفته از گره‌چینی و کاشی‌کاری ایرانی
   ═══════════════════════════════════════════════════════════════

   نظام طراحی
   رنگ:  --navy زمینه ساختاری (شب کویر) / --gold طلای کاشی گنبد
         --bg گچ‌وگل گرم / --card کاغذ روشن
   تایپ: Vazirmatn در وزن‌های متضاد برای ساخت سلسله‌مراتب
   امضای بصری: ستاره هشت‌پر (شمسه) — الگوی مشترک تمام کاشی‌کاری‌های
         ایرانی — به‌صورت واترمارک، جداکننده و نشانگر در سرتاسر رابط
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  /* ── پالت اصلی ── */
  --navy:        #0c2038;
  --navy-2:      #163f63;
  --navy-3:      #1f5788;
  --gold:        #b7862f;
  --gold-light:  #dcab5c;
  --bg:          #f3efe3;
  --card:        #fffdf7;
  --text:        #221f1a;
  --muted:       #7c7461;
  --red:         #ae4632;
  --green:       #3d7a52;
  --blue:        #2c5c85;
  --border:      #e6ddc8;

  /* ── امضای بصری: شمسه (الگوی هندسی هشت‌پر) ── */
  --star-tile-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpolygon points='20.0,5.0 22.4,14.3 30.6,9.4 25.7,17.6 35.0,20.0 25.7,22.4 30.6,30.6 22.4,25.7 20.0,35.0 17.6,25.7 9.4,30.6 14.3,22.4 5.0,20.0 14.3,17.6 9.4,9.4 17.6,14.3' fill='none' stroke='rgba(255,255,255,0.10)' stroke-width='1'/%3E%3C/svg%3E");
  --star-tile-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpolygon points='20.0,5.0 22.4,14.3 30.6,9.4 25.7,17.6 35.0,20.0 25.7,22.4 30.6,30.6 22.4,25.7 20.0,35.0 17.6,25.7 9.4,30.6 14.3,22.4 5.0,20.0 14.3,17.6 9.4,9.4 17.6,14.3' fill='none' stroke='rgba(12,32,56,0.07)' stroke-width='1'/%3E%3C/svg%3E");
  --star-mark-gold: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpolygon points='60.0,12.0 67.7,41.5 93.9,26.1 78.5,52.3 108.0,60.0 78.5,67.7 93.9,93.9 67.7,78.5 60.0,108.0 52.3,78.5 26.1,93.9 41.5,67.7 12.0,60.0 41.5,52.3 26.1,26.1 52.3,41.5' fill='none' stroke='rgba(183,134,47,0.16)' stroke-width='2.4'/%3E%3C/svg%3E");
  --star-mark-navy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpolygon points='60.0,12.0 67.7,41.5 93.9,26.1 78.5,52.3 108.0,60.0 78.5,67.7 93.9,93.9 67.7,78.5 60.0,108.0 52.3,78.5 26.1,93.9 41.5,67.7 12.0,60.0 41.5,52.3 26.1,26.1 52.3,41.5' fill='none' stroke='rgba(12,32,56,0.05)' stroke-width='2.4'/%3E%3C/svg%3E");

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(23,20,10,.04), 0 8px 24px -10px rgba(23,20,10,.16);
  --shadow-lift: 0 10px 30px -8px rgba(12,32,56,.28);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 100% 0%, rgba(183,134,47,.07), transparent 45%),
    radial-gradient(circle at 0% 100%, rgba(12,32,56,.05), transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.container, .panel-content { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }

::selection { background: var(--gold-light); color: var(--navy); }

:focus-visible {
  outline: 2.5px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ═══════════════════════ نوارهای بالایی ═══════════════════════ */
.topbar, .panel-header {
  background:
    var(--star-tile-light),
    linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 62%, var(--navy-3) 130%);
  background-size: 40px 40px, cover;
  color: #fff;
  padding: 14px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 4px 22px rgba(12,32,56,.35);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--gold);
}

.brand {
  font-weight: 800;
  font-size: 16px;
  display: flex;
  gap: 9px;
  align-items: center;
  letter-spacing: .2px;
}

.badge-admin, .role-badge.role-admin {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: var(--navy);
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 99px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(183,134,47,.35);
}
.badge-agent, .role-badge.role-agent {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 99px;
  font-weight: 800;
}
.role-badge { display: inline-block; }
.user-info { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.user-info span#userName { font-size: 13px; font-weight: 700; }

/* ═══════════════════════════ دکمه‌ها ═══════════════════════════ */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px 17px;
  border-radius: 10px;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease, filter .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: .1px;
}
.btn:active { transform: translateY(1px) scale(.99); }

.btn-gold, .btn-primary {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #fff;
  box-shadow: 0 4px 14px rgba(183,134,47,.4);
}
.btn-gold:hover, .btn-primary:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 6px 18px rgba(183,134,47,.48); }

.btn-ghost { background: rgba(255,255,255,.12); border: 1.5px solid rgba(255,255,255,.38); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.2); }

.btn-dark { background: var(--navy); color: #fff; }
.btn-dark:hover { background: var(--navy-2); }

.btn-success { background: linear-gradient(135deg, #4c9166, var(--green)); color: #fff; box-shadow: 0 3px 10px rgba(61,122,82,.32); }
.btn-danger  { background: linear-gradient(135deg, #c05a45, var(--red)); color: #fff; box-shadow: 0 3px 10px rgba(174,70,50,.3); }
.btn-blue    { background: linear-gradient(135deg, #3a72a1, var(--blue)); color: #fff; box-shadow: 0 3px 10px rgba(44,92,133,.3); }

.btn-outline, .btn-secondary {
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover, .btn-secondary:hover { background: #f8f4e8; border-color: var(--gold-light); }

.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; transform: none !important; }

.seg-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--gold); }

/* ═══════════════════════════ تب‌ها ═══════════════════════════ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border-radius: 15px;
  padding: 5px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
}
.tab {
  flex: 1;
  min-width: 102px;
  padding: 12px 14px;
  border-radius: 11px;
  text-align: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--muted);
  transition: .15s;
  white-space: nowrap;
}
.tab.active {
  background:
    var(--star-tile-light),
    linear-gradient(135deg, var(--navy), var(--navy-2));
  background-size: 40px 40px, cover;
  color: #fff;
  box-shadow: 0 4px 14px rgba(12,32,56,.28);
}
.tab:hover:not(.active) { background: #f3ecd9; color: var(--navy); }

/* ═══════════════════════════ کارت‌ها ═══════════════════════════ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold-light);
  position: relative;
}
.card h2 {
  color: var(--navy);
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 15px;
  padding-bottom: 11px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title {
  color: var(--navy);
  font-size: 13.5px;
  font-weight: 800;
  margin: 22px 0 12px;
  padding: 9px 14px;
  background: linear-gradient(90deg, #fdf6e5, transparent);
  border-radius: 9px;
  border-right: 4px solid var(--gold);
  position: relative;
}
.section-title::after {
  content: '';
  display: inline-block;
  width: 13px; height: 13px;
  margin-inline-start: 6px;
  vertical-align: -2px;
  background-image: var(--star-mark-gold);
  background-size: 200% 200%;
  background-position: center;
  opacity: .9;
}

/* ═══════════════════════════ فرم‌ها ═══════════════════════════ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; }
.form-group { display: flex; flex-direction: column; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: var(--navy); }
.form-group label .req { color: var(--red); }

input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: .15s;
}
input:hover, select:hover, textarea:hover { border-color: #d8cba3; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3.5px rgba(183,134,47,.16);
}
textarea { resize: vertical; min-height: 74px; font-family: inherit; }

.money-hint {
  font-size: 11.5px;
  color: var(--gold);
  font-weight: 700;
  margin-top: 5px;
  min-height: 16px;
  padding: 3px 8px;
  background: #fdf6e5;
  border-radius: 6px;
  border: 1px dashed var(--gold-light);
}

.facilities-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.facility-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 11px;
  background: #f8f4e8;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  transition: .15s;
  border: 1.5px solid transparent;
}
.facility-item:hover { background: #f3ecd9; }
.facility-item input { width: auto; margin: 0; accent-color: var(--gold); }
.facility-item.checked { background: #fdf6e5; border-color: var(--gold-light); box-shadow: 0 2px 6px rgba(183,134,47,.15); }

/* ═══════════════════════════ کارت فایل ("قبض ملکی") ═══════════════════════════ */
.file-list { display: grid; gap: 13px; }
.file-card {
  background: var(--card);
  border-radius: 13px;
  padding: 15px 16px;
  box-shadow: 0 2px 12px rgba(12,32,56,.06);
  display: flex;
  flex-direction: column;
  gap: 9px;
  border: 1px solid var(--border);
  border-right: 5px solid var(--gold);
  transition: box-shadow .15s, transform .15s;
}
.file-card:hover { box-shadow: 0 6px 20px rgba(12,32,56,.12); transform: translateY(-1px); }
.file-card.done { opacity: .5; }
.file-card .code {
  font-weight: 800;
  color: var(--navy);
  font-size: 13.5px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.file-card .code small { font-weight: 500; color: var(--muted); font-size: 11px; margin-right: auto; }
.file-card .addr { font-size: 13px; color: var(--text); line-height: 1.85; }
.file-card .details { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.file-card .details b { color: var(--navy); font-weight: 700; }
.file-card .price {
  background:
    var(--star-tile-light),
    linear-gradient(135deg, var(--navy), var(--navy-2));
  background-size: 40px 40px, cover;
  color: #fff;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}
.file-card .price span { color: var(--gold-light); }
.file-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.file-card .owner { background: #dfe9f2; color: var(--blue); font-size: 11px; padding: 3px 9px; border-radius: 7px; font-weight: 700; }

.badge-sell { background: var(--red); color: #fff; font-size: 11px; padding: 3px 10px; border-radius: 7px; font-weight: 700; }
.badge-rent { background: var(--green); color: #fff; font-size: 11px; padding: 3px 10px; border-radius: 7px; font-weight: 700; }
.badge-lead { background: var(--blue); color: #fff; font-size: 11px; padding: 3px 10px; border-radius: 7px; font-weight: 700; }
.restricted-note { color: var(--gold); font-size: 12px; font-weight: 700; }

/* ──────── 🖼 عکس‌ها و گالری ──────── */
.photos-preview { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 11px; }
.photo-item { position: relative; width: 90px; height: 90px; border-radius: 11px; overflow: hidden; border: 1.5px solid var(--border); box-shadow: var(--shadow); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove { position: absolute; top: 4px; left: 4px; background: rgba(174,70,50,.92); color: #fff; border: none; width: 20px; height: 20px; border-radius: 50%; cursor: pointer; font-size: 11px; line-height: 1; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 9px; }
.gallery-grid img { width: 100%; height: 90px; object-fit: cover; border-radius: 11px; cursor: pointer; border: 1px solid var(--border); transition: transform .15s; }
.gallery-grid img:hover { transform: scale(1.03); }

/* ──────── 📄 متن آگهی ──────── */
.ad-preview {
  white-space: pre-wrap;
  background: #f8f4e8;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 15px;
  font-size: 13px;
  line-height: 2;
  max-height: 320px;
  overflow-y: auto;
}
.share-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 13px; }

/* ═══════════════════════════ آمار ═══════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 13px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border-radius: 13px;
  padding: 17px 16px;
  box-shadow: var(--shadow);
  text-align: center;
  border-top: 3px solid var(--gold);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-top-width: 3px;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: -10px auto auto -10px;
  width: 90px; height: 90px;
  background-image: var(--star-mark-navy);
  background-size: contain;
  pointer-events: none;
}
.stat-card .num { font-size: 25px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; letter-spacing: .5px; position: relative; }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 4px; position: relative; }
.stat-card.alert { border-top-color: var(--red); }
.stat-card.alert .num { color: var(--red); }

/* ═══════════════════════════ مودال‌ها ═══════════════════════════ */
.modal, .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9,20,33,.62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 12px;
}
.modal-box {
  background: var(--card);
  border-radius: 18px;
  padding: 24px;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lift);
  border-top: 4px solid var(--gold);
  animation: modal-rise .18s ease;
}
@keyframes modal-rise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-box h3 { color: var(--navy); margin-bottom: 15px; font-weight: 800; }

/* ═══════════════════════════ پیام‌ها ═══════════════════════════ */
.alert { padding: 11px 15px; border-radius: 10px; font-size: 13px; margin: 11px 0; font-weight: 600; }
.alert-error { background: #fbeae6; color: var(--red); border: 1px solid #f0c9bd; }
.alert-success { background: #ecf6ef; color: var(--green); border: 1px solid #c3e2cc; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-icon { font-size: 50px; margin-bottom: 12px; opacity: .8; }

/* ═══════════════════════════ صفحه ورود ═══════════════════════════ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    var(--star-tile-light),
    radial-gradient(circle at 15% 15%, var(--navy-3), transparent 55%),
    linear-gradient(150deg, var(--navy) 0%, var(--navy-2) 60%, #0a1c30 130%);
  background-size: 40px 40px, cover, cover;
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 36px 30px;
  width: min(400px, 100%);
  box-shadow: 0 30px 70px -20px rgba(0,0,0,.55);
  border-top: 5px solid var(--gold);
  text-align: center;
  position: relative;
}
.login-logo {
  font-size: 40px;
  width: 78px;
  height: 78px;
  margin: -66px auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    var(--star-tile-light),
    linear-gradient(135deg, var(--navy), var(--navy-2));
  background-size: 40px 40px, cover;
  border-radius: 50%;
  border: 4px solid var(--card);
  box-shadow: 0 8px 22px rgba(12,32,56,.4);
}
.login-title { font-size: 19px; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.login-subtitle { font-size: 12.5px; color: var(--muted); margin-bottom: 22px; }
.login-card .form-group { text-align: right; margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* ═══════════════════════════ صفحه مشاورین / جدول ═══════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--card); }
thead { background: linear-gradient(135deg, var(--navy), var(--navy-2)); }
th { color: #fff; text-align: right; padding: 12px 14px; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #faf5e6; }
tbody tr:last-child td { border-bottom: none; }

/* ═══════════════════════════ واکنش‌گرا ═══════════════════════════ */
@media (max-width: 720px) {
  .container, .panel-content { padding: 14px 10px 50px; }
  .topbar, .panel-header { padding: 11px 13px; }
  .brand { font-size: 13.5px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .facilities-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .card h2 { font-size: 14.5px; }
  .file-card { padding: 13px; }
  .tab { min-width: 86px; font-size: 12.5px; padding: 10px 8px; }
  .btn { font-size: 12.5px; padding: 9px 13px; }
  .login-card { padding: 30px 20px; }
}
@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .facilities-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════ دسترسی‌پذیری: کاهش انیمیشن ═══════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}
