/* Image Optimization Styles */

/* Lazy loading images - add loading attribute support */
img[loading="lazy"] {
  /* Placeholder while loading */
  background: var(--md-default-bg-color);
  min-height: 100px;
}

/* Responsive images */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1em auto;
}

/* Image captions */
figure {
  margin: 2em 0;
  text-align: center;
}

figure img {
  margin-bottom: 0.5em;
}

figcaption {
  font-size: 0.9em;
  color: var(--md-default-fg-color--light);
  font-style: italic;
}

/* Image optimization for print */
@media print {
  img {
    max-width: 100%;
    page-break-inside: avoid;
  }
}

/* Performance: Reduce layout shift with aspect ratio boxes */
.img-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.img-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* SVG optimization */
svg {
  max-width: 100%;
  height: auto;
}

/* ==================== Progress Tracking Styles ==================== */

/* Visited page icon in navigation */
.md-nav__link.visited {
  position: relative;
}

.visited-icon {
  color: #4caf50;
  font-weight: bold;
  margin-left: 4px;
  font-size: 0.9em;
}

/* Progress container */
.progress-container {
  margin: 24px 0;
  padding: 20px;
  background: var(--md-code-bg-color);
  border-radius: 8px;
  border-left: 4px solid var(--md-primary-fg-color);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-title {
  font-weight: 600;
  font-size: 1.1em;
  color: var(--md-default-fg-color);
}

.progress-percentage {
  font-weight: 700;
  font-size: 1.3em;
  color: var(--md-primary-fg-color);
}

/* Progress bar */
.progress-bar {
  height: 12px;
  background: var(--md-default-fg-color--lightest);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.progress-bar-large {
  height: 16px;
  border-radius: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  border-radius: 6px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.progress-stats {
  margin-top: 8px;
  font-size: 0.9em;
  color: var(--md-default-fg-color--light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Progress overview */
.progress-overview {
  margin: 32px 0;
  padding: 24px;
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 12px;
}

.progress-overview h2 {
  margin-top: 0;
  color: var(--md-primary-fg-color);
}

.progress-overview h3 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-size: 1.2em;
}

.overall-progress {
  margin-bottom: 32px;
  padding: 20px;
  background: var(--md-code-bg-color);
  border-radius: 8px;
}

/* Stages progress grid */
.stages-progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.stage-progress-card {
  padding: 16px;
  background: var(--md-code-bg-color);
  border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.stage-progress-card:hover {
  border-color: var(--md-primary-fg-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stage-progress-card.completed {
  border-color: #4caf50;
  background: linear-gradient(135deg, var(--md-code-bg-color) 0%, rgba(76, 175, 80, 0.1) 100%);
}

.stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.stage-icon {
  font-size: 1.5em;
}

.stage-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95em;
}

.stage-status {
  font-size: 0.85em;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color--light);
}

.stage-progress-card.completed .stage-status {
  background: #4caf50;
  color: white;
}

/* Progress stats card */
.progress-stats-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin: 24px 0;
  padding: 20px;
  background: var(--md-code-bg-color);
  border-radius: 8px;
}

.stat-item {
  text-align: center;
  padding: 12px;
}

.stat-value {
  font-size: 2em;
  font-weight: 700;
  color: var(--md-primary-fg-color);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85em;
  color: var(--md-default-fg-color--light);
}

/* Progress management */
.progress-management {
  margin: 32px 0;
  padding: 24px;
  background: var(--md-code-bg-color);
  border-radius: 12px;
}

.progress-management h3 {
  margin-top: 0;
  margin-bottom: 16px;
}

.management-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--md-primary-fg-color);
  color: white;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-action .icon {
  font-size: 1.2em;
}

.btn-export {
  background: #2196f3;
}

.btn-import {
  background: #4caf50;
}

.btn-reset {
  background: #ff9800;
}

.btn-primary {
  display: inline-block;
  padding: 12px 24px;
  margin: 8px;
  background: var(--md-primary-fg-color);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  display: inline-block;
  padding: 12px 24px;
  margin: 8px;
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
  text-decoration: none;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--md-default-fg-color--lighter);
}

.btn-danger {
  display: inline-block;
  padding: 12px 24px;
  margin: 8px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: #d32f2f;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.management-info {
  margin-top: 16px;
  padding: 12px;
  background: var(--md-default-bg-color);
  border-left: 4px solid var(--md-primary-fg-color);
  border-radius: 4px;
}

.info-text {
  margin: 0;
  font-size: 0.9em;
  color: var(--md-default-fg-color--light);
}

/* Progress details panel */
.progress-details-panel {
  margin: 24px 0;
  padding: 20px;
  background: var(--md-code-bg-color);
  border-radius: 8px;
}

.progress-details-panel h3 {
  margin-top: 0;
  margin-bottom: 16px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.detail-item {
  text-align: center;
  padding: 12px;
  background: var(--md-default-bg-color);
  border-radius: 6px;
}

.detail-label {
  font-size: 0.85em;
  color: var(--md-default-fg-color--light);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--md-primary-fg-color);
}

.last-visit {
  padding: 12px;
  background: var(--md-default-bg-color);
  border-radius: 6px;
  font-size: 0.9em;
}

.last-visit .label {
  color: var(--md-default-fg-color--light);
  margin-right: 8px;
}

.last-visit .value {
  font-weight: 600;
  color: var(--md-default-fg-color);
}

/* Congratulations modal */
.congratulations-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease;
}

.congratulations-modal .modal-content {
  background: var(--md-default-bg-color);
  padding: 32px;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

.congratulations-modal h2 {
  margin-top: 0;
  color: var(--md-primary-fg-color);
}

.congratulations-modal p {
  margin: 16px 0;
  line-height: 1.6;
}

/* Reset confirm modal */
.reset-confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease;
}

.reset-confirm-modal .modal-content {
  background: var(--md-default-bg-color);
  padding: 32px;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

.reset-confirm-modal h2 {
  margin-top: 0;
  color: #ff9800;
}

.reset-confirm-modal ul {
  text-align: left;
  margin: 16px 0;
}

.warning-text {
  color: #f44336;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

/* Notification */
.progress-notification {
  position: fixed;
  top: 80px;
  right: 20px;
  padding: 16px 20px;
  background: var(--md-default-bg-color);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9998;
  animation: slideInRight 0.3s ease;
  max-width: 400px;
}

.progress-notification.fade-out {
  animation: fadeOut 0.3s ease;
}

.notification-icon {
  font-size: 1.5em;
}

.notification-message {
  flex: 1;
  font-size: 0.95em;
}

.notification-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--md-default-fg-color--light);
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.notification-close:hover {
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
}

.notification-success {
  border-left: 4px solid #4caf50;
}

.notification-error {
  border-left: 4px solid #f44336;
}

.notification-info {
  border-left: 4px solid #2196f3;
}

.notification-warning {
  border-left: 4px solid #ff9800;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive design */
@media (max-width: 768px) {
  .stages-progress {
    grid-template-columns: 1fr;
  }
  
  .progress-stats-card {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .management-buttons {
    flex-direction: column;
  }
  
  .btn-action {
    width: 100%;
    justify-content: center;
  }
  
  .progress-notification {
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .congratulations-modal .modal-content,
  .reset-confirm-modal .modal-content {
    padding: 24px;
    width: 95%;
  }
}

/* Dark mode adjustments */
[data-md-color-scheme="slate"] .progress-container,
[data-md-color-scheme="slate"] .progress-overview,
[data-md-color-scheme="slate"] .progress-management,
[data-md-color-scheme="slate"] .progress-details-panel {
  background: rgba(255, 255, 255, 0.05);
}

[data-md-color-scheme="slate"] .stage-progress-card,
[data-md-color-scheme="slate"] .overall-progress {
  background: rgba(255, 255, 255, 0.03);
}

[data-md-color-scheme="slate"] .stage-progress-card.completed {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(76, 175, 80, 0.15) 100%);
}

/* Print styles */
@media print {
  .progress-management,
  .management-buttons,
  .progress-notification,
  .congratulations-modal,
  .reset-confirm-modal {
    display: none !important;
  }
  
  .progress-container,
  .progress-overview {
    break-inside: avoid;
  }
}

/* ==================== Comment System Styles ==================== */

/* Comments container */
#comments-container {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 2px solid var(--md-default-fg-color--lightest);
}

.comments-header {
  margin-bottom: 24px;
}

.comments-header h2 {
  margin: 0 0 8px 0;
  font-size: 1.5em;
  color: var(--md-default-fg-color);
}

.comments-description {
  color: var(--md-default-fg-color--light);
  font-size: 0.95em;
  margin: 0;
}

/* Giscus iframe styling */
.giscus-frame {
  width: 100%;
  border: none;
  min-height: 200px;
}

/* Loading state */
.comments-loading {
  text-align: center;
  padding: 40px;
  color: var(--md-default-fg-color--light);
}

.comments-loading::before {
  content: "⏳";
  font-size: 2em;
  display: block;
  margin-bottom: 16px;
}

/* ==================== Feedback System Styles ==================== */

/* Feedback container */
.feedback-container {
  margin: 32px 0;
  padding: 24px;
  background: var(--md-code-bg-color);
  border-radius: 12px;
  border-left: 4px solid var(--md-primary-fg-color);
}

.feedback-header {
  margin-bottom: 16px;
}

.feedback-header h3 {
  margin: 0 0 8px 0;
  font-size: 1.2em;
  color: var(--md-default-fg-color);
}

.feedback-description {
  color: var(--md-default-fg-color--light);
  font-size: 0.9em;
  margin: 0;
}

/* Feedback actions */
.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.feedback-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--md-primary-fg-color);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  font-size: 0.95em;
}

.feedback-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.feedback-button .icon {
  font-size: 1.2em;
}

.feedback-button.report-issue {
  background: #ff9800;
}

.feedback-button.suggest-improvement {
  background: #2196f3;
}

/* Like button */
.like-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--md-code-bg-color);
  border: 2px solid var(--md-default-fg-color--lightest);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95em;
  color: var(--md-default-fg-color);
}

