/* =============================================
   COMPONENTS.CSS — Reusable UI Components
   AkalApp — Platform Pembelajaran Digital
   ============================================= */

/* ================================================
   BUTTONS
   ================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
  letter-spacing: var(--tracking-wide);
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--transition-base);
}

/* Primary — gradient bg with glow */
.btn-primary {
  background: var(--gradient-primary);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow-blue);
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

/* Secondary — outlined */
.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border-hover);
  backdrop-filter: var(--glass-blur);
}

.btn-secondary:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-blue);
  color: var(--color-blue-light);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

/* Ghost — minimal */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: var(--sp-2) var(--sp-4);
}

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

/* Danger */
.btn-danger {
  background: var(--color-error);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--color-error-light);
  box-shadow: var(--shadow-glow-blue);
  box-shadow: 0 0 20px var(--color-error-glow);
  transform: translateY(-1px);
}

/* Sizes */
.btn-sm {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn-xl {
  padding: var(--sp-5) var(--sp-10);
  font-size: var(--text-lg);
  border-radius: var(--radius-lg);
}

.btn-icon {
  padding: var(--sp-3);
  width: 40px;
  height: 40px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
  box-shadow: none !important;
}

/* ================================================
   CARDS — Glassmorphism
   ================================================ */
.card {
  background: var(--color-bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card);
  border-radius: inherit;
  pointer-events: none;
}

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

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}

/* ================================================
   FORM INPUTS
   ================================================ */
.input,
.select,
.textarea {
  display: block;
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px var(--color-blue-glow);
  background: var(--color-bg-surface);
}

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

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--color-border-hover);
}

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

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  padding-right: var(--sp-10);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

/* ================================================
   BADGES
   ================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  line-height: 1.4;
}

.badge-free {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success-light);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-premium {
  background: rgba(139, 92, 246, 0.15);
  color: var(--color-purple-light);
  border: 1px solid rgba(139, 92, 246, 0.25);
}

.badge-school {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-blue-light);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-popular {
  background: var(--gradient-primary);
  color: #ffffff;
  border: none;
}

/* ================================================
   NAV LINK — Underline Animation
   ================================================ */
.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
  text-decoration: none;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-text);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* ================================================
   MODAL
   ================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background: var(--color-bg-overlay);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

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

.modal-card {
  background: var(--color-bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--sp-8);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-spring);
}

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

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

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
  font-size: var(--text-xl);
}

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

/* ================================================
   AVATAR
   ================================================ */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border-hover);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--color-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  overflow: hidden;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar-xl { width: 72px; height: 72px; font-size: var(--text-2xl); }

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

/* ================================================
   LOADING SPINNER — CSS Only
   ================================================ */
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-blue);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

.loading-spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.loading-spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Full page loader */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  min-height: 60vh;
  color: var(--color-text-muted);
}

/* ================================================
   TOAST — Notification Popup
   ================================================ */
.toast-container {
  position: fixed;
  top: calc(var(--navbar-height, 64px) + var(--sp-4));
  right: var(--sp-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--glass-bg-heavy);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: all var(--transition-spring);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

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

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

.toast-close {
  flex-shrink: 0;
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

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

.toast-success { border-left: 3px solid var(--color-success); }
.toast-error   { border-left: 3px solid var(--color-error); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-info    { border-left: 3px solid var(--color-blue); }

/* ================================================
   PRICING CARD
   ================================================ */
.pricing-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--sp-8);
  text-align: center;
  position: relative;
  transition: all var(--transition-base);
  overflow: hidden;
}

.pricing-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card);
  pointer-events: none;
}

.pricing-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl);
}

.pricing-card.popular {
  border-color: var(--color-purple);
  box-shadow: var(--shadow-glow-purple);
  transform: scale(1.03);
}

.pricing-card.popular:hover {
  transform: scale(1.03) translateY(-6px);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.4), 0 0 60px rgba(139, 92, 246, 0.15);
}

.pricing-card .popular-badge {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gradient-primary);
  color: #ffffff;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  padding: var(--sp-1-5) var(--sp-5);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

.pricing-plan-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  margin-bottom: var(--sp-4);
  position: relative;
}

