/* =========================================================
   Maya Oefenboekjes - Hoofdstijlen voor Kinderen & Tablets
   ========================================================= */

:root {
  --primary-color: #F59E0B;
  --primary-hover: #D97706;
  --accent-color: #10B981;
  --danger-color: #EF4444;
  --bg-gradient: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  --card-bg: #FFFFFF;
  --text-main: #1F2937;
  --text-muted: #6B7280;
  --header-bg: #FFFFFF;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --touch-target: 48px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Comic Neue", "Fredoka", cursive, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ================= UTILITIES ================= */
.hidden {
  display: none !important;
}

/* ================= VIEWS ================= */
.view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ================= HEADER ================= */
.app-header {
  height: 72px;
  background: var(--header-bg);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 800;
  color: #D97706;
  cursor: pointer;
}

.logo-icon {
  font-size: 32px;
}

.header-center {
  flex: 1;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}
.header-center::-webkit-scrollbar {
  display: none;
}

.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
}

.breadcrumb-item {
  background: #FEF3C7;
  color: #92400E;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease;
}

.breadcrumb-item:active {
  transform: scale(0.95);
}

.breadcrumb-sep {
  color: #D97706;
  font-weight: 800;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  padding: 10px 36px 10px 40px;
  border-radius: 9999px;
  border: 2px solid #E5E7EB;
  background: #F9FAFB;
  font-size: 16px;
  outline: none;
  width: 200px;
  transition: width 0.2s ease, border-color 0.2s ease;
}

.search-box input:focus {
  width: 280px;
  border-color: var(--primary-color);
  background: #FFFFFF;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn {
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: 50%;
  border: 2px solid #E5E7EB;
  background: #FFFFFF;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.9);
}

.icon-btn.active {
  background: #FEF3C7;
  border-color: #F59E0B;
}

/* ================= GRID & CARDS ================= */
.library-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  border: 3px solid transparent;
}

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

.card:active {
  transform: scale(0.96);
}

.card-folder {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border-color: #FDE68A;
}

.card-folder .folder-icon {
  font-size: 64px;
  margin: 12px 0;
}

.card-book .thumbnail-wrap,
.card-pdf .thumbnail-wrap,
.thumbnail-wrap {
  width: 100%;
  aspect-ratio: 3/4;
  background: #F3F4F6;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-book .thumbnail-wrap img,
.card-pdf .thumbnail-wrap img,
.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-thumb-placeholder {
  font-size: 48px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 6px;
  word-break: break-word;
}

.card-meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.card-fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-progress-bar {
  width: 100%;
  height: 6px;
  background: #E5E7EB;
  border-radius: 9999px;
  margin-top: 8px;
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 9999px;
}

/* ================= VIEWER & WORKSPACE ================= */
.viewer-header {
  height: 72px;
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  z-index: 100;
}

.kid-btn {
  height: var(--touch-target);
  padding: 0 20px;
  border-radius: 9999px;
  border: none;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FEF3C7;
  color: #92400E;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, background 0.15s ease;
}

.kid-btn:active {
  transform: scale(0.95);
}

.export-btn {
  background: var(--accent-color);
  color: #FFFFFF;
}

.viewer-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 30%;
  overflow: hidden;
}

.book-title {
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-toggle-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #E5E7EB;
  background: #FFFFFF;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.page-indicator {
  font-size: 16px;
  font-weight: 800;
  color: #4B5563;
}

.workspace-area {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  background: #E5E7EB;
  align-items: center;
  justify-content: center;
}

.canvas-container {
  position: relative;
  box-shadow: var(--shadow-lg);
  background: #FFFFFF;
  touch-action: none;
  overflow: hidden;
  border-radius: 4px;
}