.like-button:hover {
  background: var(--md-accent-fg-color);
  color: white;
  border-color: var(--md-accent-fg-color);
  transform: scale(1.05);
}

.like-button.liked {
  background: var(--md-accent-fg-color);
  color: white;
  border-color: var(--md-accent-fg-color);
}

.like-button .icon {
  font-size: 1.2em;
  transition: transform 0.2s ease;
}

.like-button:hover .icon {
  transform: scale(1.2);
}

.like-button.liked .icon {
  animation: likeAnimation 0.3s ease;
}

@keyframes likeAnimation {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
}

.like-count {
  font-weight: 600;
}

/* ==================== Comments Error Styling ==================== */

/* Comments error styling */
.comments-error {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
  color: #856404;
}

.comments-error p:first-child {
  font-weight: 600;
  font-size: 1.1em;
  margin-bottom: 10px;
}

.comments-error ul {
  margin: 10px 0;
  padding-left: 20px;
}

.comments-error a {
  color: #0066cc;
  text-decoration: underline;
}

[data-md-color-scheme="slate"] .comments-error {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.3);
  color: #ffc107;
}

/* Comments setup notice styling */
.comments-setup-notice {
  background: #e3f2fd;
  border: 2px solid #2196f3;
  border-radius: 8px;
  padding: 24px;
  margin: 20px 0;
  color: #1565c0;
}

.comments-setup-notice h3 {
  margin-top: 0;
  color: #1565c0;
  font-size: 1.2em;
}

.comments-setup-notice ol {
  margin: 15px 0;
  padding-left: 25px;
}

.comments-setup-notice li {
  margin: 8px 0;
}

.comments-setup-notice a {
  color: #1976d2;
  text-decoration: underline;
  font-weight: 500;
}

.comments-setup-notice a:hover {
  color: #0d47a1;
}

[data-md-color-scheme="slate"] .comments-setup-notice {
  background: rgba(33, 150, 243, 0.1);
  border-color: rgba(33, 150, 243, 0.3);
  color: #64b5f6;
}

[data-md-color-scheme="slate"] .comments-setup-notice h3 {
  color: #64b5f6;
}

[data-md-color-scheme="slate"] .comments-setup-notice a {
  color: #90caf9;
}
