/* Base styles */
:root {
  --bg: #0b1220;
  --card: #111a2e;
  --text: #e8eefc;
  --muted: #9fb0d0;
  --brand: #3b82f6;
  --brand-2: #22d3ee;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #1e2a44;
}

/* Light theme overrides */
html.theme-light {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #0e1a2b;
  --muted: #4b5563;
  --brand: #2563eb;
  --brand-2: #06b6d4;
  --accent: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% -10%, #1a2650 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 0%, #0e3a60 0%, transparent 55%),
              var(--bg);
  line-height: 1.6;
}

html.theme-light body {
  /* Nền phẳng để tránh vệt tối ở phần dưới trang */
  background: var(--bg);
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header & Nav */
header.site-header {
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  background: rgba(11, 18, 32, 0.7);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

html.theme-light header.site-header { background: rgba(255, 0, 0, 0.7); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: block;
  }
  
  nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: none;
    display: none;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
  
  nav.show {
    display: block;
  }
  
  nav ul {
    flex-direction: column;
    gap: 8px;
  }
  
  nav a {
    display: block;
    padding: 12px 16px;
    border-radius: 8px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: url('../icon/logo.png') center/contain no-repeat;
  display: inline-block;
}

.brand span {
  background: linear-gradient(135deg, #fff, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

nav a {
  display: inline-block;
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

nav a:hover,
nav a.active {
  border-color: var(--border);
  background: rgba(17, 26, 46, 0.6);
}

html.theme-light nav a:hover,
html.theme-light nav a.active { background: rgba(0, 0, 0, 0.05); }

/* Hero */
.hero {
  padding: 48px 0 28px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 40px;          /* tăng kích thước tiêu đề hero */
}

.hero p.lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 18px;           /* tăng cỡ chữ mô tả */
}

.hero .hero-cta {
  font-size: 20px;           /* tăng riêng dòng CTA */
  font-weight: 600;
}

/* Mỗi mục trong danh sách hero xuống 1 dòng, có khoảng cách rõ ràng */
.hero .muted { padding-left: 20px; margin: 0 0 14px; }
.hero .muted li { display: list-item; margin: 6px 0; font-size: 20px; }

.cta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Hero layout with image */
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  align-items: center;
  gap: 16px;
}

.hero-media img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
}

/* Slideshow */
.slideshow {
  position: relative;
  height: 970px;            /* Chiều cao cố định cho hero */
  overflow: hidden;         /* Ẩn phần thừa khi crop */
}

@media (max-width: 768px) {
  .slideshow {
    height: 300px;          /* Giảm chiều cao cho mobile */
  }
  /* Đảm bảo ảnh không bị crop trên mobile */
  .slideshow img {
    object-fit: contain;
    background: var(--card);
  }
}

@media (max-width: 480px) {
  .slideshow {
    height: 250px;          /* Chiều cao nhỏ hơn cho mobile nhỏ */
  }
}
.slideshow img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;        /* Lấp đầy khung, giữ bố cục đẹp */
  opacity: 0; 
  transition: opacity 500ms ease;
}
.slideshow img.active { opacity: 1; position: relative; }
.slide-controls {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.slide-btn {
  pointer-events: auto;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.3);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 999px;
}
html.theme-light .slide-btn { background: rgba(255,255,255,0.6); }

@media (max-width: 860px) {
  .hero-grid { 
    grid-template-columns: 1fr; 
    gap: 24px;
  }
  
  .hero h1 {
    font-size: 28px;
  }
  
  .hero p.lead {
    font-size: 16px;
  }
  
  .hero .muted li {
    font-size: 16px;
  }
  
  .hero .hero-cta {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 24px;
  }
  
  .hero p.lead {
    font-size: 14px;
  }
  
  .hero .muted li {
    font-size: 14px;
  }
  
  .hero .hero-cta {
    font-size: 14px;
  }
  
  .cta-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .cta-row .btn {
    text-align: center;
  }
}

.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
}