.layer-pdf,
.layer-drawing {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.layer-pdf {
  z-index: 1;
}

.layer-drawing {
  z-index: 2;
  touch-action: none;
  cursor: crosshair;
}

/* ================= FLOATING TOOLBAR ================= */
.floating-toolbar {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 50;
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

.color-btn:active {
  transform: scale(0.9);
}

.color-btn.active {
  border-color: #1F2937;
  transform: scale(1.15);
}

.rainbow-circle-btn {
  background: linear-gradient(135deg, #FF0055 0%, #FFAA00 25%, #00DD77 50%, #0099FF 75%, #AA00FF 100%);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid transparent;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.rainbow-circle-btn:hover {
  transform: scale(1.15);
}

.rainbow-circle-btn.has-color {
  border-color: #1F2937 !important;
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 4px #1F2937 !important;
}

.toolbar-divider {
  width: 80%;
  height: 2px;
  background: #E5E7EB;
  border-radius: 9999px;
}

.size-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.size-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #E5E7EB;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.size-btn.active {
  border-color: var(--primary-color);
  background: #FEF3C7;
}

.dot {
  background: #1F2937;
  border-radius: 50%;
}
.dot-sm { width: 6px; height: 6px; }
.dot-md { width: 12px; height: 12px; }
.dot-lg { width: 18px; height: 18px; }

.tool-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-btn {
  min-width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 2px solid #E5E7EB;
  background: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.tool-btn:active {
  transform: scale(0.92);
}

.tool-btn.active {
  background: #FEF3C7;
  border-color: #F59E0B;
}

.danger-btn:hover {
  background: #FEE2E2;
  border-color: #EF4444;
}

/* ================= MODAL & TOASTS ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 800;
  color: #1F2937;
}

.modal-close {
  background: #F3F4F6;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.modal-close:hover {
  background: #E5E7EB;
  transform: scale(1.1);
}

.color-modal-content {
  max-width: 520px;
  width: 95%;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 24px;
}

.kid-color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
  justify-items: center;
}

.palette-swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.15s ease;
}

.palette-swatch:hover {
  transform: scale(1.18);
}

.palette-swatch:active {
  transform: scale(0.9);
}

.palette-swatch.active {
  border-color: #1F2937;
  transform: scale(1.25);
  box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 4px #1F2937;
}

.custom-slider-section {
  background: #F9FAFB;
  border: 2px solid #E5E7EB;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 15px;
  color: #374151;
  margin-bottom: 12px;
}

.preview-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  box-shadow: 0 0 0 2px #D1D5DB;
  transition: background-color 0.1s ease;
}

.rainbow-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  border-radius: 12px;
  background: linear-gradient(to right, 
    #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
  outline: none;
  cursor: pointer;
}

.rainbow-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid #1F2937;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.rainbow-slider::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid #1F2937;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.select-color-btn {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 800;
  border-radius: var(--radius-md);
  background: var(--primary-color);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, background 0.15s ease;
}

.select-color-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.select-color-btn:active {
  transform: scale(0.98);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.math-challenge {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  margin: 16px 0;
  color: #D97706;
}

.math-input {
  width: 100%;
  padding: 12px;
  border: 2px solid #E5E7EB;
  border-radius: var(--radius-sm);
  font-size: 20px;
  text-align: center;
  margin-bottom: 16px;
  outline: none;
}

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.admin-btn {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 2px solid #E5E7EB;
  background: #F9FAFB;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.admin-btn:hover {
  background: #FEF3C7;
  border-color: #F59E0B;
}

.admin-status {
  margin-top: 12px;
  font-weight: 600;
  color: #059669;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  background: rgba(31, 41, 55, 0.95);
  color: #FFFFFF;
  padding: 12px 24px;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  animation: fadeInOut 2.5s ease forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(20px); }
  15% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-20px); }
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-emoji {
  font-size: 64px;
  margin-bottom: 16px;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
  .app-header {
    height: 64px;
    padding: 0 12px;
  }
  .app-logo .logo-text {
    display: none;
  }
  .search-box input {
    width: 140px;
  }
  .search-box input:focus {
    width: 180px;
  }
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
  }
  .floating-toolbar {
    right: 10px;
    padding: 10px 8px;
  }
  .color-btn {
    width: 30px;
    height: 30px;
  }
}

