/* Design Tokens & CSS Variables for HSG SkillHub - ความมั่นคงที่อยู่อาศัย */
:root {
  /* Colors */
  --bg-primary: #070913;
  --bg-secondary: #0e1322;
  --bg-card: rgba(19, 27, 46, 0.65);
  --bg-card-hover: rgba(28, 39, 66, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.03);
  
  --neon-cyan: #00f2fe;
  --electric-blue: #4facfe;
  --vibrant-purple: #7928ca;
  --neon-pink: #ff007f;
  --gold: #fbbf24;
  --success: #10b981;
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Gradients */
  --grad-main: linear-gradient(135deg, var(--neon-cyan) 0%, var(--electric-blue) 50%, var(--vibrant-purple) 100%);
  --grad-purple-pink: linear-gradient(135deg, var(--vibrant-purple) 0%, var(--neon-pink) 100%);
  --grad-gold: linear-gradient(135deg, #f59e0b 0%, var(--gold) 100%);
  --grad-dark: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  
  /* Borders */
  --border-std: 1px solid rgba(255, 255, 255, 0.08);
  --border-glow-cyan: 1px solid rgba(0, 242, 254, 0.4);
  --border-glow-purple: 1px solid rgba(121, 40, 202, 0.4);
  
  /* Shadows & Glows */
  --shadow-cyan-glow: 0 0 25px rgba(0, 242, 254, 0.25);
  --shadow-purple-glow: 0 0 25px rgba(121, 40, 202, 0.30);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  --shadow-text-glow: 0 0 10px rgba(0, 242, 254, 0.5);
  
  /* Fonts */
  --font-family: 'Plus Jakarta Sans', sans-serif;
  --font-heading: 'Orbitron', sans-serif;
}

/* Base Reset & Layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-primary);
  background-image: radial-gradient(circle at 50% -20%, rgba(121, 40, 202, 0.15) 0%, transparent 50%),
                    radial-gradient(circle at 10% 40%, rgba(0, 242, 254, 0.05) 0%, transparent 40%);
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header & Navigation */
header {
  border-bottom: var(--border-std);
  background: rgba(7, 9, 19, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 0;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.logo {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo span {
  background: var(--grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
  align-items: center;
}

.nav-item {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

.nav-item:hover, .nav-item.active {
  color: var(--neon-cyan);
  background: rgba(0, 242, 254, 0.08);
}

.header-right-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(0, 242, 254, 0.3);
  color: var(--text-primary);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(19, 27, 46, 0.8);
  border: var(--border-std);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
}

.quota-indicator {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-secondary);
}

.quota-count {
  color: var(--neon-cyan);
  font-weight: 700;
}

.user-role-label {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.role-free {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.role-pro {
  background: rgba(0, 242, 254, 0.2);
  color: var(--neon-cyan);
  border: 1px solid rgba(0, 242, 254, 0.4);
}

.role-admin {
  background: rgba(251, 191, 36, 0.2);
  color: var(--gold);
  border: 1px solid rgba(251, 191, 36, 0.4);
}

/* Common UI Components: Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  border: none;
  outline: none;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--grad-main);
  color: #070913;
  font-weight: 700;
  box-shadow: var(--shadow-cyan-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 35px rgba(0, 242, 254, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: var(--border-std);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-gold {
  background: var(--grad-gold);
  color: #070913;
  font-weight: 700;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}

.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.5);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 3rem 1rem 2.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: 2.3rem;
  line-height: 1.3;
  margin-bottom: 1rem;
  letter-spacing: 0.5px;
}

.hero .gradient-text {
  background: var(--grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 1.75rem;
  line-height: 1.7;
}

.hero .cta-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Academy Filters */
.academy-filters {
  margin-bottom: 2rem;
}

.search-input-wrapper {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
}

.search-input {
  width: 100%;
  padding: 1rem 1.25rem 1rem 3.25rem;
  background: rgba(19, 27, 46, 0.7);
  border: var(--border-std);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.search-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
}

.category-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

.category-tab {
  background: rgba(255, 255, 255, 0.04);
  border: var(--border-std);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.category-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.category-tab.active {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

/* Course Grid (Desktop exactly 3 columns) */
.course-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .course-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .course-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.course-card {
  background: var(--bg-card);
  border: var(--border-std);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.course-card:hover {
  transform: translateY(-5px);
  border-color: rgba(0, 242, 254, 0.3);
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.8), var(--shadow-cyan-glow);
}

.course-card-thumb {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  background: #000;
  overflow: hidden;
}

.course-card-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.course-card:hover .course-card-thumb img {
  transform: scale(1.05);
}

.course-badge-status {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
  z-index: 2;
}

.badge-free {
  background: rgba(16, 185, 129, 0.85);
  color: #fff;
}

.badge-unlocked {
  background: rgba(0, 242, 254, 0.85);
  color: #070913;
}

.badge-locked {
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.course-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.course-code {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--neon-cyan);
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 0.35rem;
}

.course-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.6rem;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}

.course-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: var(--border-std);
  padding-top: 0.85rem;
  margin-top: auto;
}

.course-price-wrap {
  display: flex;
  flex-direction: column;
}

.course-price {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold);
}

.course-original-price {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: line-through;
}

/* Blogger News Grid */
.news-feed-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .news-feed-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .news-feed-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.news-card {
  background: rgba(19, 27, 46, 0.7);
  border: var(--border-std);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  text-decoration: none;
  color: inherit;
}

.news-card:hover {
  transform: translateY(-4px);
  border-color: var(--neon-cyan);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.news-card-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #0f172a;
}

.news-card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.news-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
}

.news-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card-excerpt {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Viewer Screen & Portal Layout */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.portal-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 992px) {
  .portal-layout {
    grid-template-columns: 320px 1fr;
  }
}

.course-sidebar {
  background: var(--bg-card);
  border: var(--border-std);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  height: fit-content;
}

.sidebar-heading {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.step-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.step-item.active {
  background: rgba(0, 242, 254, 0.12);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  font-weight: 700;
}

.viewer-content-area {
  background: var(--bg-card);
  border: var(--border-std);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.ebook-reader-container {
  background: rgba(13, 17, 34, 0.6);
  border: var(--border-std);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.ebook-reader-container h2, .ebook-reader-container h3, .ebook-reader-container h4 {
  color: var(--neon-cyan);
  margin-top: 1.2rem;
  margin-bottom: 0.6rem;
  font-family: var(--font-family);
}

.ebook-reader-container ul, .ebook-reader-container ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.ebook-reader-container li {
  margin-bottom: 0.4rem;
}

.ebook-reader-container code {
  background: rgba(0, 242, 254, 0.1);
  color: var(--neon-cyan);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
}

.ebook-reader-container pre {
  background: #070913;
  border: var(--border-std);
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 1rem 0;
}

/* AI Playground Screen */
.playground-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 992px) {
  .playground-layout {
    grid-template-columns: 1fr 1fr;
  }
}

.prompt-form-card, .output-viewer-card {
  background: var(--bg-card);
  border: var(--border-std);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-select, .form-textarea, .form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(13, 17, 34, 0.8);
  border: var(--border-std);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
}

.form-select:focus, .form-textarea:focus, .form-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.prompt-preview-box {
  background: rgba(7, 9, 19, 0.75);
  border: var(--border-std);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--neon-cyan);
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.5;
}

.output-content-box {
  background: rgba(7, 9, 19, 0.85);
  border: var(--border-std);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-primary);
  min-height: 250px;
  max-height: 450px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-bottom: 1.25rem;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: #0e1322;
  border: var(--border-glow-cyan);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), var(--shadow-cyan-glow);
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  transition: color 0.2s;
}

.modal-close-btn:hover {
  color: #fff;
}

/* Lightbox Modal */
.lightbox-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(10px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-img-wrap {
  max-width: 420px;
  width: 100%;
  text-align: center;
  background: #0e1322;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: var(--border-glow-cyan);
}

.lightbox-img-wrap img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}
