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

:root{
  --bg: #0b0f17;
  --panel: #131b26;
  --panel-card: #182232;
  --panel-hover: #1e2b3e;
  --line: #26354a;
  --text: #f0f4f9;
  --muted: #8899ad;
  --accent: #20e3b2;
  --accent-glow: rgba(32, 227, 178, 0.2);
  --accent-dim: rgba(32, 227, 178, 0.1);
  --danger: #ff5c65;
  --warn: #ffb444;
  --radius: 16px;
}

*{box-sizing:border-box; margin:0; padding:0;}
body{
  background: radial-gradient(1000px 600px at 85% -15%, #0f4038 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', system-ui, sans-serif;
  min-height: 100vh;
}
code, .mono{font-family:'JetBrains Mono', monospace; direction: ltr; unicode-bidi: embed;}
a{color: inherit; text-decoration:none;}

.shell{display:flex; min-height:100vh;}
.side{
  width: 250px; background: var(--panel); border-left: 1px solid var(--line);
  padding: 28px 18px; display:flex; flex-direction:column; gap: 24px;
  position: sticky; top:0; height:100vh;
}
.brand{display:flex; align-items:center; gap:12px; font-weight:800; font-size:18px; padding: 0 6px;}
.brand-dot{
  width:12px; height:12px; border-radius:50%; background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
}
.side nav{display:flex; flex-direction:column; gap:6px; flex:1;}
.side nav a{
  padding: 12px 16px; border-radius: var(--radius); color: var(--muted); font-size: 14px; font-weight:600;
  transition: all 0.2s ease;
}
.side nav a:hover{background: var(--panel-card); color: var(--text);}
.side nav a.active{background: var(--accent-dim); color: var(--accent); border-right: 3px solid var(--accent);}
.logout{padding:14px; color: var(--danger); font-size:13.5px; border-top:1px solid var(--line); font-weight:600; transition:0.2s;}
.logout:hover{color:#ffa3a7;}

.content{flex:1; padding: 40px 50px; max-width: 1200px;}
h1{font-size: 26px; font-weight:900; margin: 0 0 8px;}
h2{font-size:17px; margin: 0 0 16px; color: var(--text); font-weight:800;}
.subtitle{color: var(--muted); font-size:14px; margin-bottom:28px;}

.grid{display:grid; grid-template-columns: repeat(auto-fit, minmax(230px,1fr)); gap:20px; margin-bottom: 30px;}
.card{
  background: var(--panel); border:1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.stat-label{color:var(--muted); font-size:13px; margin-bottom:10px; font-weight:600;}
.stat-value{font-size: 30px; font-weight:900; font-family:'JetBrains Mono', monospace;}
.stat-value.accent{color: var(--accent); text-shadow: 0 0 20px var(--accent-glow);}

table{width:100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow:hidden; border:1px solid var(--line);}
th,td{padding: 16px 20px; text-align: right; border-bottom: 1px solid var(--line); font-size: 14px;}
th{color:var(--muted); font-weight:700; background: var(--panel-card);}
tr:last-child td{border-bottom:none;}
tbody tr:hover{background: rgba(255,255,255,0.015);}

.badge{display:inline-flex; align-items:center; gap:6px; padding: 5px 14px; border-radius: 999px; font-size:12px; font-weight:700;}
.badge-on{background: var(--accent-dim); color: var(--accent); border:1px solid rgba(32,227,178,0.3);}
.badge-off{background: rgba(255,92,101,0.12); color: var(--danger); border:1px solid rgba(255,92,101,0.3);}
.badge-warn{background: rgba(255,180,68,0.12); color:var(--warn); border:1px solid rgba(255,180,68,0.3);}

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px; padding: 11px 20px; border-radius: var(--radius);
  background: var(--accent); color:#04211a; font-weight:800; font-size:14px; border:none; cursor:pointer;
  transition: all 0.25s ease; box-shadow: 0 4px 14px var(--accent-glow);
}
.btn:hover{filter:brightness(1.12); transform: translateY(-2px); box-shadow: 0 6px 20px var(--accent-glow);}
.btn-outline{background:transparent; border:1px solid var(--line); color:var(--text); font-weight:700; box-shadow:none;}
.btn-outline:hover{background:var(--panel-card); border-color:var(--muted); transform: translateY(-1px);}
.btn-sm{padding:8px 16px; font-size:13px; border-radius:10px;}

.form-card{
  max-width:440px; margin: 0 auto; background:var(--panel); border:1px solid var(--line);
  border-radius:20px; padding:40px; text-align:center; box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  position: relative;
}
.form-card::before{
  content:''; position:absolute; top:-1px; left:20%; right:20%; height:3px; border-radius:3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
input[type=text], input[type=number], input[type=password], select{
  width:100%; padding:13px 16px; border-radius: var(--radius); border:1px solid var(--line);
  background: var(--panel-card); color:var(--text); font-family:inherit; font-size:14.5px; margin-bottom:18px;
  outline: none; transition: 0.2s;
}
input:focus, select:focus{border-color:var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);}
label{display:block; text-align:right; font-size:13px; color:var(--muted); margin-bottom:8px; font-weight:700;}

.flash{padding:14px 20px; border-radius:var(--radius); margin-bottom:24px; font-size:14px; font-weight:700;}
.flash-error{background:rgba(255,92,101,0.12); color:#ff8e94; border:1px solid rgba(255,92,101,0.4);}
.flash-ok{background: var(--accent-dim); color: var(--accent); border:1px solid rgba(32,227,178,0.4);}
.center-page{
  min-height: calc(100vh - 80px); width:100%;
  display:flex; align-items:center; justify-content:center;
  margin: -40px -50px; padding: 40px 50px;
}
@media (max-width: 640px){
  .center-page{ margin: -24px -16px; padding: 24px 16px; min-height: calc(100vh - 48px); }
  .form-card{ padding: 30px 24px; }
}

/* استایل‌های اختصاصی صفحه مدیریت کانفیگ مشتری */
.config-header-card {
  background: linear-gradient(135deg, #131b26 0%, #172333 100%);
  border: 1px solid var(--line); border-radius: 20px; padding: 26px 30px; margin-bottom: 24px;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px;
}
.qr-container-box {
  display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 24px; margin-bottom: 24px; text-align: center; animation: fadeInDown 0.3s ease;
}
.qr-white-frame {
  background: #ffffff; padding: 14px; border-radius: 16px; display: inline-block;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4); margin-bottom: 16px;
}
.qr-white-frame img { display: block; width: 180px; height: 180px; }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

.spec-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px;
}
.spec-card {
  background: var(--panel-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.spec-title { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.spec-val { font-size: 16px; font-weight: 800; }

.toast-box {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #04211a; padding: 12px 24px; border-radius: 50px;
  font-weight: 800; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: none; z-index: 9999; animation: popUp 0.3s ease;
}
@keyframes popUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Server Selection Cards */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.server-card {
  background: var(--panel-card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  position: relative;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.server-card:hover {
  background: var(--panel-hover);
  border-color: var(--muted);
  transform: translateY(-2px);
}
.server-card.selected {
  border-color: var(--accent);
  background: linear-gradient(145deg, var(--panel-card) 0%, rgba(32, 227, 178, 0.08) 100%);
  box-shadow: 0 0 20px var(--accent-glow);
}
.server-card input[type="radio"] {
  display: none;
}
.server-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.server-flag-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 800;
}
.server-flag-icon {
  font-size: 24px;
  line-height: 1;
}
.server-check-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
  transition: 0.2s;
}
.server-card.selected .server-check-icon {
  background: var(--accent);
  border-color: var(--accent);
  color: #04211a;
  font-weight: 900;
}

/* نوار پیشرفت ظرفیت */
.capacity-wrapper {
  margin-top: 4px;
}
.capacity-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}
.capacity-bar {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.capacity-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* کارت‌های انتخاب پلن */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.plan-card {
  background: var(--panel-card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.plan-card:hover {
  background: var(--panel-hover);
  border-color: var(--muted);
}
.plan-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 16px var(--accent-glow);
}
.plan-card input[type="radio"] {
  display: none;
}

/* Chat & Ticket System Styles */
.chat-wrapper {
  display: flex; flex-direction: column; height: 600px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.chat-header {
  padding: 16px 22px; background: var(--panel-card); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.chat-messages {
  flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
}
.chat-bubble {
  max-width: 75%; padding: 12px 18px; border-radius: 16px; font-size: 14.5px;
  line-height: 1.6; position: relative; animation: bubbleIn 0.2s ease;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.chat-bubble.customer {
  align-self: flex-start; background: #182230; border: 1px solid var(--line);
  color: var(--text); border-bottom-right-radius: 4px;
}
.chat-bubble.reseller {
  align-self: flex-end; background: linear-gradient(135deg, #0d3830 0%, #124d42 100%);
  border: 1px solid rgba(32,227,178,0.4); color: #fff; border-bottom-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(32,227,178,0.15);
}
.chat-sender { font-size: 11.5px; font-weight: 800; margin-bottom: 4px; display: block; }
.chat-bubble.customer .chat-sender { color: var(--muted); }
.chat-bubble.reseller .chat-sender { color: var(--accent); }
.chat-time { font-size: 11px; opacity: 0.6; margin-top: 6px; text-align: left; display: block; font-family: 'JetBrains Mono', monospace; }

.chat-input-bar {
  padding: 14px 18px; background: var(--panel-card); border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center;
}
.chat-input-bar input { margin-bottom: 0 !important; flex: 1; }

/* Ticket Attachment Styles */
.chat-img-attach {
  max-width: 240px; max-height: 220px; border-radius: 12px; display: block;
  margin-bottom: 6px; object-fit: cover; border: 1px solid rgba(255,255,255,0.15);
  transition: transform 0.2s ease; cursor: pointer;
}
.chat-img-attach:hover { transform: scale(1.02); }
.attach-btn-label {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 14px; border-radius: var(--radius); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.attach-btn-label:hover { background: var(--panel-hover); border-color: var(--accent); }
.file-indicator { font-size: 11.5px; color: var(--accent); display: none; }

/* Server Card Background Flag Watermark */
.server-card {
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.server-card-bg-flag {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%) rotate(-12deg);
  font-size: 85px;
  line-height: 1;
  opacity: 0.08;
  filter: grayscale(20%) blur(0.5px);
  pointer-events: none;
  z-index: 0;
  user-select: none;
  transition: all 0.3s ease;
}

.server-card:hover .server-card-bg-flag {
  opacity: 0.14;
  transform: translateY(-50%) scale(1.08) rotate(-8deg);
}

.server-card.selected .server-card-bg-flag {
  opacity: 0.18;
  filter: none;
  transform: translateY(-50%) scale(1.1) rotate(-6deg);
}

.server-card > * {
  position: relative;
  z-index: 2;
}

/* ============================================================
   موبایل — فقط جلوگیری از سرریز افقی (زیر ۹۰۰ پیکسل)
   نمای دسکتاپ کاملاً دست‌نخورده باقی می‌ماند
   ============================================================ */
@media (max-width: 900px) {

  /* جلوگیری از اسکرول افقی کل صفحه */
  html, body { max-width: 100%; overflow-x: hidden; }

  /* سایدبار باریک‌تر تا فضا برای محتوا بماند */
  .side { width: 168px; padding: 18px 10px; }
  .side nav a { padding: 10px 11px; font-size: 12.5px; }
  .brand { font-size: 14.5px; gap: 8px; }

  .content { padding: 20px 14px; max-width: 100%; min-width: 0; }

  /* هر گرید تک‌ستونه شود */
  .grid, .cp-stats, .rs-stats, .us-stats, .tk-stats, .ch-stats,
  .cv-specs, .cv-cards, .cfg-grid, .us-grid, .or-grid,
  .buy-server-grid, .buy-plan-grid, .rs-quick, .cv-actions,
  .server-grid, .plan-grid {
    grid-template-columns: 1fr !important;
  }

  /* چیدمان‌های دوستونه تک‌ستونه شوند */
  .tk-cols, .ch-cols, .cg-cols { grid-template-columns: 1fr !important; }

  /* جدول‌ها: اسکرول داخلی به جای شکستن صفحه */
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  th, td { padding: 11px 13px; font-size: 12.5px; }

  /* هیچ عنصری از عرض صفحه بیرون نزند */
  .card, .form-card, .cv-panel, .tc-wrap, .cp-hero, .rs-hero, .tk-hero, .cg-hero {
    max-width: 100% !important;
    min-width: 0;
  }

  /* متن‌های طولانی بشکنند */
  .mono, .cfg-name, .or-name, .cv-spec-v, .tc-text { word-break: break-word; }

  /* عکس‌ها و ورودی‌ها در قاب بمانند */
  img, textarea, input, select { max-width: 100%; }

  /* ردیف دکمه‌ها بشکند به جای سرریز */
  .actions, .us-actions, .us-form, .cv-actions { flex-wrap: wrap; }

  /* گفتگوی تیکت */
  .tc-line { max-width: 92%; }
  .tc-msgs { padding: 18px 14px; }

  /* عنوان‌ها کمی کوچک‌تر */
  h1 { font-size: 19px; }
  .stat-value, .cp-stat-value, .rs-stat-value { font-size: 20px; }
}

@media (max-width: 560px) {
  .side { width: 128px; padding: 16px 8px; }
  .side nav a { font-size: 11.5px; padding: 9px 8px; line-height: 1.6; }
  .brand { font-size: 12.5px; gap: 6px; }
  .brand-dot { width: 8px; height: 8px; }
  .logout { font-size: 11.5px; padding: 11px 8px; }
  .content { padding: 16px 11px; }
}
