/**
 * Materyaal Ders Oyunu Hazırlayıcı - Core Stylesheet
 * Brand colors: Navy (#1e3a8a), Cyan (#0891b2), Coral (#e11d48), Slate (#f8fafc)
 */

:root {
  --primary: #1e3a8a;
  --primary-dark: #172554;
  --primary-light: #3b82f6;
  --secondary: #0891b2;
  --secondary-light: #06b6d4;
  --accent: #e11d48;
  --accent-light: #f43f5e;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #090d16;
  --text-muted: #334155;
  --border: #cbd5e1;
  --border-focus: #2563eb;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.12), 0 2px 4px -2px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.12), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* High Contrast Mode */
body.high-contrast {
  --primary: #000080;
  --bg-main: #ffffff;
  --bg-card: #ffffff;
  --text-main: #000000;
  --text-muted: #111111;
  --border: #000000;
  --shadow-md: 0 0 0 2px #000000;
}

body.large-text {
  font-size: 1.25rem;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Screen reader utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Header & Navigation */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
  color: #ffffff;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 72px;
  border-bottom: 1px solid rgba(255,255,255,.16);
  backdrop-filter: saturate(135%) blur(12px);
  -webkit-backdrop-filter: saturate(135%) blur(12px);
}

.header-brand-wrap {
  display: flex;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: #ffffff;
}

.brand-icon {
  width: 46px;
  height: 46px;
  padding: 5px 7px;
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 5px 15px rgba(15, 23, 42, .22);
  overflow: hidden;
}

.brand-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: clamp(1.2rem, 1.8vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.8rem;
  opacity: 0.88;
  font-weight: 500;
}

/* Header Navigation Tabs */
.header-nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-nav-tabs {
  padding: .25rem;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  background: rgba(15,23,42,.16);
}

.nav-tab-btn.active {
  background: #ffffff;
  color: #1e3a8a;
  box-shadow: 0 5px 16px rgba(15,23,42,.2);
}

.header-search-input {
  border-color: rgba(255,255,255,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}

body.embed-fixed-mode {
  overscroll-behavior-x: contain;
}

.nav-tab-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.nav-tab-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.nav-tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Header Global Search */
.header-search-wrap {
  position: relative;
  max-width: 100%;
}

.header-search-input {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  width: 220px;
  max-width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  outline: none;
  transition: all 0.2s ease;
}

.header-search-input::placeholder {
  color: rgba(255, 255, 255, 0.75);
}

.header-search-input:focus {
  background: #ffffff;
  color: #0f172a;
  border-color: #ffffff;
  width: 280px;
  max-width: 100%;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}

.header-search-input:focus::placeholder {
  color: #94a3b8;
}

/* Header User Profile Dropdown */
.header-user-menu-wrap {
  position: relative;
}

.header-user-badge-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.35rem 0.85rem 0.35rem 0.45rem;
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.15s ease;
}

.header-user-badge-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.6);
}

.header-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #7c3aed;
  color: #ffffff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-username-text {
  font-weight: 700;
  font-size: 0.9rem;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-dropdown-caret {
  font-size: 0.65rem;
  opacity: 0.8;
}

.header-profile-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 0.5rem 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.mobile-sheet-handle,
.mobile-user-sheet-header,
.mobile-sheet-close-btn,
.header-profile-backdrop {
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  text-decoration: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.12s ease;
}

.dropdown-item:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.dropdown-item-danger {
  color: #dc2626;
}

.dropdown-item-danger:hover {
  background: #fef2f2;
  color: #b91c1c;
}

.dropdown-item-smartboard {
  background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
  border-bottom: 1px solid #e0f2fe;
  color: #0369a1;
  padding: 0.75rem 1.15rem;
}

.dropdown-item-smartboard:hover {
  background: linear-gradient(135deg, #dcfce7 0%, #dbeafe 100%);
  color: #0284c7;
}

.dropdown-item-smartboard .dropdown-item-icon {
  font-size: 1.25rem;
}

.dropdown-item-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.25;
}

.dropdown-item-title {
  color: #0369a1;
  font-size: 0.92rem;
  font-weight: 750;
}

.dropdown-item-subtitle {
  color: #64748b;
  font-size: 0.75rem;
  font-weight: normal;
}

.dropdown-badge-pill {
  margin-left: auto;
  font-size: 0.68rem;
  background: #0284c7;
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@keyframes scan-laser-anim {
  0% { top: 10px; }
  100% { top: 180px; }
}

.dropdown-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 0.4rem 0;
}

/* Mobile Toggle */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
}

.hamburger-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
}

.btn-action-large {
  min-height: 52px;
  padding: 0.75rem 1.5rem;
  font-size: 1.05rem;
}

/* Main Container */
.main-layout {
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  padding-bottom: 7.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Buttons */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  text-decoration: none;
}

button:focus-visible, .btn:focus-visible, [tabindex="0"]:focus-visible {
  outline: 3px solid var(--secondary-light);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border);
}
.btn-secondary:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-accent {
  background-color: var(--accent);
  color: #ffffff;
}
.btn-accent:hover {
  background-color: #be123c;
}

.btn-cyan {
  background-color: var(--secondary);
  color: #ffffff;
}
.btn-cyan:hover {
  background-color: #0e7490;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1.1rem;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

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

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
}

.input-error-highlight {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.25) !important;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-content {
  background-color: #ffffff;
  border-radius: var(--radius);
  max-width: 580px;
  width: 100%;
  max-height: min(90vh, calc(100dvh - 2rem));
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: modalFadeIn 0.2s ease-out;
}