.pricing-amount {
  font-size: var(--text-5xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  line-height: 1;
  margin-bottom: var(--sp-2);
  position: relative;
}

.pricing-amount .currency {
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  vertical-align: super;
  margin-right: var(--sp-1);
}

.pricing-period {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--sp-6);
  position: relative;
}

.pricing-features {
  text-align: left;
  margin-bottom: var(--sp-8);
  position: relative;
}

.pricing-feature-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.pricing-feature-item .check {
  color: var(--color-success);
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.pricing-feature-item.disabled {
  color: var(--color-text-muted);
  text-decoration: line-through;
  opacity: 0.5;
}

.pricing-feature-item.disabled .check {
  color: var(--color-text-muted);
}

/* ================================================
   FEATURE CARD
   ================================================ */
.feature-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-8);
  text-align: center;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card);
  pointer-events: none;
}

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

.feature-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: rgba(59, 130, 246, 0.1);
  font-size: 28px;
  margin-bottom: var(--sp-5);
  position: relative;
  transition: all var(--transition-base);
}

.feature-card:hover .feature-card-icon {
  transform: scale(1.1);
  box-shadow: var(--shadow-glow-blue);
}

.feature-card-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--sp-3);
  position: relative;
}

.feature-card-desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  position: relative;
}

/* ================================================
   STAT ITEM
   ================================================ */
.stat-item {
  text-align: center;
  padding: var(--sp-4);
}

.stat-number {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  margin-bottom: var(--sp-2);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
}

/* ================================================
   TESTIMONIAL CARD
   ================================================ */
.testimonial-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.testimonial-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card);
  pointer-events: none;
}

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

.testimonial-quote {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--sp-5);
  font-style: italic;
  position: relative;
}

.testimonial-quote::before {
  content: '"';
  font-size: var(--text-5xl);
  font-weight: var(--weight-bold);
  color: var(--color-blue);
  opacity: 0.3;
  position: absolute;
  top: -10px;
  left: -4px;
  line-height: 1;
  font-style: normal;
}

.testimonial-author {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  position: relative;
}

.testimonial-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.testimonial-role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ===========================
   CUSTOM CONFIRM / ALERT DIALOG
   =========================== */
.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 50);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  animation: confirmFadeIn 0.25s ease forwards;
}

.confirm-dialog-box {
  background: var(--color-bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-xl), 0 0 40px rgba(59, 130, 246, 0.08);
  padding: var(--sp-8);
  max-width: 400px;
  width: 100%;
  transform: scale(0.9) translateY(10px);
  animation: confirmSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s forwards;
}

.confirm-dialog-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto var(--sp-5);
}

.confirm-dialog-icon.icon-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.confirm-dialog-icon.icon-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.confirm-dialog-icon.icon-info {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.confirm-dialog-icon.icon-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.confirm-dialog-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  text-align: center;
  margin-bottom: var(--sp-2);
  color: var(--color-text);
}

.confirm-dialog-message {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.6;
  margin-bottom: var(--sp-6);
}

.confirm-dialog-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
}

.confirm-dialog-actions .btn {
  flex: 1;
  max-width: 160px;
  padding: var(--sp-3) var(--sp-5);
}

/* Exit animation */
.confirm-dialog-overlay.closing {
  animation: confirmFadeOut 0.2s ease forwards;
}

.confirm-dialog-overlay.closing .confirm-dialog-box {
  animation: confirmSlideOut 0.2s ease forwards;
}

@keyframes confirmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes confirmFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes confirmSlideIn {
  from { transform: scale(0.9) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes confirmSlideOut {
  from { transform: scale(1) translateY(0); opacity: 1; }
  to   { transform: scale(0.95) translateY(5px); opacity: 0; }
}

@media (max-width: 480px) {
  .confirm-dialog-box {
    max-width: calc(100vw - var(--sp-8));
    padding: var(--sp-6);
  }
}

/* ================================================
   FISIKA X FENOMENA POPUP — z-index Override
   Fisika X's main.css overwrites --z-modal to 200,
   which is below AkalApp navbar (z-index: 500).
   Use hardcoded value above all platform layers.
   ================================================ */
.fenomena-overlay {
  z-index: 9999 !important;
}
