/* ============================================
   COMPONENTS.CSS - Cards, Buttons, Badges, Tables, Modals
   InterSystems IRIS Arabic Academy
   ============================================ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.65rem 1.5rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--bg-deep);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-gold);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.btn-teal {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: var(--bg-deep);
}

.btn-teal:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-teal);
}

.btn-outline {
  background: transparent;
  color: var(--teal);
  border: 2px solid var(--teal);
}

.btn-outline:hover {
  background: var(--teal);
  color: var(--bg-deep);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: var(--text-xs);
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: var(--text-base);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--teal));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.card:hover::before {
  opacity: 1;
}

.card-flat {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.card-glass {
  background: rgba(26, 37, 72, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--text-heading);
  font-weight: 700;
}

.card-body {
  color: var(--text-secondary);
}

.card-footer {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Course card specific */
.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg), var(--shadow-glow-gold);
  border-color: var(--gold);
}

.course-card-cover {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.course-card-cover .icon-large {
  font-size: 3rem;
  opacity: 0.8;
}

.course-card-body {
  padding: var(--space-lg);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.course-card-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--text-heading);
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.course-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  flex: 1;
}

.course-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
}

.course-card-meta span {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.course-card-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.2rem 0.65rem;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-gold {
  background: rgba(212, 168, 67, 0.15);
  color: var(--gold);
  border: 1px solid rgba(212, 168, 67, 0.3);
}

.badge-teal {
  background: rgba(46, 196, 182, 0.15);
  color: var(--teal);
  border: 1px solid rgba(46, 196, 182, 0.3);
}

.badge-blue {
  background: rgba(58, 134, 255, 0.15);
  color: var(--blue);
  border: 1px solid rgba(58, 134, 255, 0.3);
}

.badge-purple {
  background: rgba(131, 56, 236, 0.15);
  color: var(--purple);
  border: 1px solid rgba(131, 56, 236, 0.3);
}

.badge-rose {
  background: rgba(255, 0, 110, 0.15);
  color: var(--rose);
  border: 1px solid rgba(255, 0, 110, 0.3);
}

.badge-green {
  background: rgba(6, 214, 160, 0.15);
  color: var(--green);
  border: 1px solid rgba(6, 214, 160, 0.3);
}

.badge-level {
  font-family: var(--font-heading);
}

.badge-beginner { background: rgba(6, 214, 160, 0.15); color: var(--green); border: 1px solid rgba(6, 214, 160, 0.3); }
.badge-intermediate { background: rgba(58, 134, 255, 0.15); color: var(--blue); border: 1px solid rgba(58, 134, 255, 0.3); }
.badge-advanced { background: rgba(131, 56, 236, 0.15); color: var(--purple); border: 1px solid rgba(131, 56, 236, 0.3); }
.badge-expert { background: rgba(255, 0, 110, 0.15); color: var(--rose); border: 1px solid rgba(255, 0, 110, 0.3); }

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width var(--transition-slow);
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}

.progress-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
  display: flex;
  justify-content: space-between;
}

/* Progress ring */
.progress-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  stroke: var(--bg-elevated);
  fill: none;
}

.progress-ring-fill {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-slow);
}

.progress-ring-text {
  position: absolute;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-heading);
}

/* Form elements */
.input, .select, .textarea {
  width: 100%;
  padding: 0.65rem 1rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  direction: rtl;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.15);
  outline: none;
}

.input::placeholder {
  color: var(--text-muted);
}

.textarea {
  resize: vertical;
  min-height: 100px;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 2.5rem;
}

.search-input {
  position: relative;
}

.search-input .input {
  padding-right: 2.5rem;
}

.search-input .search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Checkbox and Radio */
.checkbox-group, .radio-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  margin-bottom: var(--space-sm);
}

.checkbox-group input, .radio-group input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
  cursor: pointer;
}

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.2rem 0.6rem;
  font-size: var(--text-xs);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.tag-removable::after {
  content: '×';
  cursor: pointer;
  margin-right: var(--space-xs);
  color: var(--text-muted);
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-deep);
  color: var(--text-primary);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  border: 1px solid var(--border-default);
  margin-bottom: var(--space-xs);
}

