/* ============================================================================
   components.css — Tavroo
   Buttons · Inputs · Cards · Badges · Modals · Dropdowns · Avatars · Toasts
   ============================================================================ */

/* ============================================================================
   1. BUTTONS
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-lg  { padding: 10px 20px; font-size: 15px; }
.btn-block { width: 100%; }

/* Primary — Orange */
.btn-primary {
  background: var(--color-accent-500);
  color: #FFFFFF;
}
.btn-primary:hover:not(:disabled)  { background: var(--color-accent-600); }
.btn-primary:active:not(:disabled) { background: var(--color-accent-700); }

/* Secondary — Sky outline */
.btn-secondary {
  background: transparent;
  color: var(--color-primary-600);
  border-color: var(--color-primary-300);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary-50);
  border-color: var(--color-primary-400);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-gray-100);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: #FFFFFF;
}
.btn-danger:hover:not(:disabled) { background: #DC2626; }

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-outline:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-medium);
}

/* Icon Button */
.btn-icon {
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-icon:hover:not(:disabled) {
  background: var(--color-gray-100);
  color: var(--text-primary);
}
.btn-icon-sm { width: 28px; height: 28px; }
.btn-icon-lg { width: 40px; height: 40px; }

/* Loading state */
.btn.is-loading {
  pointer-events: none;
  position: relative;
  color: transparent !important;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-color: rgba(255,255,255,0.4) rgba(255,255,255,0.4) rgba(255,255,255,0.4) #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  top: 50%;
  inset-inline-start: 50%;
  margin-top: -8px;
  margin-inline-start: -8px;
  color: currentColor;
}

/* ============================================================================
   2. INPUTS
   ============================================================================ */

.input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--surface-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input:hover:not(:disabled) { border-color: var(--border-medium); }
.input:focus:not(:disabled) {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(14 165 233 / 0.15);
}
.input:disabled {
  background: var(--color-gray-50);
  color: var(--text-muted);
  cursor: not-allowed;
}
.input::placeholder { color: var(--text-muted); }

.input.is-error {
  border-color: var(--color-danger);
}
.input.is-error:focus {
  box-shadow: 0 0 0 3px rgb(239 68 68 / 0.15);
}

textarea.input {
  height: auto;
  min-height: 80px;
  padding: 8px 12px;
  resize: vertical;
  line-height: 1.5;
}

.input-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.input-error {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-danger);
}

.input-group {
  margin-bottom: var(--space-4);
}

/* Input with icon */
.input-with-icon {
  position: relative;
}
.input-with-icon .input {
  padding-inline-start: 36px;
}
.input-with-icon-icon {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Checkbox */
.checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary-500);
  cursor: pointer;
}

/* Switch */
.switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--color-gray-300);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.switch::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  top: 2px;
  inset-inline-start: 2px;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.switch.is-on { background: var(--color-primary-500); }
.switch.is-on::after { transform: translateX(16px); }
[dir="rtl"] .switch.is-on::after { transform: translateX(-16px); }

/* ============================================================================
   3. CARDS
   ============================================================================ */

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card-hover {
  transition: all var(--transition-normal);
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 0; }

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

/* ============================================================================
   4. BADGES
   ============================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-blue   { background: var(--color-primary-100); color: var(--color-primary-700); }
.badge-orange { background: #FEF3C7; color: #92400E; }
.badge-green  { background: #D1FAE5; color: #065F46; }
.badge-red    { background: #FEE2E2; color: #991B1B; }
.badge-gray   { background: var(--color-gray-100); color: var(--color-gray-600); }
.badge-purple { background: #EDE9FE; color: #5B21B6; }

.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Priority badges */
.badge-priority-urgent  { background: rgb(239 68 68 / 0.12); color: var(--priority-urgent); }
.badge-priority-high    { background: rgb(249 115 22 / 0.12); color: var(--priority-high); }
.badge-priority-medium  { background: rgb(245 158 11 / 0.12); color: var(--priority-medium); }
.badge-priority-low     { background: rgb(16 185 129 / 0.12); color: var(--priority-low); }
.badge-priority-none    { background: var(--color-gray-100); color: var(--priority-none); }

/* Status badges */
.badge-status-todo        { background: rgb(148 163 184 / 0.15); color: var(--status-todo); }
.badge-status-inprogress  { background: rgb(14 165 233 / 0.12);  color: var(--status-inprogress); }
.badge-status-review      { background: rgb(139 92 246 / 0.12);  color: var(--status-review); }
.badge-status-done        { background: rgb(16 185 129 / 0.12);  color: var(--status-done); }
.badge-status-cancelled   { background: rgb(239 68 68 / 0.12);   color: var(--status-cancelled); }

