@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&display=swap');

:root {
  --color-red: #eb2f06;
  --color-blue: #1e3799;
  --color-light-blue: #4a69bd;
  --color-yellow: #f6b93b;
  --color-green: #78e08f;
  --color-purple: #82ccdd;
  --color-orange: #fa983a;
  --color-bg: #f1f2f6;
  --color-card-bg: #ffffff;
  --color-text-main: #2f3542;
  --color-text-light: #747d8c;
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-float: 0 20px 40px rgba(0, 0, 0, 0.15);
  --radius-xl: 28px;
  --radius-md: 16px;
  --radius-round: 9999px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  background-color: var(--color-bg);
  background-image: radial-gradient(#dfe4ea 2px, transparent 2px);
  background-size: 30px 30px;
  color: var(--color-text-main);
  min-height: 100vh;
}

button {
  border: none;
  cursor: pointer;
  background: none;
  font-family: inherit;
}

a {
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  position: relative;
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 60px;
  text-align: center;
}

.profile-image {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 50%;
  border: 6px solid var(--color-card-bg);
  box-shadow: var(--shadow-card);
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pop-in {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fade-up {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.profile-header h1 {
  font-size: 3rem;
  margin: 20px 0 10px 0;
  font-weight: 800;
  color: var(--color-blue);
  letter-spacing: -1px;
  animation: fade-up 0.5s 0.2s both;
}

.status-badge {
  font-size: 1.2rem;
  color: var(--color-text-light);
  background: var(--color-card-bg);
  padding: 10px 25px;
  border-radius: var(--radius-round);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  animation: fade-up 0.5s 0.3s both;
}

/* Points Widget */
.points-widget {
  background: linear-gradient(135deg, #1e3799 0%, #0c2461 100%);
  color: white;
  padding: 20px;
  border-radius: 20px;
  margin: 0 auto 30px auto;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  cursor: pointer;
}
.points-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.2rem;
  font-weight: bold;
}
.week-label {
  opacity: 0.8;
  font-weight: normal;
  font-size: 0.9rem;
}
.progress-track {
  width: 100%;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
}
.bar-segment { height: 100%; transition: width 0.6s ease-out; }
.bar-segment.mathe { background-color: #27ae60; }
.bar-segment.english { background-color: #2980b9; }
.bar-segment.other { background-color: #8e44ad; }
.bar-segment.generic { background-color: #f1c40f; }
.progress-track .bar-segment:first-child { border-radius: 10px 0 0 10px; }
.progress-track .bar-segment:last-child { border-radius: 0 10px 10px 0; }
.progress-track .bar-segment:only-child { border-radius: 10px; }
.points-status { text-align: right; font-weight: bold; }
.phase-complete {
  background: rgba(255, 255, 255, 0.15);
  padding: 8px 12px;
  border-radius: 10px;
  text-align: center;
  font-weight: bold;
}
.chart-legend {
  display: flex;
  gap: 15px;
  justify-content: center;
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.mathe { background-color: #27ae60; }
.dot.english { background-color: #2980b9; }
.dot.other { background-color: #8e44ad; }
.dot.generic { background-color: #f1c40f; }
.points-info {
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 10px;
  margin-top: 5px;
  text-align: center;
}
.history-section {
  margin-top: 15px;
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 15px;
  display: none;
}
.history-section.open { display: block; }
.history-section h3 { margin: 0 0 10px 0; font-size: 1rem; opacity: 0.9; }
.history-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.history-item:last-child { border-bottom: none; }
.h-week { font-family: monospace; opacity: 0.8; }
.h-points { font-weight: bold; color: #f1c40f; }
.activity-timeline {
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.1);
  padding: 10px;
  border-radius: 10px;
  max-height: 300px;
  overflow-y: auto;
}
.activity-timeline h3 {
  margin-top: 0; margin-bottom: 10px; font-size: 1rem;
  padding-bottom: 5px; border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.timeline-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; margin-bottom: 5px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05); font-size: 0.9rem;
}
.timeline-item.log-correct { border-left: 4px solid #2ecc71; }
.timeline-item.log-wrong { border-left: 4px solid #e74c3c; opacity: 0.8; }
.log-time { font-family: monospace; opacity: 0.6; font-size: 0.8rem; min-width: 45px; }
.log-game { font-weight: bold; color: #ffd700; min-width: 60px; }
.log-details { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-icon { font-size: 1.2rem; }

/* Weekly History Chart */
.wh {
  background: var(--color-card-bg);
  border-radius: var(--radius-xl);
  padding: clamp(14px, 2.5vw, 24px);
  margin-bottom: 30px;
  box-shadow: var(--shadow-card);
}
.wh-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: clamp(40px, 5vw, 50px); }
.wh-title { font-size: clamp(0.85rem, 1.5vw, 1.05rem); font-weight: 700; color: var(--color-text-main); margin: 0; }
.wh-subtitle { font-size: clamp(0.6rem, 1vw, 0.78rem); color: var(--color-text-light); }
.wh-loading { display: flex; gap: clamp(3px, 0.5vw, 6px); align-items: flex-end; height: clamp(80px, 14vw, 140px); padding-bottom: 20px; }
.wh-skeleton { flex: 1; border-radius: 4px; background: linear-gradient(90deg, #eee 25%, #e0e0e0 50%, #eee 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; height: 30%; }
.wh-skeleton:nth-child(2) { height: 50%; }
.wh-skeleton:nth-child(3) { height: 70%; }
.wh-skeleton:nth-child(4) { height: 40%; }
.wh-skeleton:nth-child(5) { height: 60%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.wh-empty { font-size: clamp(0.75rem, 1.3vw, 0.9rem); color: var(--color-text-light); text-align: center; padding: 24px 0; }
.wh-chart { display: flex; align-items: stretch; gap: clamp(4px, 1vw, 8px); height: clamp(180px, 30vw, 280px); position: relative; overflow: visible; margin-bottom: 22px; }
.wh-goal-line { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--color-blue); opacity: 0.25; z-index: 2; pointer-events: none; }
.wh-goal-label { position: absolute; right: 0; top: -16px; font-size: clamp(0.5rem, 0.9vw, 0.68rem); color: var(--color-blue); font-weight: 700; opacity: 0.7; }
.wh-col { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
.wh-bar-area { width: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.wh-bar { width: 80%; max-width: clamp(30px, 5vw, 50px); min-height: 3px; border-radius: 6px 6px 3px 3px; background: #e8eaf0; position: relative; transition: height 0.6s ease-out; }
.wh-bar.reached { background: linear-gradient(180deg, var(--color-blue) 0%, var(--color-light-blue) 100%); box-shadow: 0 0 8px rgba(30, 55, 153, 0.2); }
.wh-bar.current { border: 1.5px solid var(--color-blue); background: rgba(30, 55, 153, 0.08); }
.wh-bar.current.reached { background: linear-gradient(180deg, var(--color-blue) 0%, var(--color-light-blue) 100%); border-color: transparent; }
.wh-val { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: clamp(0.6rem, 1.1vw, 0.78rem); font-weight: 700; color: var(--color-text-light); white-space: nowrap; }
.wh-bar.reached .wh-val { color: var(--color-blue); }
.wh-reached-icon { position: absolute; top: -34px; left: 50%; transform: translateX(-50%); font-size: 0.85rem; }
.wh-stats { display: flex; justify-content: center; gap: 16px; margin-top: 8px; font-size: clamp(0.6rem, 1vw, 0.75rem); color: var(--color-text-light); }
.wh-stat { display: flex; align-items: center; gap: 4px; }
.wh-label { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: clamp(0.45rem, 0.8vw, 0.62rem); color: var(--color-text-light); white-space: nowrap; }
.wh-label.current { color: var(--color-blue); font-weight: 700; }

/* Project Groups */
.project-group { margin-bottom: 50px; }
.group-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--color-card-bg);
}
.group-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-text-main);
  margin: 0;
}
.group-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-light);
  font-weight: 400;
}
@media (max-width: 600px) {
  .group-header { flex-direction: column; gap: 2px; }
  .group-title { font-size: 1.2rem; }
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
}
.card-link { display: block; }
.project-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-xl);
  padding: 30px;
  height: 100%;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fade-up 0.4s both;
}
.project-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-float); }
.card-top-bar { position: absolute; top: 0; left: 0; right: 0; height: 12px; }
.card-emoji { font-size: 4.5rem; margin-bottom: 15px; margin-top: 10px; }
.project-card h2 { margin: 0 0 10px 0; font-size: 1.6rem; color: var(--color-text-main); font-weight: 700; }
.project-card p { margin: 0; color: var(--color-text-light); font-size: 1.1rem; line-height: 1.5; }
.card-points-badge {
  position: absolute; top: 25px; right: 15px;
  background: #f1c40f; color: #2c3e50; font-size: 0.9rem; font-weight: bold;
  padding: 5px 12px; border-radius: 99px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 2; transform: rotate(10deg); animation: pulse-badge 2s infinite; border: 2px solid white;
}
@keyframes pulse-badge {
  0%, 100% { transform: rotate(10deg) scale(1); }
  50% { transform: rotate(10deg) scale(1.1); }
}
.card-external-badge {
  position: absolute; top: 25px; right: 15px;
  background: #e0f7f3; color: #00897b; font-size: 0.8rem; font-weight: bold;
  padding: 4px 10px; border-radius: 99px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  z-index: 2; border: 1.5px solid #b2dfdb;
}

.fun-section { text-align: center; margin-top: 80px; margin-bottom: 60px; }
.confetti-button {
  background: var(--color-yellow); color: #fff; font-size: 1.5rem; font-weight: 800;
  padding: 18px 50px; border-radius: var(--radius-round);
  box-shadow: 0 8px 0 #c28b0f, 0 20px 20px rgba(0, 0, 0, 0.15);
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.1); border: 2px solid rgba(255, 255, 255, 0.3);
  transition: transform 0.1s;
}
.confetti-button:active { transform: translateY(4px); box-shadow: 0 4px 0 #c28b0f; }

/* Lock Screen */
.lock-screen {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  height: 100vh; background-color: #2f3542; color: white; text-align: center;
}
.lock-card {
  background: white; padding: 40px; border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); width: 90%; max-width: 400px;
  color: #2f3542; animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.lock-avatar-container {
  width: 100px; height: 100px; margin: 0 auto 20px;
  background: #f1f2f6; border-radius: 50%; overflow: hidden; border: 4px solid #eb2f06;
}
.lock-avatar-container img { width: 100%; height: 100%; object-fit: cover; }
.lock-input {
  width: 100%; padding: 15px; font-size: 1.2rem; border: 2px solid #ddd;
  border-radius: 12px; margin: 20px 0; text-align: center; outline: none;
  font-family: inherit; transition: border-color 0.2s;
}
.lock-input:focus { border-color: #eb2f06; }
.unlock-btn {
  width: 100%; padding: 15px; background-color: #eb2f06; color: white;
  font-size: 1.2rem; font-weight: bold; border-radius: 12px; transition: transform 0.1s;
}
.unlock-btn:active { transform: scale(0.98); }
.error-msg { color: #eb2f06; font-weight: bold; margin-top: 10px; }
.admin-link {
  display: inline-block; margin-top: 18px; font-size: 0.82rem; color: rgba(255,255,255,0.35);
  text-decoration: none; transition: color 0.2s;
}
.admin-link:hover { color: rgba(255,255,255,0.7); }
.shake { animation: shake-it 0.4s; }
@keyframes shake-it {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  background: var(--color-card-bg);
  padding: 10px 16px;
  border-radius: var(--radius-round);
  box-shadow: var(--shadow-sm);
  margin-bottom: 30px;
  animation: fade-up 0.4s both;
}
.top-bar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--color-text-light);
  font-size: 0.92rem; font-weight: 600; padding: 8px 18px;
  border-radius: var(--radius-round); transition: all 0.2s;
  font-family: inherit;
}
.top-bar-btn:hover { background: var(--color-bg); color: var(--color-text-main); }
.top-bar-btn--logout:hover { background: #ffeaea; color: #eb2f06; }
.top-bar-icon { font-size: 1rem; }

/* Password Change Modal */
.pw-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(47, 53, 66, 0.45); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: pw-overlay-in 0.2s ease-out;
}
@keyframes pw-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.pw-dialog {
  background: var(--color-card-bg); border-radius: var(--radius-xl);
  padding: 40px 32px 32px; width: 100%; max-width: 400px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0,0,0,0.04);
  animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  text-align: center; position: relative;
}
.pw-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-bg); color: var(--color-text-light);
  font-size: 1.4rem; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; line-height: 1; font-family: inherit;
}
.pw-close:hover { background: #ffeaea; color: #eb2f06; transform: scale(1.1); }
.pw-dialog-icon { font-size: 3rem; margin-bottom: 8px; }
.pw-dialog-title {
  font-size: 1.4rem; font-weight: 800; margin: 0 0 6px;
  color: var(--color-text-main);
}
.pw-hint {
  font-size: 0.9rem; color: var(--color-text-light);
  margin: 0 0 24px; line-height: 1.5;
}
.pw-fields { text-align: left; }
.pw-label {
  display: block; font-size: 0.82rem; font-weight: 700;
  color: var(--color-text-light); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.pw-field {
  width: 100%; padding: 13px 16px; font-size: 1.05rem;
  border: 2px solid var(--color-bg); border-radius: var(--radius-md);
  margin-bottom: 14px; background: var(--color-bg);
  font-family: inherit; outline: none; transition: all 0.2s;
  box-sizing: border-box;
}
.pw-field:focus {
  border-color: var(--color-blue); background: #fff;
  box-shadow: 0 0 0 4px rgba(30, 55, 153, 0.1);
}
.pw-field::placeholder { color: #b2b8c3; }
.pw-error {
  color: #eb2f06; font-weight: 700; font-size: 0.9rem;
  margin: 0 0 14px; padding: 10px 14px; background: #fff5f5;
  border-radius: var(--radius-md); border: 1px solid #ffe0e0;
  text-align: left;
}
.pw-success {
  color: #27ae60; font-weight: 700; font-size: 0.9rem;
  margin: 0 0 14px; padding: 10px 14px; background: #f0fff4;
  border-radius: var(--radius-md); border: 1px solid #c6f6d5;
  text-align: left;
}
.pw-actions { display: flex; gap: 10px; margin-top: 4px; }
.pw-btn-cancel {
  flex: 1; padding: 14px; border-radius: var(--radius-md); font-size: 0.95rem;
  font-weight: 600; background: var(--color-bg); color: var(--color-text-light);
  font-family: inherit; transition: all 0.2s;
}
.pw-btn-cancel:hover { background: #dfe4ea; color: var(--color-text-main); }
.pw-btn-save {
  flex: 1.2; padding: 14px; border-radius: var(--radius-md); font-size: 0.95rem;
  font-weight: 700; background: linear-gradient(135deg, var(--color-blue), var(--color-light-blue));
  color: #fff; font-family: inherit; transition: all 0.25s;
  box-shadow: 0 4px 14px rgba(30, 55, 153, 0.25);
}
.pw-btn-save:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(30, 55, 153, 0.35);
}
.pw-btn-save:active:not(:disabled) { transform: translateY(0); }
.pw-btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 600px) {
  .profile-header h1 { font-size: 2.2rem; }
  .projects-grid { grid-template-columns: 1fr; }
  .dashboard-container { padding: 20px; }
  .top-bar { margin-bottom: 20px; padding: 8px 10px; gap: 4px; }
  .top-bar-btn { font-size: 0.82rem; padding: 7px 12px; }
  .pw-dialog { padding: 28px 20px 24px; }
  .pw-actions { flex-direction: column; }
  .pw-btn-save { flex: 1; }
}
