/* Workspace card deep panel (templates/workspace/cardPanel.html, js/services/wsCardPanel.js).
   Right dock ~480px (docks LEFT under [dir="rtl"]); flex/grid only, no floats.
   Tokens from css/modern-admin.css (--admin-primary, --bg-sidebar); fonts Almarai/Inter. */

/* body scroll-lock while the panel is open */
body.ws-card-panel-open {
  overflow: hidden;
}

/* z-index: below angular-material dialogs (md-backdrop 50 / dialog 80) so
   $pop.confirm / mdp-date-picker opened from the panel stay on top. */
.wscp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 44;
}

.wscp-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: 480px;
  max-width: 100vw;
  background: #ffffff;
  color: #1e293b;
  z-index: 45;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.18);
  transform: translateX(105%);
  transition: transform 0.28s ease;
  font-family: "Almarai", "Inter", sans-serif;
}

.wscp-panel.wscp-open {
  transform: translateX(0);
}

[dir="rtl"] .wscp-panel {
  right: auto;
  left: 0;
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.18);
  transform: translateX(-105%);
}

[dir="rtl"] .wscp-panel.wscp-open {
  transform: translateX(0);
}

@media (max-width: 520px) {
  .wscp-panel {
    width: 100vw;
    box-shadow: none;
  }
}

/* ---------------------------------------------------------------- header */
.wscp-stripe {
  height: 5px;
  flex: 0 0 auto;
}

.wscp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.wscp-header-main {
  flex: 1 1 auto;
  min-width: 0;
}

.wscp-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: text;
  word-break: break-word;
  border-radius: 6px;
  padding: 2px 6px;
  margin-inline-start: -6px;
}

.wscp-title:hover {
  background: #f1f5f9;
}

.wscp-title-form {
  margin: 0;
}

.wscp-subtitle {
  margin-top: 4px;
  font-size: 0.8rem;
  color: #64748b;
  word-break: break-word;
}