.btn.primary { border-color: #2453a6;     background: linear-gradient(180deg, #ffffff, #626366); }
.btn.accent { border-color: #0a5d48; background: linear-gradient(180deg, #065f46, #063f2f); }
.btn.warn { border-color: #7a5206; background: linear-gradient(180deg, #92400e, #5a2c08); }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 18px 0 10px;
  align-items: stretch;            /* kéo các phần tử con cao bằng nhau */
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  height: 100%;                     /* chiếm toàn bộ chiều cao ô grid */
  display: flex;                    /* để nội dung xếp dọc gọn gàng */
  flex-direction: column;
}

/* Desktop: luôn hiển thị đúng 5 cột cho phần tính năng */
@media (min-width: 1200px) {
  .cards#features-cards, section#features .cards { grid-template-columns: repeat(5, 1fr); }
}

.card h3 { margin: 6px 0 8px; font-size: 18px; }
.card p { margin: 0; color: var(--muted); }

/* Sections */
section { padding: 14px 0; }
section h2 { margin: 0 0 10px; font-size: 22px; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/* Excel-like helpers */
.table-tools { display: flex; gap: 10px; align-items: center; margin: 8px 0 10px; }
.table-tools input[type="search"] { max-width: 360px; }

#rom-table { border-spacing: 0; }
#rom-table thead th { position: sticky; top: 0; z-index: 10; cursor: pointer; background: rgba(36, 83, 166, 0.2); }
#rom-table td, #rom-table th { border-right: 1px solid var(--border); }
#rom-table td:last-child, #rom-table th:last-child { border-right: none; }
#rom-table tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }
#rom-table thead th.sort-asc::after { content: " \25B2"; }
#rom-table thead th.sort-desc::after { content: " \25BC"; }

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

thead th {
  background: rgba(36, 83, 166, 0.2);
  text-align: left;
}

tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

/* Forms */
form {
  display: grid;
  gap: 10px;
}

label { font-weight: 600; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1326;
  color: var(--text);
}

html.theme-light input,
html.theme-light select,
html.theme-light textarea { background: #ffffff; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-actions { display: flex; gap: 10px; align-items: center; }

.note { color: var(--muted); font-size: 14px; }
.chip { display: inline-block; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,0.03); font-size: 12px; }

/* Footer */
footer.site-footer {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding: 18px 0;
  color: var(--muted);
}

/* Utilities */
.muted { color: var(--muted); }
.spacer { height: 10px; }

/* Mobile-specific improvements */
@media (max-width: 768px) {
  .container {
    padding: 0 12px;
  }
  
  .hero {
    padding: 24px 0 16px;
  }
  
  .cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .card {
    padding: 12px;
  }
  
  .btn {
    padding: 12px 16px;
    font-size: 16px;
    min-height: 44px; /* Touch-friendly minimum size */
  }
  
  .slide-btn {
    padding: 12px 14px;
    font-size: 18px;
  }
  
  /* Improve touch targets */
  nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  /* Better spacing for mobile */
  section {
    padding: 16px 0;
  }
  
  footer.site-footer {
    padding: 16px 0;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 8px;
  }
  
  .hero {
    padding: 16px 0 12px;
  }
  
  .btn {
    padding: 10px 14px;
    font-size: 14px;
  }
  
  .card h3 {
    font-size: 16px;
  }
  
  .card p {
    font-size: 14px;
  }
}

/* Theme toggle button */
#theme-toggle {
  border-color: var(--border);
  cursor: pointer;
}

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

.gallery-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.gallery-item:hover img { transform: scale(1.03); }


/* Sticky footer: giữ footer luôn ở đáy màn hình */
body { min-height: 100vh; display: flex; flex-direction: column; }
main.container { flex: 1 0 auto; }
footer.site-footer { margin-top: auto; }

/* Căn giữa nội dung trang theo cả 2 trục */
.page-center {
  min-height: calc(100vh - 72px - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Tool page slideshow - centered carousel */
.tool-slideshow {
  position: relative;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;           /* center horizontally */
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
}
.tool-slideshow img { width: 100%; display: none; }
.tool-slideshow img.active { display: block; }
.tool-slide-controls {
  position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: center;
}
.tool-slide-btn { pointer-events: auto; border: 1px solid var(--border); background: rgba(0,0,0,0.3); color: var(--text); padding: 8px 10px; border-radius: 999px; }
html.theme-light .tool-slide-btn { background: rgba(255,255,255,0.6); }

/* Modal (QR) */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 100; }
.modal.show { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-content { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; max-width: 520px; width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); padding: 8px 6px 10px; }
.modal-body { padding: 12px 6px 6px; }
.modal-body img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); }

/* Autocomplete dropdown */
.autocomplete-dropdown {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: none;
}

/* Dark theme specific adjustments for autocomplete */
html:not(.theme-light) .autocomplete-dropdown {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

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

.autocomplete-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

html.theme-light .autocomplete-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Dark theme hover state for autocomplete items */
html:not(.theme-light) .autocomplete-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Ensure autocomplete items have proper background in dark theme */
html:not(.theme-light) .autocomplete-item {
  background: var(--card);
}

.autocomplete-item .device-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.autocomplete-item .device-code {
  font-size: 0.9em;
  color: var(--muted);
}

/* Ensure autocomplete input container has relative positioning */
form div {
  position: relative;
}

