/* ===========================================
   DuoMate - Common Styles (Light Theme)
   =========================================== */

/* --- Reset & Custom Properties --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg-primary: #f7f7f7;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f0;
  --bg-green-light: #e8f5e1;
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --border-light: #f0f0f0;

  /* Duolingo brand */
  --duo-green: #58cc02;
  --duo-green-dark: #46a302;
  --duo-green-light: #89e219;
  --duo-blue: #1cb0f6;
  --duo-orange: #ff9600;
  --duo-red: #ff4b4b;
  --duo-purple: #ce82ff;
  --duo-yellow: #ffc800;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--duo-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: 32px 0;
}

/* --- Navigation --- */
.nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.nav-logo:hover { text-decoration: none; }

.nav-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: block;
  object-fit: cover;
}

.nav-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--bg-green-light);
  color: var(--duo-green-dark);
  font-weight: 600;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.nav-toggle:active { background: var(--bg-hover); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--duo-green);
  color: #fff;
  box-shadow: 0 4px 0 var(--duo-green-dark);
}
.btn-primary:hover { background: #4cb801; }
.btn-primary:active { box-shadow: 0 2px 0 var(--duo-green-dark); transform: translateY(2px); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}
.btn-secondary:hover { border-color: var(--duo-green); color: var(--duo-green); }

.btn-kakao {
  background: #FEE500;
  color: #000000;
  box-shadow: 0 4px 0 #d4bf00;
}
.btn-kakao:hover { background: #f0d900; }

.btn-danger {
  background: var(--duo-red);
  color: #fff;
  box-shadow: 0 4px 0 #d43a3a;
}
.btn-danger:hover { background: #e04040; }

.btn-lg {
  padding: 14px 28px;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

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

.card-body {
  padding: 20px;
}

.card-body-flush {
  padding: 0;
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

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

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}

.stat-icon.green { background: var(--bg-green-light); color: var(--duo-green); }
.stat-icon.blue { background: rgba(28, 176, 246, 0.12); color: var(--duo-blue); }
.stat-icon.orange { background: rgba(255, 150, 0, 0.12); color: var(--duo-orange); }
.stat-icon.purple { background: rgba(206, 130, 255, 0.12); color: var(--duo-purple); }
.stat-icon.red { background: rgba(255, 75, 75, 0.12); color: var(--duo-red); }

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

/* --- Leaderboard --- */
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.leaderboard-item:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.leaderboard-item:last-child { border-bottom: none; }

.leaderboard-rank {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: #000; }
.rank-2 { background: linear-gradient(135deg, #e0e0e0, #b0b0b0); color: #000; }
.rank-3 { background: linear-gradient(135deg, #CD7F32, #B87333); color: #fff; }
.rank-default { background: var(--bg-hover); color: var(--text-muted); }

.leaderboard-user {
  flex: 1;
  min-width: 0;
}

.leaderboard-username {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.leaderboard-value {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

/* --- Badge --- */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-fire { background: rgba(255, 150, 0, 0.12); color: var(--duo-orange); }
.badge-xp { background: rgba(28, 176, 246, 0.12); color: var(--duo-blue); }
.badge-streak { background: var(--bg-green-light); color: var(--duo-green); }
.badge-status-done { background: var(--bg-green-light); color: var(--duo-green); }
.badge-status-pending { background: rgba(255, 75, 75, 0.1); color: var(--duo-red); }
.badge-status-notyet { background: var(--bg-hover); color: var(--text-secondary); }

/* Badge card (collection) */
.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: all 0.2s;
}

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

.badge-card.earned {
  border-color: var(--duo-green);
  background: var(--bg-green-light);
}

.badge-card.unearned {
  opacity: 0.45;
  filter: grayscale(0.5);
}

.badge-emoji {
  font-size: 2rem;
  margin-bottom: 8px;
}

.badge-name {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.badge-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Badge grid */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  width: fit-content;
}

.tab {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  background: var(--bg-secondary);
  color: var(--duo-green-dark);
  box-shadow: var(--shadow-sm);
}

/* --- Progress Bar --- */
.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--duo-green), var(--duo-green-light));
  transition: width 0.5s ease;
  min-width: 2px;
}

/* --- Avatar --- */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--duo-green), var(--duo-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

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

.avatar-lg {
  width: 80px;
  height: 80px;
  font-size: 1.8rem;
}

/* --- Empty State --- */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.95rem;
}

.empty-state-img {
  display: block;
  width: 160px;
  max-width: 60%;
  height: auto;
  margin: 0 auto 16px;
}

.empty-state .empty-state-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.empty-state-cta {
  margin-top: 16px;
}

/* --- Loading --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--duo-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Footer --- */
.footer {
  padding: 32px 0 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  margin-top: 48px;
}

.footer-links { margin-bottom: 12px; }
.footer-links a { color: var(--text-secondary); }
.footer-links a:hover { color: var(--text-primary); }
.footer-sep { margin: 0 6px; color: var(--text-muted); }
.footer-service {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.footer-biz {
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.6;
}
.footer-biz a { color: var(--text-muted); }
.footer-biz a:hover { color: var(--text-primary); }
.footer-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.footer-copy {
  color: var(--text-muted);
  margin-top: 10px;
}

/* --- Section Headers --- */
.section-header {
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* --- Utility --- */
.text-green { color: var(--duo-green); }
.text-blue { color: var(--duo-blue); }
.text-orange { color: var(--duo-orange); }
.text-red { color: var(--duo-red); }
.text-purple { color: var(--duo-purple); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* --- Form Input --- */
.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color 0.2s;
  outline: none;
  min-height: 44px;
}
.form-input:focus {
  border-color: var(--duo-green);
}
.form-input::placeholder {
  color: var(--text-muted);
}

/* --- Nav Auth --- */
.nav-auth, #nav-auth {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.nav-user-link {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  transition: background 0.2s;
}
.nav-user-link:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-username {
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-nav {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--duo-green), var(--duo-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }

  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    z-index: 101;
  }
  .nav-toggle { display: flex; }
  .nav-link { padding: 12px 14px; }
  .btn-sm { padding: 8px 14px; min-height: 36px; }

  #nav-auth {
    margin-left: 0;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
  }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 1.5rem; }

  .badge-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  .page-content { padding: 20px 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .tabs { width: 100%; }
  .tab { flex: 1; text-align: center; padding: 8px 10px; font-size: 0.8rem; }
  .btn-lg { padding: 12px 20px; font-size: 0.95rem; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .card-body { padding: 16px; }
  .leaderboard-item { padding: 12px 16px; gap: 10px; }
  .leaderboard-meta { font-size: 0.75rem; }
  .badge-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
  .badge-name { font-size: 0.75rem; }
  .badge-desc { font-size: 0.65rem; }
  .section-title { font-size: 1.2rem; }
  .empty-state { padding: 32px 16px; }
  .footer { font-size: 0.75rem; }
}
