/* AI4TEC - Ana Stil Dosyası v2 */
/* Dark/Light tema, mobile-first, app-like UI */

/* === CSS VARIABLES === */
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --bg-hover: #374151;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59,130,246,0.15);
  --success: #10b981;
  --success-bg: rgba(16,185,129,0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.15);
  --border: #334155;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
  --header-height: 56px;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --bg-hover: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }
input, select, textarea, button { font: inherit; color: inherit; }

/* Selection */
::selection { background: var(--accent); color: #fff; }
::-moz-selection { background: var(--accent); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === LAYOUT === */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.app-header .logo { transition: opacity 0.2s; }
.app-header .logo:active { opacity: 0.7; }
.app-header .logo img { height: 28px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 0.85rem; color: var(--text-muted); }

.app-main {
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 80px);
  max-width: 640px;
  margin: 0 auto;
}

.app-footer {
  text-align: center;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.6;
}

/* === BOTTOM NAV === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  height: var(--nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s, transform 0.15s;
  text-decoration: none;
  min-height: 48px;
}
.nav-item svg { width: 20px; height: 20px; }
.nav-item.active { color: var(--accent); }
.nav-item:hover { color: var(--accent); }
.nav-item:active { transform: scale(0.92); }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }

/* Tema ikon */
[data-theme="dark"] .theme-icon-dark { display: block; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: block; }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; min-height: 44px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
input:hover, select:hover, textarea:hover {
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}
select { cursor: pointer; }

/* === CARDS === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s, transform 0.3s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-body { padding: 16px; }
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

/* === ALERTS === */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 4px solid transparent;
  animation: slideIn 0.3s ease;
}
.alert-success { background: var(--success-bg); color: var(--success); border-left-color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-left-color: var(--warning); }

/* === BADGES === */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
}
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.warning { background: var(--warning-bg); color: var(--warning); }

/* === LOGIN === */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}
.login-container {
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}
.login-form { margin-bottom: 24px; }
.login-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.5;
}

/* === UPLOAD === */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: scale(1.01);
}
.upload-area svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin: 0 auto 12px;
  transition: color 0.2s;
}
.upload-area:hover svg { color: var(--accent); }
.upload-area p {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.upload-preview {
  margin-top: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: none;
  background: var(--bg-input);
  padding: 12px;
  border: 1px solid var(--border);
  animation: fadeInScale 0.3s ease;
}
.upload-preview img {
  max-height: 300px;
  margin: 0 auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Sik secici (A-E butonlari) */
.answer-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.answer-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.answer-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.answer-btn:active { transform: scale(0.9); }
.answer-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.answer-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
}
.answer-btn.correct {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,0.4);
  animation: popIn 0.3s ease;
}
.answer-btn.wrong {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,0.4);
  animation: shake 0.4s ease;
}

/* Ders secici */
.subject-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.subject-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.subject-chip:hover { border-color: var(--accent); }
.subject-chip.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* Son yuklenen sorular grid */
.questions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.question-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}
.question-thumb:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(59,130,246,0.2);
}
.question-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.question-thumb .thumb-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 0.6rem;
  background: rgba(0,0,0,0.6);
  color: #fff;
  backdrop-filter: blur(4px);
}
.thumb-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(239,68,68,0.85);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
.question-thumb:hover .thumb-delete { opacity: 1; }
.thumb-delete:hover { background: #dc2626; transform: scale(1.1); }

/* === TEST === */
.test-config { margin-bottom: 24px; }
.subject-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}
.subject-row:hover { background: var(--bg-hover); }
.subject-row:last-child { border-bottom: none; }
.subject-name { font-weight: 500; flex: 1; }
.subject-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 12px;
}
.subject-input {
  width: 60px;
  text-align: center;
  padding: 6px;
}

/* Test cozme ekrani */
.test-progress {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  margin-bottom: 16px;
  overflow: hidden;
}
.test-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 3px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.test-counter {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
  margin: 0 auto 12px;
  width: auto;
}
.question-img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin: 12px 0;
}
.test-nav {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 16px;
}

/* Test listesi */
.test-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}
.test-list-item:hover { background: var(--bg-hover); }
.test-list-item:last-child { border-bottom: none; }
.test-info { flex: 1; }
.test-info small { color: var(--text-muted); font-size: 0.8rem; }
.test-score {
  font-weight: 700;
  font-size: 1.1rem;
}
.test-score.good { color: var(--success); }
.test-score.mid { color: var(--warning); }
.test-score.bad { color: var(--danger); }

/* === STATS === */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(59,130,246,0.15);
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Progress bars */
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.progress-label {
  width: 80px;
  font-size: 0.85rem;
  font-weight: 500;
  flex-shrink: 0;
}
.progress-bar {
  flex: 1;
  height: 20px;
  background: var(--bg-input);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-fill.correct { background: linear-gradient(90deg, var(--success), #34d399); }
.progress-fill.wrong { background: linear-gradient(90deg, var(--danger), #f87171); }
.progress-pct {
  width: 45px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* Recent answers table */
.answer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.answer-table th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.answer-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.answer-table tr:hover { background: var(--bg-hover); }
.answer-table .icon-correct { color: var(--success); font-weight: 700; }
.answer-table .icon-wrong { color: var(--danger); font-weight: 700; }

/* === SPINNER === */
.spinner-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  backdrop-filter: blur(4px);
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-text { color: #fff; font-size: 0.9rem; }

/* === UTILITIES === */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.container { max-width: 640px; margin: 0 auto; }
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* Comparison view */
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.comparison-label {
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.comparison img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  background: var(--accent-light);
  border-radius: var(--radius);
  margin: 16px 0;
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: 0.6; }
.empty-state p { font-size: 0.9rem; line-height: 1.6; }

/* === ANIMATIONS === */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes popIn {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* === SORU HAVUZU (Klasörler) === */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.folder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 6px 10px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}
.folder-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.folder-empty { opacity: 0.5; }
.folder-icon svg { width: 28px; height: 28px; color: var(--accent); margin-bottom: 4px; }
.folder-name { font-size: 0.75rem; font-weight: 600; line-height: 1.2; }
.folder-count { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; }
.folder-solved { font-size: 0.6rem; color: var(--success); margin-top: 1px; }

/* Çözülmüş sorular grid */
.solved-grid .question-thumb {
  opacity: 0.65;
  position: relative;
}
.solved-grid .question-thumb::after {
  content: '\2713';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* === RESPONSIVE === */
@media (max-width: 380px) {
  .app-main { padding: 12px; }
  .login-container { max-width: 100%; }
  .answer-selector { gap: 6px; }
  .folder-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .answer-table { font-size: 0.75rem; }
  .answer-table td, .answer-table th { padding: 6px 4px; }
}

@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .questions-grid { grid-template-columns: repeat(4, 1fr); }
  .subject-select { grid-template-columns: 1fr 1fr 1fr; }
}

@media (min-width: 1024px) {
  .app-main { max-width: 720px; }
}
