@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:"Cairo",system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.6;
}
a{color:inherit;text-decoration:none}
img{max-width:100%;display:block}
.container{max-width:1100px;margin:0 auto;padding:0 16px}
.row{display:flex;align-items:center}
.row.wrap{flex-wrap:wrap}
.spacer{flex:1}
.small{font-size:13px}
.tiny{font-size:12px}
.muted{color:var(--muted)}
.hr{height:1px;background:var(--border);margin:12px 0}

.header{
  position:sticky;top:0;z-index:20;
  background:rgba(248,250,252,0.92);
  backdrop-filter:blur(8px);
  border-bottom:1px solid var(--border);
}
.header .inner{display:flex;align-items:center;gap:12px;padding:10px 0}
.brand{display:flex;align-items:center;gap:10px;font-weight:800}
.brand img{width:34px;height:34px}
.searchbar{display:flex;align-items:center;gap:8px;min-width:260px}
@media(max-width:760px){
  .searchbar{display:none}
}

.btn{
  border:1px solid var(--border);
  background:var(--surface);
  padding:10px 14px;border-radius:999px;
  cursor:pointer;
  box-shadow:0 2px 8px rgba(2,6,23,0.05);
  transition:transform .06s ease, background .2s ease;
}
.btn:hover{transform:translateY(-1px)}
.btn:active{transform:translateY(0)}
.btn.sm{padding:8px 12px;font-size:14px}
.btn.primary{background:var(--primary);color:#fff;border-color:transparent}
.btn.primary:hover{background:var(--primary-600)}

.input{
  width:100%;
  border:1px solid var(--border);
  background:var(--surface);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
  font-family:inherit;
}
.input:focus{border-color:rgba(15,118,110,0.4);box-shadow:0 0 0 4px rgba(15,118,110,0.10)}
.label{display:block;margin-top:10px;margin-bottom:6px;color:var(--muted);font-size:13px}

.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}
.card-body{padding:16px}
.card-title{font-weight:800}
.big{font-size:26px;font-weight:800}

.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}
.grid.two{grid-template-columns:repeat(2,1fr)}
.grid.stats{grid-template-columns:repeat(5,1fr)}
@media(max-width:980px){
  .grid{grid-template-columns:repeat(2,1fr)}
  .grid.stats{grid-template-columns:repeat(2,1fr)}
}
@media(max-width:560px){
  .grid{grid-template-columns:1fr}
  .grid.two{grid-template-columns:1fr}
}

.badge{
  display:inline-flex;align-items:center;gap:6px;
  padding:6px 10px;border-radius:999px;
  background:rgba(15,118,110,0.08);
  color:var(--primary);
  font-size:12px;font-weight:700;
}
.badge.gray{background:rgba(100,116,139,0.12);color:var(--muted)}

.section-title{display:flex;align-items:flex-end;gap:12px;margin:20px 0 12px}
.section-title h2{margin:0;font-size:22px}
.page-head{display:flex;align-items:flex-end;gap:12px;margin:18px 0 12px}
.page-head h2{margin:0}