/* ============================================================================
   5. AVATARS
   ============================================================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary-500);
  color: white;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
}

.avatar-xs { width: 20px; height: 20px; font-size: 9px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.avatar-xl { width: 56px; height: 56px; font-size: 18px; }

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-group {
  display: inline-flex;
}
.avatar-group .avatar {
  border: 2px solid var(--surface-card);
  margin-inline-start: -8px;
}
.avatar-group .avatar:first-child {
  margin-inline-start: 0;
}

.avatar-group-more {
  background: var(--color-gray-200);
  color: var(--text-secondary);
}

/* ============================================================================
   6. MODALS
   ============================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn 150ms ease;
  padding: var(--space-4);
}

.modal {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 200ms ease;
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ============================================================================
   7. DROPDOWNS
   ============================================================================ */

.dropdown {
  position: absolute;
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: var(--z-dropdown);
  overflow: hidden;
  animation: fadeIn 150ms ease;
  padding: var(--space-1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.dropdown-item:hover {
  background: var(--surface-hover);
}

.dropdown-item.is-active {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
}

.dropdown-item.danger {
  color: var(--color-danger);
}

.dropdown-item.danger:hover {
  background: #FEF2F2;
}

.dropdown-item.disabled,
.dropdown-item:disabled {
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.6;
}

.dropdown-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.dropdown-item.is-active .dropdown-item-icon,
.dropdown-item:hover .dropdown-item-icon {
  color: currentColor;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-1) 0;
}

.dropdown-section-label {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================================
   8. TOOLTIPS
   ============================================================================ */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-gray-900);
  color: white;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

[data-tooltip-bottom]::after {
  bottom: auto;
  top: calc(100% + 6px);
}

/* ============================================================================
   9. TOASTS
   ============================================================================ */

.toast-container {
  position: fixed;
  top: var(--space-4);
  inset-inline-end: var(--space-4);
  z-index: calc(var(--z-modal) + 100);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 280px;
  animation: slideUp 200ms ease;
  pointer-events: auto;
  border-inline-start: 3px solid var(--color-primary-500);
}

.toast.is-success { border-inline-start-color: var(--color-success); }
.toast.is-error   { border-inline-start-color: var(--color-danger); }
.toast.is-warning { border-inline-start-color: var(--color-warning); }

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--color-primary-500);
}
.toast.is-success .toast-icon { color: var(--color-success); }
.toast.is-error   .toast-icon { color: var(--color-danger); }
.toast.is-warning .toast-icon { color: var(--color-warning); }

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* ============================================================================
   10. SPINNERS / LOADERS
   ============================================================================ */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-gray-200);
  border-top-color: var(--color-primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

.skeleton {
  background: linear-gradient(90deg,
    var(--color-gray-100) 0%,
    var(--color-gray-200) 50%,
    var(--color-gray-100) 100%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================================
   11. EMPTY STATE
   ============================================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-4);
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--color-gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-message {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  max-width: 360px;
}

/* ============================================================================
   12. SIDE PANEL (drawer for task detail)
   ============================================================================ */

.side-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.3);
  z-index: var(--z-modal);
  animation: fadeIn 200ms ease;
}

.side-panel {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  height: 100vh;
  width: 50vw;
  min-width: 480px;
  max-width: 800px;
  background: var(--surface-card);
  border-inline-start: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  z-index: calc(var(--z-modal) + 1);
  animation: slideInRight 250ms ease;
  display: flex;
  flex-direction: column;
}

[dir="rtl"] .side-panel {
  animation: slideInLeft 250ms ease;
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@media (max-width: 768px) {
  .side-panel {
    width: 100vw;
    min-width: 0;
  }
}

/* ============================================================================
   13. MENTIONS (في markdown rendering)
   ============================================================================ */

.mention {
  display: inline-flex;
  padding: 1px 6px;
  background: var(--color-primary-50);
  color: var(--color-primary-700);
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.mention:hover {
  background: var(--color-primary-100);
}

/* ============================================================================
   14. PROSE (لعرض markdown content)
   ============================================================================ */

.prose {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.prose h1 { font-size: 22px; font-weight: 700; margin: var(--space-4) 0 var(--space-2); }
.prose h2 { font-size: 18px; font-weight: 600; margin: var(--space-4) 0 var(--space-2); }
.prose h3 { font-size: 16px; font-weight: 600; margin: var(--space-3) 0 var(--space-2); }

.prose p { margin-bottom: var(--space-2); }

.prose ul, .prose ol {
  padding-inline-start: var(--space-5);
  margin-bottom: var(--space-2);
}

.prose li { margin-bottom: 2px; }

.prose code {
  background: var(--color-gray-100);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-primary-700);
}

.prose pre {
  background: var(--color-gray-50);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  overflow-x: auto;
}

.prose pre code {
  background: transparent;
  padding: 0;
  color: var(--text-primary);
  font-size: 13px;
}

.prose a {
  color: var(--color-primary-600);
  text-decoration: underline;
}

.prose a:hover {
  color: var(--color-primary-700);
}

.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