.wscp-header-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.wscp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #475569;
  font-size: 1.15rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.wscp-icon-btn:hover {
  background: #f1f5f9;
  color: var(--admin-primary, #3b82f6);
}

.wscp-icon-btn.wscp-active {
  color: var(--admin-primary, #3b82f6);
  background: rgba(59, 130, 246, 0.12);
}

.wscp-icon-btn-sm {
  width: 26px;
  height: 26px;
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- tabs */
.wscp-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 12px;
}

.wscp-tab {
  flex: 1 1 0;
  border: none;
  background: transparent;
  padding: 10px 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.wscp-tab:hover {
  color: var(--admin-primary, #3b82f6);
}

.wscp-tab-active {
  color: var(--admin-primary, #3b82f6);
  border-bottom-color: var(--admin-primary, #3b82f6);
}

/* ---------------------------------------------------------------- body */
.wscp-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 18px 24px;
}

.wscp-section {
  margin-bottom: 18px;
}

.wscp-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px) {
  .wscp-grid-2 {
    grid-template-columns: 1fr;
  }
}

.wscp-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
}

.wscp-section-title i {
  color: var(--admin-primary, #3b82f6);
}

.wscp-section-value {
  margin-inline-start: auto;
  color: #1e293b;
}

.wscp-empty {
  font-size: 0.8rem;
  color: #94a3b8;
  padding: 6px 0;
}

.wscp-empty-text {
  color: #94a3b8;
  font-style: italic;
}

/* ---------------------------------------------------------------- chips & pickers */
.wscp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.wscp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 0.78rem;
  max-width: 100%;
}

.wscp-chip-label {
  color: #ffffff;
  border: none;
  font-weight: 600;
}

.wscp-chip-add {
  cursor: pointer;
  color: var(--admin-primary, #3b82f6);
  border-style: dashed;
}

.wscp-chip-add:hover {
  background: rgba(59, 130, 246, 0.1);
}

.wscp-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.wscp-chip-x {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
  line-height: 1;
}

.wscp-chip-x:hover {
  color: #ef4444;
}

.wscp-chip-muted {
  color: #94a3b8;
  font-size: 0.74rem;
}

.wscp-picker {
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}

.wscp-picker-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  padding: 6px 8px 2px;
}

.wscp-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
}

.wscp-picker-item:hover {
  background: #f1f5f9;
}

.wscp-picker-item i.uil-check {
  margin-inline-start: auto;
  color: var(--admin-primary, #3b82f6);
}

.wscp-picker-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* avatars */
.wscp-chip img,
.wscp-picker-item img,
.wscp-comment-head img,
.wscp-approval img,
.wscp-time-entry img,
.wscp-avatar-fallback {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}

.wscp-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--admin-primary, #3b82f6);
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 700;
}

.wscp-label-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: 0 0 auto;
}

/* ---------------------------------------------------------------- forms */
.wscp-panel .form-control {
  font-size: 0.85rem;
}

.wscp-range {
  width: 100%;
  accent-color: var(--admin-primary, #3b82f6);
  cursor: pointer;
}

.wscp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.wscp-btn:hover {
  background: #f1f5f9;
}

.wscp-btn-primary {
  background: var(--admin-primary, #3b82f6);
  border-color: var(--admin-primary, #3b82f6);
  color: #ffffff;
}

.wscp-btn-primary:hover {
  background: var(--admin-primary-dark, #2563eb);
}

.wscp-btn-danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
}

.wscp-btn-danger:hover {
  background: #dc2626;
}

.wscp-btn-sm {
  padding: 3px 9px;
  font-size: 0.74rem;
}

.wscp-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wscp-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.wscp-inline-add {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.wscp-inline-add .form-control {
  flex: 1 1 auto;
}

/* date pickers must not overflow the grid cell */
.wscp-panel mdp-date-picker {
  display: block;
  max-width: 100%;
}

/* ---------------------------------------------------------------- description */
.wscp-descr {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  min-height: 38px;
}

.wscp-descr:hover {
  background: #f8fafc;
}

/* ---------------------------------------------------------------- checklists */
.wscp-checklist {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}

.wscp-checklist-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wscp-checklist-head strong {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.86rem;
}

.wscp-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  margin: 8px 0;
  overflow: hidden;
}

.wscp-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--admin-primary, #3b82f6);
  transition: width 0.25s ease;
}

.wscp-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.84rem;
  cursor: pointer;
  margin: 0;
}

.wscp-check-item input[type="checkbox"] {
  accent-color: var(--admin-primary, #3b82f6);
  flex: 0 0 auto;
}

.wscp-check-name {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.wscp-check-name.wscp-done {
  text-decoration: line-through;
  color: #94a3b8;
}

/* ---------------------------------------------------------------- custom fields / subtasks */
.wscp-cf {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 0.83rem;
  border-bottom: 1px dashed #e2e8f0;
}

.wscp-cf:last-child {
  border-bottom: none;
}

.wscp-cf-name {
  color: #64748b;
}

.wscp-cf-value {
  font-weight: 600;
  text-align: end;
  word-break: break-word;
}

.wscp-subtask {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.84rem;
  border-bottom: 1px dashed #e2e8f0;
}

.wscp-subtask:last-child {
  border-bottom: none;
}

/* ---------------------------------------------------------------- badges */
.wscp-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.68rem;
  font-weight: 700;
}

.wscp-badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.wscp-badge-approved {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
}

.wscp-badge-rejected {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.wscp-badge-order {
  background: var(--admin-primary, #3b82f6);
  color: #ffffff;
  min-width: 22px;
  justify-content: center;
}

/* ---------------------------------------------------------------- approvals */
.wscp-approval {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.wscp-approval:last-of-type {
  border-bottom: none;
}

.wscp-approval-step {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.wscp-approval-main {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.84rem;
}

.wscp-approval-comment {
  margin-top: 3px;
  font-size: 0.78rem;
  color: #64748b;
  word-break: break-word;
}

.wscp-approval-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* ---------------------------------------------------------------- comments */
.wscp-comment-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.wscp-comment-form .form-control {
  flex: 1 1 auto;
}

.wscp-comment {
  padding: 8px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.wscp-comment-reply {
  border-bottom: none;
  margin-inline-start: 34px;
  padding-inline-start: 10px;
  border-inline-start: 2px solid #e2e8f0;
}

.wscp-comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.wscp-comment-body {
  margin: 4px 0 6px;
  margin-inline-start: 34px;
  font-size: 0.84rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.wscp-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-inline-start: 34px;
}

.wscp-reaction {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wscp-reaction:hover {
  background: #f1f5f9;
}

.wscp-reaction-me {
  border-color: var(--admin-primary, #3b82f6);
  background: rgba(59, 130, 246, 0.1);
}

.wscp-reply-btn {
  color: #64748b;
}

/* ---------------------------------------------------------------- activity */
.wscp-activity {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed #e2e8f0;
  font-size: 0.83rem;
}

.wscp-activity:last-of-type {
  border-bottom: none;
}

.wscp-activity-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--admin-primary, #3b82f6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.wscp-activity-main {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

/* ---------------------------------------------------------------- time */
.wscp-timer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.wscp-timer-elapsed {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--bg-sidebar, #0f172a);
  direction: ltr;
  text-align: start;
}

.wscp-totals {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  font-size: 0.83rem;
  color: #475569;
}

.wscp-manual-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

@media (max-width: 520px) {
  .wscp-manual-row {
    grid-template-columns: 1fr;
  }
}

.wscp-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.83rem;
  margin: 0;
}

.wscp-check input[type="checkbox"] {
  accent-color: var(--admin-primary, #3b82f6);
}

.wscp-time-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed #e2e8f0;
  font-size: 0.83rem;
}

.wscp-time-entry:last-of-type {
  border-bottom: none;
}

.wscp-time-main {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---------------------------------------------------------------- files */
.wscp-files-actions {
  margin-top: 0;
  margin-bottom: 14px;
}

.wscp-upload-label {
  cursor: pointer;
}

.wscp-files {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .wscp-files {
    grid-template-columns: 1fr;
  }
}

.wscp-file {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px;
  min-width: 0;
}

.wscp-file-thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f1f5f9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #64748b;
  font-size: 1.4rem;
}

.wscp-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wscp-file-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.wscp-file-name {
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- skeleton */
.wscp-skel {
  border-radius: 8px;
  background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%);
  background-size: 200% 100%;
  animation: wscp-shimmer 1.3s infinite;
}

.wscp-skel-title {
  height: 24px;
  width: 60%;
}

.wscp-skel-line {
  height: 14px;
  width: 100%;
  margin-bottom: 14px;
}

.wscp-skel-short {
  width: 55%;
}

.wscp-skel-block {
  height: 90px;
  width: 100%;
  margin-bottom: 14px;
}

@keyframes wscp-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ---------------------------------------------------------------- night mode */
.night-mode .wscp-panel {
  background: var(--bg-sidebar, #0f172a);
  color: #e2e8f0;
}

.night-mode .wscp-header,
.night-mode .wscp-tabs {
  border-bottom-color: #1e293b;
}

.night-mode .wscp-title:hover,
.night-mode .wscp-icon-btn:hover,
.night-mode .wscp-picker-item:hover,
.night-mode .wscp-btn:hover,
.night-mode .wscp-reaction:hover,
.night-mode .wscp-descr:hover {
  background: #1e293b;
}

.night-mode .wscp-chip,
.night-mode .wscp-btn,
.night-mode .wscp-picker,
.night-mode .wscp-reaction,
.night-mode .wscp-file,
.night-mode .wscp-checklist,
.night-mode .wscp-timer {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.night-mode .wscp-btn-primary {
  background: var(--admin-primary, #3b82f6);
  border-color: var(--admin-primary, #3b82f6);
  color: #ffffff;
}

.night-mode .wscp-btn-danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
}

.night-mode .wscp-timer-elapsed {
  color: #f1f5f9;
}