.post-card .cover{height:160px;background:#e2e8f0}
.post-card .cover img{width:100%;height:100%;object-fit:cover}
.cover.big{height:280px}
.excerpt{color:var(--muted);font-size:14px;margin-top:6px}
.meta-line{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px;color:var(--muted);font-size:13px}

.rating{display:inline-flex;align-items:center;gap:3px}
.rating .star{color:rgba(100,116,139,0.35)}
.rating .star.filled{color:#F59E0B}
.rating .count{color:var(--muted);font-size:12px;margin-right:6px}

.star{color:rgba(100,116,139,0.35)}
.star.filled{color:#F59E0B}
.star-btn{
  border:none;background:transparent;
  font-size:22px;cursor:pointer;
  color:rgba(100,116,139,0.35);
  padding:0 2px;
}
.star-btn.on{color:#F59E0B}

.footer{margin-top:30px;border-top:1px solid var(--border);padding:16px 0}
.center{min-height:50vh;display:grid;place-items:center}
.auth{min-height:65vh;display:grid;place-items:center}
.auth .card{max-width:520px;width:100%}

.alert{
  padding:12px 14px;border-radius:14px;
  border:1px solid var(--border);background:rgba(100,116,139,0.06);
  margin:12px 0;
}
.alert.danger{background:rgba(220,38,38,0.08);border-color:rgba(220,38,38,0.18)}
.alert.warn{background:rgba(245,158,11,0.10);border-color:rgba(245,158,11,0.18)}
.alert.info{background:rgba(37,99,235,0.10);border-color:rgba(37,99,235,0.18)}

.shell{display:grid;grid-template-columns:260px 1fr;gap:14px;max-width:1200px;margin:0 auto;padding:14px}
@media(max-width:900px){
  .shell{grid-template-columns:1fr}
}
.sidebar{
  position:sticky;top:70px;height:calc(100vh - 90px);
  padding:12px;border-radius:var(--radius);
  background:var(--surface);border:1px solid var(--border);
  box-shadow:var(--shadow);
}
.nav a{display:block;padding:10px 12px;border-radius:12px;color:var(--muted);font-weight:700}
.nav a.active{background:rgba(15,118,110,0.10);color:var(--primary)}
.nav a:hover{background:rgba(100,116,139,0.08)}
.content{min-height:60vh}

.drawer-btn{display:none}
.drawer-backdrop{display:none}
@media(max-width:900px){
  .drawer-btn{display:inline-flex}
  .sidebar{
    position:fixed;top:0;right:-320px;z-index:40;
    width:280px;height:100vh;border-radius:0;
    transition:right .2s ease;
  }
  body.drawer-open .sidebar{right:0}
  body.drawer-open .drawer-backdrop{
    display:block;position:fixed;inset:0;background:rgba(2,6,23,0.45);z-index:30;
  }
}

.table{width:100%;border-collapse:collapse}
.table th,.table td{border-bottom:1px solid var(--border);padding:10px;text-align:right;vertical-align:top}
.table th{color:var(--muted);font-size:13px;font-weight:800}
.table td{font-size:14px}

.post-page .post-title h1{margin:8px 0 0;font-size:28px}
.info-bar{
  margin-top:14px;
  padding:14px;border-radius:var(--radius);
  border:1px solid var(--border);background:var(--surface);
}
.doctor-mini{display:flex;align-items:center;gap:10px}
.avatar{width:44px;height:44px;border-radius:999px;object-fit:cover;border:1px solid var(--border);background:#e2e8f0}

.article{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-top:14px;box-shadow:var(--shadow)}
.article p{margin:0 0 12px}
.article h2,.article h3{margin:16px 0 10px}

.comments{margin-top:14px;display:flex;flex-direction:column;gap:10px}
.comment{border:1px solid var(--border);background:rgba(100,116,139,0.04);border-radius:14px;padding:12px}
.comment.doctor{background:rgba(15,118,110,0.06);border-color:rgba(15,118,110,0.18)}
.comment-text{margin-top:6px}
.comment-children{margin-top:10px;display:flex;flex-direction:column;gap:10px}

.toast-wrap{position:fixed;left:16px;bottom:16px;z-index:60;display:flex;flex-direction:column;gap:10px}
.toast{
  background:var(--text);color:#fff;
  padding:10px 12px;border-radius:14px;
  box-shadow:var(--shadow);max-width:320px;
  font-size:14px;
}

.install-banner{
  display:none;
  position:fixed;bottom:16px;right:16px;left:16px;
  z-index:50;
}
.install-banner .card{max-width:520px;margin:0 auto}
.install-banner .card-body{display:flex;gap:10px;align-items:center}
body.show-install-banner #install-banner{display:block}

.chart-wrap{height:220px}
.chart-wrap canvas{width:100%;height:220px}

.chat{display:flex;flex-direction:column;gap:10px}
.chat-box{height:52vh;overflow:auto;border:1px solid var(--border);background:var(--surface);border-radius:var(--radius);padding:12px}
.msg{display:flex;margin:8px 0}
.msg.from-doctor{justify-content:flex-end}
.msg.from-visitor{justify-content:flex-start}
.bubble{max-width:78%;background:rgba(100,116,139,0.08);border-radius:16px;padding:10px 12px}
.msg.from-doctor .bubble{background:rgba(15,118,110,0.12)}
.msg-img{max-width:260px;border-radius:12px;border:1px solid var(--border)}
.chat-form textarea{resize:vertical}
.qr{width:220px;height:220px;border-radius:14px;border:1px solid var(--border);background:#fff;padding:6px}

.editor{direction:rtl}

/* =========================
   Post Details (Redesign)
   ========================= */
.post-layout{
  display:grid;
  grid-template-columns: 1fr;
  gap:16px;
  align-items:start;
  margin-top:16px;
}

.post-aside{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.post-main{
  display:flex;
  flex-direction:column;
  gap:14px;
}

/* Cover fix (حل مشكلة الصورة الضخمة + حواف ناعمة) */
.cover-card .cover.big{
  height:260px;
  border-radius:var(--radius);
  overflow:hidden;
  border:1px solid var(--border);
  background:#e2e8f0;
}
.cover-card .cover.big img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

/* Title area */
.post-main-head .post-h1{
  margin:10px 0 6px;
  font-size:28px;
  line-height:1.35;
}
.post-main-head .excerpt{
  margin:0;
  color:var(--muted);
  font-size:15px;
}

/* Article typography */
.post-article{
  margin-top:0;
  font-size:17px;
  line-height:1.95;
}
.post-article img{
  max-width:100%;
  height:auto;
  border-radius:14px;
  border:1px solid var(--border);
  margin:12px 0;
}
.post-article blockquote{
  margin:12px 0;
  padding:12px 14px;
  border-right:4px solid var(--primary);
  background:rgba(15,118,110,0.06);
  border-radius:14px;
}
.post-article ul, .post-article ol{
  padding-right:18px;
}

/* Aside buttons */
.post-aside-actions{
  display:flex;
  gap:10px;
  margin-top:12px;
}
.post-aside-actions .btn{
  border-radius:12px;
}

/* Desktop layout: main left + aside right */
@media (min-width: 980px){
  .post-layout{
    grid-template-columns: 1fr 360px;
    grid-template-areas: "main aside";
    gap:20px;
  }
  .post-main{ grid-area: main; }
  .post-aside{ grid-area: aside; }

  .cover-card .cover.big{ height:360px; }
}

/* =========================
   Home improvements
   ========================= */
.home-section{ margin-top:18px; }

.section-head, .latest-head{
  display:flex;
  align-items:end;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.section-title{
  margin:0;
  font-size:22px;
}

/* Categories horizontal scroll (Grid via scroll) */
.cat-scroll{
  display:grid;
  grid-auto-flow:column;
  grid-auto-columns: minmax(160px, 1fr);
  gap:10px;
  overflow-x:auto;
  padding:10px 2px;
  scroll-snap-type:x mandatory;
  -webkit-overflow-scrolling:touch;
}
.cat-scroll::-webkit-scrollbar{ height:8px; }
.cat-scroll::-webkit-scrollbar-thumb{ border-radius:99px; background:rgba(0,0,0,.15); }

.cat-chip{
  scroll-snap-align:start;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:16px;
  background:var(--card);
  text-decoration:none;
  color:inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.cat-chip:hover{ transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0,0,0,.06); }
.cat-name{ font-weight:700; }
.cat-count{
  min-width:34px;
  text-align:center;
  padding:4px 10px;
  border-radius:999px;
  background: rgba(15,118,110,.10);
  color: var(--primary);
  font-weight:700;
}

/* Filters responsive */
.post-filters{ margin:12px 0 14px; }
.filters-row{
  display:flex;
  gap:12px;
  align-items:end;
  flex-wrap:wrap;
  padding:12px;
  border:1px solid var(--border);
  border-radius:16px;
  background:var(--card);
}
.filter-item{ min-width:180px; }
.filter-item.grow{ flex:1; min-width:220px; }
.filter-actions{ display:flex; gap:10px; }

/* Posts grid */
.posts-grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:14px;
}

@media (max-width: 980px){
  .posts-grid{ grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px){
  .section-head, .latest-head{
    flex-direction:column;
    align-items:flex-start;
  }

  .filters-row{
    flex-direction:column;
    align-items:stretch;
  }
  .filter-item, .filter-item.grow{ min-width:unset; width:100%; }
  .filter-actions{ width:100%; }
  .filter-actions .btn{ flex:1; }

  .posts-grid{ grid-template-columns: 1fr; }
}

