/* ==================== DESIGN SYSTEM ==================== */
:root {
  /* Colors */
  --primary: #1abc9c;
  --primary-dark: #16a085;
  --primary-light: #48dbb8;
  --secondary: #0f3460;
  
  /* Light Mode - GIỮ NGUYÊN BAN ĐẦU */
  --bg-light: #f0f2f5;
  --text-light: #222;
  --card-bg-light: #ffffff;
  --card-shadow-light: rgba(0, 0, 0, 0.1);
  --glass-bg-light: rgba(255, 255, 255, 0.8);
  --border-light: #e0e0e0;
  --placeholder-light: rgba(34, 34, 34, 0.6);

  /* Dark Mode - CHỈNH LẠI RÕ NÉT HƠN */
  --bg-dark: #0d1117;
  --text-dark: #e0e0e0;
  --card-bg-dark: #1e1e1e;
  --card-shadow-dark: rgba(26, 188, 156, 0.15);
  --glass-bg-dark: rgba(30, 30, 30, 0.9);
  --border-dark: #333;
  --placeholder-dark: rgba(224, 224, 224, 0.6);

  /* Other */
  --transition-speed: 0.3s;
}

/* Base Reset & Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Roboto', sans-serif;
}
html, body {
  height: 100%;
}
body {
  background-color: var(--bg-light);
  color: var(--text-light);
  transition: background-color var(--transition-speed), color var(--transition-speed);
}
body.dark {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}
a {
  text-decoration: none;
  color: var(--primary);
  transition: color var(--transition-speed);
}
a:hover {
  color: var(--primary-dark);
}

/* ==================== HEADER & FOOTER ==================== */
header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--glass-bg-light);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
}
body.dark header {
  background: var(--glass-bg-dark);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

#header-content {
    display: flex;
    align-items: center;
    max-width: 500px;
    flex-grow: 1;
}

#site-title {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--primary);
  margin-right: 20px;
}

#search-icon {
    position: absolute;
    left: 25px;
    color: var(--placeholder-light);
}

body.dark #search-icon {
    color: var(--placeholder-dark);
}

#search {
  width: 100%;
  padding: 10px 15px 10px 45px;
  border: none;
  border-radius: 20px;
  background-color: var(--border-light);
  color: var(--text-light);
  transition: background-color var(--transition-speed);
}
body.dark #search {
  background-color: var(--border-dark);
  color: var(--text-dark);
}
#search:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary);
}

#toggle-mode {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  transition: color var(--transition-speed);
}
body.dark #toggle-mode {
  color: var(--text-dark);
}
#toggle-mode:hover {
  color: var(--primary);
}

.content-frame {
  width: 100%;
  height: calc(100vh - 120px); /* 100vh - header - footer */
  border: none;
  margin-top: 60px; /* Header height */
  margin-bottom: 60px; /* Footer height */
  background: none;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 5px 0;
  background: var(--glass-bg-light);
  backdrop-filter: blur(10px);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 10;
  transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
}
body.dark .bottom-nav {
  background: var(--glass-bg-dark);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 10px;
  color: var(--placeholder-light);
  font-size: 0.7em;
  transition: color 0.2s;
}
body.dark .bottom-nav a {
  color: var(--placeholder-dark);
}
.bottom-nav a.active {
  color: var(--primary);
}
.bottom-nav a:hover {
  color: var(--primary-dark);
}
.bottom-nav .material-icons {
  font-size: 1.5em;
}

/* ==================== CONTENT PAGES ==================== */
.filter-bar {
  display: flex;
  padding: 10px 20px;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
  background-color: var(--bg-light);
  transition: background-color var(--transition-speed);
  position: sticky;
  top: 0;
  z-index: 5;
}
body.dark .filter-bar {
    background-color: var(--bg-dark);
}

.filter-btn {
  background-color: var(--border-light);
  color: var(--text-light);
  border: none;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s, color 0.2s;
}
body.dark .filter-btn {
  background-color: var(--border-dark);
  color: var(--text-dark);
}
.filter-btn:hover {
  background-color: var(--primary-light);
  color: white;
}
.filter-btn.active {
  background-color: var(--primary);
  color: white;
  font-weight: 600;
}

/* ==================== APP CARDS & LIST (CHỈNH SỬA CHÍNH) ==================== */

.app-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 20px;
}

.app-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    
    height: 240px;
    
    background: var(--card-bg-light);
    border-radius: 20px;
    box-shadow: 0 4px 10px var(--card-shadow-light);
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s, background-color var(--transition-speed);
}

body.dark .app-card {
    background: var(--card-bg-dark);
    box-shadow: 0 4px 10px var(--card-shadow-dark);
}

.app-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px var(--card-shadow-light);
}
body.dark .app-card:hover {
    box-shadow: 0 8px 20px var(--card-shadow-dark);
}

.app-card img {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  object-fit: cover;
  margin: 0 auto 10px;
}

.app-info {
    flex-grow: 1; 
    margin-bottom: 10px;
    overflow: hidden;
}

.app-info h3 {
  font-size: 1em;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-light);
}
body.dark .app-info h3 {
    color: var(--text-dark);
}

