.pill {
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
}
.pill.active  { background:#d1fae5; color:#065f46; }
.pill.revoked { background:#fee2e2; color:#991b1b; }
.pill.free    { background:#e5e7eb; color:#374151; }
.pill.admin   { background:#ede9fe; color:#5b21b6; }
table.admin-table {
    direction: rtl;
}
:root{
  --bg1:#eef5ff;
  --bg2:#f7f3ff;
  --card: rgba(255,255,255,.86);
  --cardBorder: rgba(20,40,90,.10);
  --shadow: 0 10px 24px rgba(10,25,60,.10);
  --shadow2: 0 14px 30px rgba(10,25,60,.14);
  --muted:#667;
  --ink:#12121a;
  --accent1:#0b57d0;
  --accent2:#4f46e5;
  --accent3:#7c3aed;
}

/* page */
html,body{height:100%;}
body{
  font-family:Tahoma, Arial;
  margin:0;
  color:var(--ink);
  background:
    radial-gradient(1200px 700px at 20% 0%, var(--bg1) 0%, var(--bg2) 45%, #fbfbfd 100%);
}
.container{max-width:980px; margin:0 auto; padding:12px;}

/* topbar */
.topbar{
  position:sticky; top:0; z-index:10;
  color:#fff;
  background: linear-gradient(90deg, var(--accent1), var(--accent2), var(--accent3));
  box-shadow: 0 10px 30px rgba(20,20,60,.18);
}
.toprow{display:flex; align-items:center; gap:10px; padding:10px 12px;}
.brand{font-weight:900; letter-spacing:.2px; white-space:nowrap;}
.brand a{color:#fff !important; text-decoration:none;}

/* search box in topbar */
/* .searchBox{flex:1; display:flex; gap:8px; align-items:center; min-width:160px;} */
.searchBox {
  flex: 0 1 400px; /* به جای flex:1 */
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 200px;
  max-width: 450px;
}

.searchBox input{
  width:100%;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.25);
  border-radius:14px;
  outline:none;
  background: rgba(255,255,255,.92);
}
.searchBox input:focus{
  border-color: rgba(255,255,255,.55);
  box-shadow: 0 0 0 3px rgba(255,255,255,.18);
}

/* .actions{display:flex; gap:8px; align-items:center; flex-wrap:wrap;} */
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-left: auto; /* این خط مهمه - دکمه‌ها رو به راست می‌چسبونه */
}
.nav-group {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar .btn{
  border:1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.16);
  color:#fff;
}
.topbar .btn:hover{background: rgba(255, 255, 255, 0.26);}

.muted{color:var(--muted); font-size:12px;}

/* breadcrumbs */
.crumbArea{padding:0 12px 10px 12px; background: rgba(255,255,255,.10);}
.crumbs{display:flex; gap:6px; flex-wrap:wrap; align-items:center;}
.crumbs a{color:#fff; text-decoration:none;}
.crumbs span{color:rgba(255,255,255,.75);}

/* section headings */
h2,h3{margin:10px 0;}

/* grid */
.grid{display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:12px;}
@media(max-width:520px){ .grid{grid-template-columns:repeat(1, minmax(0,1fr));} }

/* cards base */
.card, .hcard, .leaf{
  background: var(--card);
  border:1px solid var(--cardBorder);
  border-radius:18px;
  overflow:hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  background: #668fcc29;
}
.srchcard{
  background: var(--card);
  border:1px solid var(--cardBorder);
  border-radius:10px;
  overflow:hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  background: #668fcc29;
}
.card:hover{
  box-shadow: var(--shadow2);
  transform: translateY(-1px);
  transition: 140ms ease;
}
.rightActions {
  margin-bottom: 10px;
}

/* ====== IMPORTANT: grid cards are HORIZONTAL tiles ======
   خواسته شما: سمت راست عکس مربع کوچک، سمت چپ متن/عنوان
   چون صفحه RTL است، برای اینکه متن «سمت چپ» بیاید:
   text-align:end و align-items:flex-end استفاده می‌کنیم.
*/
.grid .card a{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px;
  text-decoration:none;
  color:inherit;
}

/* image box (right side) */
.grid .card .imgWrap{
  width:86px;
  height:86px;
  flex:0 0 86px;
  border-radius:16px;
  overflow:hidden;
  background: rgba(240,245,255,.9);
  border:1px solid rgba(20,40,90,.10);
}
.grid .card .imgWrap img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;      /* اگر بدون برش می‌خوای: contain */
  object-position:center;
}
.parentCard .imgWrap{
  width:100% !important;
  height:auto !important;
  aspect-ratio: 1 / 1 !important;   /* مربع */
  border-radius:18px;
  overflow:hidden;
  }
  .parentCard .imgWrap img{
  width:100% !important;
  height:100% !important;
  object-fit: cover !important;
  }
/* text area (left side) */
.grid .card .cardBody{
  flex:1 1 auto;
  min-width:0;
  padding:0;
  display:flex;
  flex-direction:column;
  align-items:flex-end;  /* در RTL => متن به سمت چپ کارت می‌چسبد */
  text-align:end;        /* end در RTL یعنی چپ */
}
.cardTitle{
  font-weight:900;
  margin:0;
  line-height:1.35;
  font-size:16px;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

/* leaf box */
.leaf{padding:12px; margin:10px 0;}
pre{white-space:pre-wrap; font-family:Tahoma, Arial; margin:8px 0 0;}

/* zoom mode */
body.zoomed .container{max-width:1100px;}
body.zoomed .grid{gap:14px;}
body.zoomed .cardTitle{font-size:16px;}
.leafBox {
background:#fafafa;
border:1px solid #e5e7eb;
border-radius:14px;
padding:14px;
margin:12px 0;
}
.leafExplain {
  margin-top: 8px;
  padding: 10px;
  background: rgb(243, 214, 214);
  border: 1px solid #000000;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.8;
  font-family:  sans-serif;
}

.leafMeta {
display:flex;
flex-wrap:wrap;
gap:8px;
margin-bottom:10px;
}

.metaBox {
background:#eef2ff;
padding:6px 10px;
border-radius:10px;
font-size:12px;
}

.btn-Start {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #e7a137;
  background-color: #000000;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}
.btn-danger {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
    background-color: #000000;
  color: #fff;
  font-weight: 400;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}
.btn-tab {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgb(75, 75, 75);
  background: rgb(255, 197, 111);
  color: #333;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  margin: 4px;
}
.btn-tab:hover {
  background: #f5f5f5;
  border-color: #00177e;
  transform: translateY(-1px);
}
.btn-login {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid #000000;
  background-color: #f5e174;
  color: rgb(0, 0, 0);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
  
}
.leafHidden {
display:none;
margin-top:8px;
padding:10px;
background:#fff;
border:1px dashed rgb(0, 0, 0);
border-radius:10px;
font-family:  sans-serif;
font-size:15px;
}
/* ===== medical boxes (Symptoms / Muscle) ===== */

.autoTable {
  width:100%;
  border-collapse:collapse;
  margin-top:10px;
}

.autoTable th, .autoTable td{
  border:1px solid #ddd;
  padding:6px 8px;
  text-align:center;
}

.autoTable th{
  background:#eef2ff;
  font-weight:700;
}

.autoTable tr:nth-child(even){
  background:#f9fafb;
}
/* ===== Floating Draggable Modal ===== */
#dynamicTitle {
  font-size:15px;
  font-weight:600;
  color:rgb(255, 255, 255);
  border-bottom:1px solid #eee;
  padding-bottom:6px;
}


.modal{
  display:none;
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background:rgba(0,0,0,.35);
  z-index:9999;
}

.modalContent{
  position:absolute;
  top:120px;
  left:200px;
  width:700px;
  max-height:80vh;
  overflow:auto;
  background:#ffffff;
  border-radius:2px;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
  animation:fadeIn .2s ease;
}

.modalHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px 14px;
  background:linear-gradient(90deg,#4f46e5,#7c3aed);
  color:#fff;
  border-radius:2px 2px 0 0;
  cursor:move;
  user-select:none;
}

.closeBtn{
  cursor:pointer;
  font-weight:bold;
}

.autoTable{
  width:100%;
  border-collapse:collapse;
}

.autoTable th, .autoTable td{
  border:1px solid #e5e7eb;
  padding:6px 8px;
  text-align:center;
}

.autoTable th{
  background:#eef2ff;
}

.autoTable tbody tr:nth-child(odd){
  background:#ffffff;
}

.autoTable tbody tr:nth-child(even){
  background:#b3c3f8;
}

@keyframes fadeIn{
  from{opacity:0; transform:scale(.95);}
  to{opacity:1; transform:scale(1);}
}
.no-copy {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.treatment-sidepanel{
  position: fixed;
  top: 0;
  right: -500px;
  width: 400px;
  height: 100vh;
  background: #aebbff;
  border-left: 1px solid #cfd6ea;
  box-shadow: -4px 0 18px rgba(0,0,0,.08);
  z-index: 9999;
  transition: right .3s ease;
  padding: 16px;
  overflow-y: auto;
}

.treatment-sidepanel.open{
  direction: rtl;
  right: 0;
}

.tp-topbar{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  direction: rtl;
}

.tp-topbar button{
  border: 1px solid #b8bfd6;
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}

.tp-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  direction: rtl;
}

.tp-actions button{
  border: 1px solid #b8bfd6;
  background: #fff;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
}

.tp-current-leaf{
  background: #eef2ff;
  border: 1px solid #d9e0f2;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.tp-history-table{
  width: 100%;
  border-collapse: collapse;
}

.tp-history-table th,
.tp-history-table td{
  border-bottom: 1px solid #dde3f2;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.tp-history-table th{
  background: #eef2ff;
}
/* Undo Button */
.tp-btn-undo {
  background: #e74c3c;
  color: rgb(0, 0, 0);
  border: none;
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.tp-btn-undo:hover {
  background: #e6bfbb;
}

.tp-btn-undo:active {
  transform: scale(0.96);
}
.med-box{
  background: linear-gradient(180deg,#ffffff,#f8fafc);
  border:1px solid #e5e7eb;
  border-radius:16px;
  padding:12px 14px;
  box-shadow: 0 6px 14px rgba(0,0,0,.06);
}

.med-box.symptoms{
  border-left:5px solid #ef4444;
}

.med-box.muscles{
  border-left:5px solid #6366f1;
}
.med-title{
  font-weight:800;
  font-size:13px;
  margin-bottom:6px;
  color:#111827;
}

.med-body{
  font-size:13px;
  line-height:1.8;
  color:#374151;
  white-space:pre-line;
}

/* ── هایلایت سلول‌های انتخابی در جدول مودال ── */
.autoTable td.selected-emotion,
.autoTable td.selected-energy {
    background: #e79436 !important;
    color: #fff !important;
    transition: background 0.15s ease;
}
.btn-correct,
.btn-eval {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgb(75, 75, 75);
    background: rgb(223, 223, 223);
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 4px;
}

.btn-correct:hover,
.btn-eval:hover {
    background: #f5f5f5;
    border-color: #667eea;
    transform: translateY(-1px);
}
#open-treatment-btn {
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  cursor: pointer;
  transition: all .2s;
}

#open-treatment-btn:hover {
  background: rgba(255,255,255,.25);
}
/* Main entry rows */
.tp-history-table tr.tp-main-row {
  font-weight: bold;
}

/* Child entry rows */
.tp-history-table tr.tp-child-row {
  background-color: #f0f7ff;
}

.tp-history-table tr.tp-child-row td:first-child {
  padding-right: 15px;
}
/* Selected row highlight */
.tp-history-table tr.selected-row {
  background-color: #ffcb6a !important;
  border-right: 3px solid #2196F3;
}
/* ===== Search Result Cards with Icon ===== */
.search-card-text .cardTitle {
  font-weight: 600;
  margin-bottom: 2px;
}

 .search-card-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-icon-img {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.search-icon-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* ===== RTL Header Fix ===== */
[dir="rtl"] .toprow {
  flex-direction: row-reverse;
}

[dir="rtl"] .actions {
  flex-direction: row-reverse;
}

[dir="rtl"] .searchBox {
  flex-direction: row-reverse;
}

[dir="rtl"] .searchBox input {
  text-align: right;
  direction: rtl;
}

[dir="rtl"] .crumbArea {
  text-align: right;
}

[dir="rtl"] .crumbs {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

/* ===== LTR (default) ===== */
[dir="ltr"] .searchBox input {
  text-align: left;
  direction: ltr;
}