#profile-setup-modal { overflow:hidden; touch-action:pan-y; }
#profile-setup-modal .profile-settings-content { width:min(580px,95vw); height:min(90dvh,760px); max-height:calc(100dvh - 2rem); overflow-y:auto!important; overflow-x:hidden; overscroll-behavior:contain; touch-action:pan-y; -webkit-overflow-scrolling:touch; scrollbar-gutter:stable; }
.settings-admin-fold { margin-bottom:1rem; border:1px solid #e8d39c; border-radius:14px; background:#fffdf7; overflow:hidden; }
.settings-admin-fold>summary { display:flex; align-items:center; gap:.65rem; padding:1rem; cursor:pointer; list-style:none; color:#334155; }
.settings-admin-fold>summary::-webkit-details-marker { display:none; }
.settings-admin-fold>summary>div { flex:1; min-width:0; }
.settings-admin-fold>summary strong,.settings-admin-fold>summary small { display:block; }
.settings-admin-fold>summary strong { font-size:.9rem; color:#0f172a; }
.settings-admin-fold>summary small { margin-top:.15rem; color:#8a6417; font-size:.72rem; }
.settings-fold-arrow { font-size:1.25rem; transition:transform .2s; }
.settings-admin-fold[open] .settings-fold-arrow { transform:rotate(180deg); }
.settings-admin-content { padding:0 1rem 1rem; border-top:1px solid #f0dfb5; }
.settings-admin-toolbar { display:flex; align-items:center; justify-content:space-between; gap:.75rem; padding:.8rem 0; }
.settings-admin-toolbar p { margin:0; color:#64748b; font-size:.76rem; }
.settings-admin-groups { display:grid; grid-template-columns:1fr 1fr; gap:.65rem; }
.settings-admin-group { padding:.7rem; border:1px solid #e2e8f0; border-radius:11px; background:#fff; }
.settings-admin-group h5 { display:flex; justify-content:space-between; margin:0 0 .4rem; color:#334155; font-size:.76rem; }
.settings-admin-user { display:grid; gap:.4rem; padding:.55rem 0; border-top:1px solid #edf2f7; }
.settings-admin-user strong { overflow-wrap:anywhere; font-size:.73rem; }
.settings-admin-user .btn { width:100%; font-size:.7rem; }
.settings-admin-empty { margin:.6rem 0; color:#94a3b8; font-size:.72rem; text-align:center; }

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.hidden {
  display: none !important;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background-color: #ffffff;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce), (update: slow) {
  *, ::before, ::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body.reduced-motion * {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

.inline-error-msg {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.memory-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:1rem; margin-top:1rem; }
.memory-card { min-height:110px; border:3px solid var(--primary); border-radius:var(--radius); background:#fff; color:var(--primary); font-size:1.25rem; font-weight:800; padding:1rem; cursor:pointer; }
.memory-card:disabled { background:#dcfce7; border-color:#16a34a; color:#166534; }
.wheel-board { text-align:center; }
.wheel-disc { width:180px; height:180px; margin:1rem auto; border-radius:50%; display:grid; place-items:center; font-size:4rem; background:conic-gradient(#2563eb 0 25%,#f59e0b 0 50%,#10b981 0 75%,#8b5cf6 0); border:8px solid #fff; box-shadow:0 0 0 4px var(--primary); }
.wheel-spinning { animation:wheelSpin .6s ease-in-out; }
@keyframes wheelSpin { to { transform:rotate(720deg); } }
.wheel-result { min-height:70px; font-size:1.35rem; font-weight:700; margin:1rem 0; }
.wheel-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:.75rem; }
.word-answer-input { max-width:520px; margin:1.25rem auto; font-size:1.4rem; min-height:58px; }

/* Error highlighting */
.input-error-highlight {
  outline: 3px solid #dc2626 !important;
  outline-offset: 2px !important;
  border-color: #dc2626 !important;
  background-color: #fef2f2 !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.25) !important;
  transition: outline 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

/* 3-Step Teacher Workflow Bar */
.teacher-steps-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  background: #ffffff;
  padding: 0.5rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.teacher-step-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  font-family: inherit;
}

.teacher-step-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.teacher-step-btn.active {
  background: #eff6ff;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.teacher-step-btn .step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}

.teacher-step-btn.active .step-num {
  background: var(--primary);
  color: #ffffff;
}

.teacher-step-btn .step-info {
  display: flex;
  flex-direction: column;
}

.teacher-step-btn .step-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.teacher-step-btn.active .step-title {
  color: var(--primary);
}

.teacher-step-btn .step-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.auth-modal-content {
  max-width: 480px;
}

.auth-notice {
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid #f59e0b;
  border-radius: 0.65rem;
  background: #fffbeb;
  color: #92400e;
  line-height: 1.5;
}

.auth-description {
  margin-bottom: 1rem;
  color: #475569;
  line-height: 1.55;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.auth-message {
  min-height: 1.5rem;
  margin: 0.35rem 0 0.85rem;
  color: #166534;
  font-weight: 600;
}

.auth-message.is-error {
  color: #b91c1c;
}

.auth-signed-in-label {
  color: #64748b;
  font-size: 0.85rem;
}

.auth-user-email {
  margin: 0.25rem 0 1rem;
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.cloud-game-status {
  min-height: 1.5rem;
  margin-top: 0.85rem;
  color: #475569;
  font-weight: 600;
}

.cloud-game-status.success { color: #15803d; }
.cloud-game-status.error { color: #b91c1c; }
.cloud-game-status.working { color: #1d4ed8; }

@media (max-width: 768px) {
  .teacher-steps-bar {
    flex-direction: column;
    gap: 0.5rem;
  }
  .teacher-step-btn {
    padding: 0.5rem 0.75rem;
  }
}
