/* ============================================================
   MOSTAQER — SIDEBAR NAVIGATION
   css/sidebar.css
   Unified sidebar matching CRM design language
   ============================================================ */

/* ── Design tokens ── */
:root {
  --sb-w:        260px;
  --sb-bg:       #FFFFFF;
  --sb-border:   #EDE8D0;
  --sb-gold:     #C49A00;
  --sb-gold-l:   #E6B800;
  --sb-gold-bg:  #FFFBEA;
  --sb-text:     #1A1209;
  --sb-text2:    #78716C;
  --sb-active:   #FFF8E0;
  --sb-hover:    #FEFCF3;
  --sb-purple:   #8B5CF6;
  --sb-green:    #10B981;
  --sb-red:      #EF4444;
  --sb-shadow:   2px 0 16px rgba(196,154,0,.08);
}

/* ════════════════════════════════════════
   SIDEBAR CONTAINER
════════════════════════════════════════ */
#app-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sb-w);
  height: 100vh;
  background: var(--sb-bg);
  border-left: 1.5px solid var(--sb-border);
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  z-index: 9200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  transform: translateX(100%); /* hidden by default */
}

#app-sidebar.sb-open {
  transform: translateX(0);
}

/* Legacy class support */
#app-sidebar.sb-collapsed {
  transform: translateX(100%);
}

/* ── Sidebar sections ── */
.sb-section {
  padding: .5rem .6rem;
}

.sb-section + .sb-section {
  border-top: 1px solid #F3F0E8;
}

.sb-section-label {
  font-size: .65rem;
  font-weight: 700;
  color: var(--sb-text2);
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: .4rem .6rem .2rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}

/* ── Sidebar nav items ── */
.sb-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .7rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
  font-size: .82rem;
  font-weight: 600;
  color: var(--sb-text);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  position: relative;
}

.sb-item:hover {
  background: var(--sb-hover);
  color: var(--sb-gold);
}

.sb-item.sb-active {
  background: var(--sb-active);
  color: var(--sb-gold);
  font-weight: 700;
}

.sb-item.sb-active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--sb-gold-l);
  border-radius: 3px;
}

.sb-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: .85rem;
  flex-shrink: 0;
}

