/* Global Styles */
:root {
  --primary-color: #b89569;
  --primary-hover: #9e7d54;
  --bg-color: #fcfaf6;
  --bg-gradient: linear-gradient(135deg, #fdfcfb 0%, #e2d1c3 100%);
  --text-color: #3b3024;
  --text-muted: #7a6a58;
  --card-bg: rgba(255, 255, 255, 0.7);
  --card-border: rgba(255, 255, 255, 0.5);
  --border-radius: 16px;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --glass-shadow: 0 8px 32px 0 rgba(136, 105, 68, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-color);
  line-height: 1.6;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

a {
  text-decoration: none;
  color: inherit;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Typography */
h1, h2, h3 {
  color: var(--text-color);
}
h1.page-title {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}
p.page-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #c7a980 0%, #a7855b 100%);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 99px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
  width: auto;
  font-size: 1rem;
  box-shadow: 0 4px 15px rgba(167, 133, 91, 0.3);
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(167, 133, 91, 0.4);
  background: linear-gradient(135deg, #d4b892 0%, #b89569 100%);
}
.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}
.btn-outline:hover {
  background: var(--primary-color);
  color: #fff;
}

/* Cards & Layout */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--glass-shadow);
  margin-bottom: 1.5rem;
  transition: transform 0.3s, box-shadow 0.3s;
}
.card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  border: 1px solid var(--primary-color);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }
.alert-danger { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }

/* Navigation */
.navbar {
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 1rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.navbar-brand {
  font-size: 1.5rem;
  font-weight: 800;
  color: #6e5436;
  letter-spacing: -0.5px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
}
.nav-links a {
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active {
  color: #6e5436;
  border-bottom: 2px solid #a7855b;
  padding-bottom: 0.25rem;
}
.btn-login {
  background: linear-gradient(135deg, #c7a980 0%, #a7855b 100%);
  color: white !important;
  padding: 0.5rem 1.5rem !important;
  border-radius: 99px;
  border: none !important;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(167, 133, 91, 0.2);
}
.btn-login:hover {
  background: linear-gradient(135deg, #d4b892 0%, #b89569 100%);
  transform: translateY(-1px);
}

/* Quiz Specific */
.option-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}
.option-btn:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}
.option-btn.selected {
  background: #e0e7ff;
  border-color: var(--primary-color);
  color: var(--primary-hover);
}
.option-btn.correct {
  background: #d1fae5;
  border-color: var(--success);
  color: #065f46;
}
.option-btn.wrong {
  background: #fee2e2;
  border-color: var(--danger);
  color: #991b1b;
}

/* Flashcard */
.flashcard-container {
  perspective: 1000px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 2rem;
  height: 250px;
}
.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard.flipped {
  transform: rotateY(180deg);
}
.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  font-size: 1.25rem;
  font-weight: 500;
}
.flashcard-front {
  background: var(--card-bg);
  border: 2px solid var(--primary-color);
  color: var(--text-color);
}
.flashcard-back {
  background: var(--primary-color);
  color: white;
  transform: rotateY(180deg);
}

.hidden {
  display: none !important;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .navbar {
    flex-direction: row;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    border-radius: 1rem !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
  }
  .navbar-brand {
    font-size: 1.15rem;
    flex-shrink: 0;
  }
  
  /* Hamburger toggle button — hidden on desktop, shown on mobile */
  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(167, 133, 91, 0.25);
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    flex-shrink: 0;
  }
  .nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: #6e5436;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
  }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }
  
  /* Slide-down menu when open */
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0.5rem 0.5rem 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(167, 133, 91, 0.18);
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.08);
    display: none;
    font-size: 0.95rem;
    z-index: 1001;
  }
  .nav-links.open {
    display: flex;
  }
  .nav-links a {
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    text-align: left;
    border-bottom: none !important;
  }
  .nav-links a:hover, .nav-links a.active {
    background: rgba(167, 133, 91, 0.1);
    border-bottom: none !important;
    padding-bottom: 0.7rem;
  }
  .nav-links .btn-login {
    margin-top: 0.25rem;
    text-align: center;
  }
  
  .container {
    padding: 1rem;
  }
}