.app-info p, .app-meta {
  font-size: 0.8em;
  color: var(--placeholder-light);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis; 
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
body.dark .app-info p, body.dark .app-meta {
    color: var(--placeholder-dark);
}

.download-btn {
  margin-top: auto; 
  display: block;
  width: 100%;
  padding: 8px 15px;
  border-radius: 15px;
  background-color: var(--primary);
  color: white;
  font-weight: bold;
  text-align: center;
  transition: background-color 0.2s;
}

/* ⭐ THÊM: Dark mode cho download button */
body.dark .download-btn {
  background-color: var(--card-bg-dark);
  color: var(--text-dark);
  border: 2px solid var(--border-dark);
}

.download-btn:hover {
  background-color: var(--primary-dark);
  color: white;
}

/* ⭐ THÊM: Hover trong dark mode */
body.dark .download-btn:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

.download-btn .material-icons {
    font-size: 1.1em;
    vertical-align: middle;
    margin-right: 5px;
}

/* Conf Cards */
.app-card.conf-card {
    height: 200px;
}

/* Tags */
.tag-badge {
    display: inline-block;
    background-color: #f1f1f1;
    color: #333;
    font-size: 0.7em;
    padding: 3px 6px;
    border-radius: 10px;
    margin-top: 5px;
}
body.dark .tag-badge {
    background-color: #333;
    color: #e0e0e0;
}

/* ==================== POPUP DETAIL ==================== */
.app-detail-popup, .usage-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}
.app-detail-popup.active, .usage-popup.active {
    display: flex;
}

.app-detail-popup-content, .usage-popup-content {
    background: var(--card-bg-light);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: background-color var(--transition-speed);
}
body.dark .app-detail-popup-content, body.dark .usage-popup-content {
    background: var(--card-bg-dark);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-light);
}
body.dark .close-btn {
    color: var(--text-dark);
}

.app-info-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}
.app-info-header img {
    width: 70px;
    height: 70px;
    border-radius: 20px;
    margin-right: 15px;
}
.app-info-header h2 {
    font-size: 1.5em;
    margin-bottom: 5px;
    color: var(--primary);
}
.app-desc {
    font-size: 0.9em;
    line-height: 1.6;
    margin-bottom: 15px;
}
.app-meta-details p {
    font-size: 0.9em;
    margin-bottom: 5px;
}
.app-meta-details strong {
    font-weight: 600;
    margin-right: 5px;
}

/* Usage Popup Specific */
.usage-content h3 {
    margin-top: 15px;
    color: var(--primary);
}
.usage-content pre {
    background-color: var(--border-light);
    padding: 15px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 0.9em;
    margin-top: 10px;
}
body.dark .usage-content pre {
    background-color: var(--border-dark);
}

#copy-open-btn {
    background-color: #3498db;
    margin-top: 20px;
}
#copy-open-btn:hover {
    background-color: #2980b9;
}


/* ==================== HOME PAGE (Tùy chỉnh) ==================== */
.home-container {
    padding: 30px 20px;
    text-align: center;
    max-width: 800px;
    margin: 20px auto;
    background: var(--card-bg-light);
    border-radius: 16px;
    box-shadow: 0 4px 15px var(--card-shadow-light);
    transition: background-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

body.dark .home-container {
    background: var(--card-bg-dark);
    box-shadow: 0 4px 15px var(--card-shadow-dark);
}

.home-container h1 {
    color: var(--primary);
    font-size: 2.5em;
    margin-bottom: 20px;
}

.home-container p {
    font-size: 1.1em;
    line-height: 1.8;
    color: var(--text-light);
    margin-bottom: 20px;
}
body.dark .home-container p {
    color: var(--text-dark);
}

.section-title {
    color: var(--primary-dark);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.tutorial-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    list-style: none;
    padding: 0;
}

.tutorial-list li {
    flex: 1 1 calc(50% - 15px);
    max-width: calc(50% - 15px);
    background: var(--border-light);
    padding: 15px;
    border-radius: 10px;
    text-align: left;
}
body.dark .tutorial-list li {
    background: var(--border-dark);
}

.tutorial-button {
    display: block;
    width: 100%;
    background-color: var(--primary);
    color: white;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    transition: background-color 0.2s;
    margin-top: 10px;
}
.tutorial-button:hover {
    background-color: var(--primary-dark);
}

/* Video Popup */
.video-popup-content {
    padding: 10px;
    max-width: 95%;
    width: 800px;
}
.youtube-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
}
.youtube-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  header {
    flex-direction: row;
    justify-content: space-between;
    padding: 10px 15px;
  }

  #header-content {
    flex-grow: 1;
    max-width: unset;
    margin-right: 10px;
  }

  #site-title {
    font-size: 1.3em;
    padding-left: 0;
  }

  #search {
    padding: 10px 15px 10px 45px;
    margin-left: 0;
  }

  #toggle-mode {
    margin-left: 0;
  }
  
  .app-container {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 15px;
  }

  .app-card {
    height: 220px;
    padding: 10px;
  }

  .app-card img {
    width: 50px;
    height: 50px;
    border-radius: 14px;
  }

  .app-info h3 {
    font-size: 0.9em;
  }

  .app-info p, .app-meta {
    font-size: 0.7em;
  }

  .download-btn {
    padding: 6px 8px;
    font-size: 0.85em;
  }
  
  .app-detail-popup-content, .usage-popup-content {
      padding: 20px;
  }
  
  .tutorial-list li {
      flex: 1 1 100%;
      max-width: 100%;
  }
}