.sb-item-icon--gold   { background: #FFF8E0; color: var(--sb-gold); }
.sb-item-icon--purple { background: #F3F0FF; color: var(--sb-purple); }
.sb-item-icon--green  { background: #ECFDF5; color: var(--sb-green); }
.sb-item-icon--blue   { background: #EFF6FF; color: #3B82F6; }
.sb-item-icon--red    { background: #FEF2F2; color: var(--sb-red); }
.sb-item-icon--gray   { background: #F5F5F4; color: #78716C; }
.sb-item-icon--teal   { background: #E6FFFA; color: #0D9488; }

.sb-item-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-item-badge {
  font-size: .65rem;
  font-weight: 800;
  padding: .1rem .4rem;
  border-radius: 8px;
  background: var(--sb-gold-l);
  color: #fff;
  min-width: 18px;
  text-align: center;
}

/* ── Sidebar footer ── */
.sb-footer {
  margin-top: auto;
  padding: .75rem;
  border-top: 1px solid #F3F0E8;
  text-align: center;
}

.sb-footer-brand {
  font-size: .7rem;
  color: var(--sb-text2);
  font-weight: 600;
}

.sb-footer-brand span {
  color: var(--sb-gold);
  font-weight: 800;
}

/* ── Toggle button in header — always visible ── */
.gh-btn--sidebar {
  display: flex !important;
}

/* ════════════════════════════════════════
   MAIN CONTENT — no margin push (overlay mode)
════════════════════════════════════════ */
#app.has-sidebar .main-content,
#tp-app.has-sidebar .tp-main,
#tp-app.has-sidebar .tp-header {
  margin-right: 0;
}

/* ════════════════════════════════════════
   BACKDROP OVERLAY
════════════════════════════════════════ */
.sb-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 9150;
  backdrop-filter: blur(2px);
}
.sb-backdrop.active {
  display: block;
}

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sb-w: 240px; }
}
@media (max-width: 480px) {
  :root { --sb-w: 220px; }
}

/* ════════════════════════════════════════
   APPOINTMENT FILTER BUTTONS
════════════════════════════════════════ */
.crm-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .7rem;
  border: 1px solid var(--sb-border, #EDE8D0);
  background: #fff;
  color: var(--sb-text2, #78716C);
  border-radius: 20px;
  font-family: inherit;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.crm-filter-btn:hover {
  border-color: var(--sb-gold-l, #E6B800);
  color: var(--sb-gold, #C49A00);
  background: var(--sb-gold-bg, #FFFBEA);
}

.crm-filter-btn.crm-filter-active {
  background: var(--sb-gold-l, #E6B800);
  color: #fff;
  border-color: var(--sb-gold-l, #E6B800);
  box-shadow: 0 2px 8px rgba(230, 184, 0, .25);
}

.crm-filter-btn.crm-filter-active:hover {
  background: var(--sb-gold, #C49A00);
  border-color: var(--sb-gold, #C49A00);
  color: #fff;
}

.crm-filter-btn i {
  font-size: .7rem;
}

/* Filter count badge */
.crm-filter-count {
  font-size: .62rem;
  font-weight: 800;
  padding: .05rem .3rem;
  border-radius: 8px;
  background: rgba(255,255,255,.3);
  min-width: 16px;
  text-align: center;
}

.crm-filter-btn:not(.crm-filter-active) .crm-filter-count {
  background: #F3F0E8;
  color: var(--sb-text2, #78716C);
}

/* ════════════════════════════════════════
   VISIT DROPDOWN (زيارة جديدة)
════════════════════════════════════════ */
.visit-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.visit-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--sb-border, #EDE8D0);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 100;
  overflow: hidden;
  animation: visitDropIn .2s ease-out;
}

.visit-dropdown.show {
  display: block;
}

@keyframes visitDropIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.visit-dropdown-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .8rem;
  cursor: pointer;
  transition: background .15s;
  font-size: .78rem;
  font-weight: 600;
  color: var(--sb-text, #1A1209);
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  text-align: right;
}

.visit-dropdown-item:hover {
  background: #FFFBEA;
}

.visit-dropdown-item + .visit-dropdown-item {
  border-top: 1px solid #F3F0E8;
}

.visit-dropdown-item i {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: .8rem;
  flex-shrink: 0;
}

.visit-dropdown-item .vd-icon--green  { background: #ECFDF5; color: #10B981; }
.visit-dropdown-item .vd-icon--purple { background: #F3F0FF; color: #8B5CF6; }
.visit-dropdown-item .vd-icon--blue   { background: #EFF6FF; color: #3B82F6; }

/* ════════════════════════════════════════
   THERAPY PLANS MODAL
════════════════════════════════════════ */
.crm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: crmModalFadeIn .2s ease;
}
@keyframes crmModalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.crm-modal-card {
  background: var(--card, #fff);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: crmModalSlideUp .25s ease;
}
@keyframes crmModalSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.crm-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border, #eee);
  background: var(--bg2, #FAFAFA);
}
.crm-modal-body {
  padding: .75rem 1rem;
  overflow-y: auto;
  flex: 1;
}

/* Plan cards list */
.crm-therapy-plans-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.crm-tp-plan-card {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .7rem;
  border-radius: 10px;
  border: 1px solid var(--border, #eee);
  background: var(--card, #fff);
  transition: all .15s;
}
.crm-tp-plan-card:hover {
  border-color: #E6B800;
  box-shadow: 0 2px 8px rgba(230,184,0,.1);
}
.crm-tp-plan-active  { border-right: 3px solid #10B981; }
.crm-tp-plan-completed { border-right: 3px solid #6B7280; opacity: .8; }
.crm-tp-plan-archived  { border-right: 3px solid #D97706; opacity: .65; }

/* Status badge */
.crm-tp-status {
  font-size: .62rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 6px;
  white-space: nowrap;
}
.crm-tp-status-active    { background: #ECFDF5; color: #059669; }
.crm-tp-status-completed { background: #F3F4F6; color: #6B7280; }
.crm-tp-status-archived  { background: #FEF3C7; color: #D97706; }

/* Open journey button */
.crm-tp-open-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  transition: all .15s;
  flex-shrink: 0;
}
.crm-tp-open-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(16,185,129,.35);
}

/* Create plan button */
.crm-tp-create-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border: 1.5px solid var(--border, #ddd);
  background: var(--card, #fff);
  color: var(--text, #333);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
}
.crm-tp-create-btn:hover {
  border-color: #E6B800;
  background: #FFFBEB;
  color: #92400E;
}
.crm-tp-create-btn--primary {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: #fff;
  border-color: transparent;
}
.crm-tp-create-btn--primary:hover {
  background: linear-gradient(135deg, #D97706, #B45309);
  color: #fff;
  box-shadow: 0 4px 12px rgba(217,119,6,.35);
}

/* ════════════════════════════════════════
   PRINT — hide sidebar
════════════════════════════════════════ */
@media print {
  #app-sidebar,
  .sb-backdrop {
    display: none !important;
  }
  #app.has-sidebar .main-content {
    margin-right: 0 !important;
  }
}