/* Hide nav-toggle on desktop */
@media (min-width: 769px) {
  .nav-toggle { display: none; }
}

/* Toggle Switch Style */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}
input:checked + .slider {
  background-color: var(--primary-color);
}
input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}
input:checked + .slider:before {
  transform: translateX(22px);
}
.slider.round {
  border-radius: 34px;
}
.slider.round:before {
  border-radius: 50%;
}

/* RTL Mode for Arabic */
.rtl-mode {
  direction: rtl;
  text-align: right;
  font-family: 'Amiri', 'Traditional Arabic', serif;
  font-size: 1.25rem;
}
.rtl-mode .opt-box {
  flex-direction: row-reverse;
  text-align: right;
}
.rtl-mode .opt-label {
  margin-right: 0;
  margin-left: 1rem;
}



/* ─────────────────────────────────────────────────────────────────
   AdSense — responsive containers (mobile-first)
   ───────────────────────────────────────────────────────────────── */

.ad-slot {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 1.25rem auto;
  padding: 0;
  text-align: center;
  overflow: hidden;
  box-sizing: border-box;
  /* Reserve minimum vertical space so layout doesn't jump (CLS) */
  min-height: 100px;
}

/* Label "Iklan" wajib tampil agar tidak menyamar konten */
.ad-slot::before {
  content: "Iklan";
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9ca3af;
  background: rgba(255,255,255,0.6);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.ad-slot .adsbygoogle {
  display: block !important;
  width: 100% !important;
  max-width: 100%;
  margin: 0 auto;
}

/* Mobile: banner kecil 320x100 area */
@media (max-width: 480px) {
  .ad-slot {
    min-height: 100px;
    margin: 1rem auto;
  }
  .ad-slot .adsbygoogle {
    min-height: 100px;
  }
}

/* Tablet: banner 728x90 / leaderboard area */
@media (min-width: 481px) and (max-width: 1023px) {
  .ad-slot {
    min-height: 90px;
  }
  .ad-slot .adsbygoogle {
    min-height: 90px;
    max-width: 728px;
  }
}

/* Desktop: leaderboard 728x90 atau billboard 970x250 area */
@media (min-width: 1024px) {
  .ad-slot {
    min-height: 90px;
    max-width: 970px;
  }
  .ad-slot .adsbygoogle {
    min-height: 90px;
    max-width: 970px;
  }
}

/* Container existing yang masih pakai ID langsung (legacy) */
#ads-slot-top-container,
#ads-slot-bottom-container,
#ads-slot-results-container {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* ─────────────────────────────────────────────────────────────────
   Anchor ad — sticky bottom mobile (compliant, dapat ditutup)
   ───────────────────────────────────────────────────────────────── */

.ad-anchor {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 980;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  display: none; /* aktifkan via JS hanya di mobile */
  flex-direction: column;
  align-items: stretch;
  padding: 0.25rem 0.5rem 0.4rem;
  box-sizing: border-box;
}

.ad-anchor.visible { display: flex; }

.ad-anchor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #6b7280;
  padding: 0.15rem 0.25rem;
}

.ad-anchor-label {
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}

.ad-anchor-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.ad-anchor-close:hover { background: #f3f4f6; }

.ad-anchor .adsbygoogle {
  display: block !important;
  width: 100% !important;
  height: 60px;
  max-height: 90px;
}

/* Tampilkan anchor hanya di layar sempit */
@media (min-width: 768px) {
  .ad-anchor.visible { display: none; }
}

/* Beri padding bawah pada body agar konten tidak tertutup anchor ad */
body.ad-anchor-active { padding-bottom: 96px; }

@media (min-width: 768px) {
  body.ad-anchor-active { padding-bottom: 0; }
}