.tooltip:hover::after {
  opacity: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: accordian-center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--text-heading);
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-lg);
}

.modal-close:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-xl);
}

.modal-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-start;
  gap: var(--space-md);
}

/* Toast */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: var(--shadow-lg);
  animation: fadeDown 0.3s ease forwards;
  pointer-events: auto;
  min-width: 300px;
  direction: rtl;
}

.toast-success { border-right: 4px solid var(--green); }
.toast-error { border-right: 4px solid var(--rose); }
.toast-warning { border-right: 4px solid var(--gold); }
.toast-info { border-right: 4px solid var(--blue); }

.toast-icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-lg);
  padding: var(--space-xs);
}

/* Accordion */
.accordion {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.accordion-item {
  border-bottom: 1px solid var(--border-subtle);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-header {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition-fast);
  text-align: right;
}

.accordion-header:hover {
  background: var(--bg-elevated);
}

.accordion-header .arrow {
  transition: transform var(--transition-fast);
  color: var(--text-muted);
}

.accordion-item.open .accordion-header .arrow {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
}

.accordion-item.open .accordion-content {
  max-height: 1000px;
}

.accordion-body {
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-default);
  gap: var(--space-xs);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: var(--space-sm) var(--space-lg);
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
}

.tab-panel {
  display: none;
  padding: var(--space-lg) 0;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* Table of Contents */
.toc {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.toc-title {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  margin-bottom: var(--space-xs);
}

.toc-link {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  border-right: 2px solid transparent;
  text-decoration: none;
}

.toc-link:hover {
  color: var(--teal);
  background: var(--bg-elevated);
}

.toc-link.active {
  color: var(--teal);
  border-right-color: var(--teal);
  background: rgba(46, 196, 182, 0.08);
}

/* Achievement badges */
.achievement {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.achievement.unlocked {
  border-color: var(--gold);
  box-shadow: var(--shadow-glow-gold);
}

.achievement.locked {
  opacity: 0.5;
  filter: grayscale(0.8);
}

.achievement-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  font-size: var(--text-2xl);
  flex-shrink: 0;
}

.achievement.unlocked .achievement-icon {
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.2), rgba(212, 168, 67, 0.05));
}

.achievement-info h4 {
  font-size: var(--text-sm);
  color: var(--text-heading);
  margin-bottom: var(--space-xs);
}

.achievement-info p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-sm);
}

.skeleton-title {
  height: 1.5em;
  width: 60%;
  margin-bottom: var(--space-md);
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-lg);
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-2xl) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-4xl) var(--space-xl);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-lg);
  opacity: 0.5;
}

.empty-state-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--text-heading);
  margin-bottom: var(--space-sm);
}

.empty-state-desc {
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto var(--space-lg);
}

/* Notification dot */
.notification-dot {
  position: relative;
}

.notification-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 8px;
  height: 8px;
  background: var(--rose);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-surface);
}

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:hover {
  background: var(--bg-card);
  border-color: var(--border-default);
}

.chip.active {
  background: rgba(46, 196, 182, 0.15);
  color: var(--teal);
  border-color: rgba(46, 196, 182, 0.3);
}

/* Stat card */
.stat-card {
  text-align: center;
  padding: var(--space-xl);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.stat-value {
  font-family: var(--font-heading);
  font-size: var(--text-4xl);
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb a:hover {
  color: var(--teal);
}

.breadcrumb-sep {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

/* Bookmark button */
.bookmark-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-lg);
  padding: var(--space-xs);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
}

.bookmark-btn:hover {
  color: var(--gold);
}

.bookmark-btn.active {
  color: var(--gold);
}

/* Responsive */
@media (max-width: 768px) {
  .modal {
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-top: auto;
  }

  .modal-overlay {
    align-items: flex-end;
  }

  .stat-value {
    font-size: var(--text-3xl);
  }
}
