/* =============================================
   DownloadHub — main.css
   Palette: deep navy #0F1B2D, accent #3B82F6,
   bright cyan #06B6D4, surface #1E2D40,
   text #E2E8F0, muted #64748B
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0F1B2D;
  --surface:  #1E2D40;
  --surface2: #253447;
  --border:   #2E4060;
  --accent:   #3B82F6;
  --cyan:     #06B6D4;
  --green:    #10B981;
  --red:      #EF4444;
  --yellow:   #F59E0B;
  --text:     #E2E8F0;
  --muted:    #94A3B8;
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,.45);
  --font-th:  'Sarabun', sans-serif;
  --font-en:  'Space Grotesk', sans-serif;
}

html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font-th); font-size: 16px; line-height: 1.65; min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--cyan); }

img { max-width: 100%; display: block; }

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

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 20px; border-radius: 8px; font-family: var(--font-th); font-size: .9rem; font-weight: 600; border: none; cursor: pointer; transition: all .18s; text-decoration: none; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: #2563EB; color:#fff; }
.btn-outline  { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline:hover  { background: var(--accent); color: #fff; }
.btn-ghost    { background: transparent; color: var(--muted); }
.btn-ghost:hover    { color: var(--text); }
.btn-danger   { background: var(--red); color: #fff; }
.btn-green    { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Navbar ---- */
.navbar { position: sticky; top: 0; z-index: 100; background: rgba(15,27,45,.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.nav-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-en); font-weight: 700; font-size: 1.2rem; color: var(--text); text-decoration: none; flex-shrink: 0; }
.brand-icon { font-size: 1.4rem; }
.brand:hover { color: var(--cyan); }

.nav-search { flex: 1; max-width: 480px; display: flex; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.nav-search input { flex: 1; background: none; border: none; padding: 8px 14px; color: var(--text); font-family: var(--font-th); font-size: .9rem; outline: none; }
.nav-search input::placeholder { color: var(--muted); }
.nav-search button { background: var(--accent); border: none; padding: 0 16px; cursor: pointer; font-size: 1rem; }
.nav-search button:hover { background: #2563EB; }

.nav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-username { font-size: .85rem; color: var(--muted); }
.nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }

/* ---- Flash ---- */
.flash { padding: 12px 18px; border-radius: 8px; margin: 14px auto; font-size: .93rem; }
.flash--success { background: rgba(16,185,129,.15); border: 1px solid var(--green); color: #6EE7B7; }
.flash--error   { background: rgba(239,68,68,.15);  border: 1px solid var(--red);   color: #FCA5A5; }
.flash--info    { background: rgba(59,130,246,.15); border: 1px solid var(--accent); color: #93C5FD; }

/* ---- Hero ---- */
.hero { padding: 80px 0 60px; text-align: center; }
.hero h1 { font-family: var(--font-en); font-size: clamp(2rem,5vw,3.4rem); font-weight: 700; background: linear-gradient(135deg, #E2E8F0 0%, var(--cyan) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1.15; margin-bottom: 16px; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 520px; margin: 0 auto 32px; }
.hero-stats { display: flex; justify-content: center; gap: 40px; margin-top: 20px; }
.hero-stat { text-align: center; }
.hero-stat strong { display: block; font-family: var(--font-en); font-size: 1.8rem; color: var(--cyan); }
.hero-stat span { font-size: .82rem; color: var(--muted); }

/* ---- Section titles ---- */
.section { padding: 48px 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.section-title { font-family: var(--font-en); font-size: 1.3rem; font-weight: 700; }
.section-title::before { content: attr(data-dot) '  '; color: var(--cyan); }

/* ---- Category pills ---- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 14px; }
.cat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 12px; text-align: center; text-decoration: none; color: var(--text); transition: all .18s; }
.cat-card:hover { border-color: var(--accent); background: var(--surface2); transform: translateY(-2px); color: var(--text); }
.cat-card .cat-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.cat-card .cat-name { font-size: .88rem; font-weight: 600; }
.cat-card .cat-count { font-size: .75rem; color: var(--muted); }

/* ---- File cards ---- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 20px; }
.file-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: all .18s; }
.file-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.file-card-thumb { height: 140px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 3.5rem; color: var(--muted); position: relative; overflow: hidden; }
.file-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-card-badge { position: absolute; top: 8px; right: 8px; background: var(--accent); color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 100px; font-weight: 700; text-transform: uppercase; }
.file-card-body { padding: 14px 16px; flex: 1; }
.file-card-cat { font-size: .72rem; color: var(--cyan); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.file-card-title { font-weight: 700; font-size: .97rem; margin-bottom: 6px; line-height: 1.35; }
.file-card-title a { color: var(--text); }
.file-card-title a:hover { color: var(--cyan); }
.file-card-desc { font-size: .82rem; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.file-card-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); }
.file-card-footer a { color: inherit; text-decoration: none; }

/* ---- File detail ---- */
.file-detail { display: grid; grid-template-columns: 1fr 300px; gap: 32px; padding: 40px 0; }
.file-main {}
.file-title { font-family: var(--font-en); font-size: clamp(1.4rem,3vw,2rem); font-weight: 700; margin-bottom: 12px; }
.file-meta-row { display: flex; flex-wrap: wrap; gap: 16px; font-size: .85rem; color: var(--muted); margin-bottom: 20px; }
.file-meta-row span { display: flex; align-items: center; gap: 4px; }
.file-desc { color: var(--text); line-height: 1.8; }
.file-tags { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--surface2); border: 1px solid var(--border); padding: 4px 12px; border-radius: 100px; font-size: .78rem; color: var(--muted); text-decoration: none; }
.tag:hover { border-color: var(--accent); color: var(--accent); }

.file-sidebar .sidebar-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; }
.sidebar-box h3 { font-size: .95rem; font-weight: 700; margin-bottom: 14px; }
.info-table td { padding: 7px 0; font-size: .87rem; }
.info-table td:first-child { color: var(--muted); padding-right: 14px; width: 90px; }

/* ---- Auth forms ---- */
.auth-wrap { min-height: calc(100vh - 120px); display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 40px 36px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-box h2 { font-family: var(--font-en); font-size: 1.5rem; margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); font-size: .88rem; margin-bottom: 28px; }

/* ---- Form controls ---- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.form-control { width: 100%; background: var(--surface2); border: 1.5px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-family: var(--font-th); font-size: .95rem; outline: none; transition: border-color .18s; }
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: #4B5563; }
select.form-control option { background: var(--surface2); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--red); margin-top: 4px; }

/* ---- Search page ---- */
.search-bar { display: flex; gap: 0; margin-bottom: 28px; }
.search-bar input { flex: 1; border-radius: 10px 0 0 10px; }
.search-bar button { border-radius: 0 10px 10px 0; padding: 10px 24px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; align-items: center; }
.filter-row select { background: var(--surface); border: 1.5px solid var(--border); color: var(--text); padding: 7px 12px; border-radius: 8px; font-size: .87rem; cursor: pointer; }

/* ---- Admin panel ---- */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.admin-sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 0; }
.admin-sidebar .sidebar-brand { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--muted); font-size: .9rem; text-decoration: none; transition: all .15s; }
.admin-nav a:hover, .admin-nav a.active { color: var(--text); background: var(--surface2); border-left: 3px solid var(--accent); }
.admin-content { padding: 30px 36px; }
.admin-content h1 { font-family: var(--font-en); font-size: 1.5rem; margin-bottom: 24px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { background: var(--surface2); padding: 11px 14px; text-align: left; font-weight: 600; color: var(--muted); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ---- Stats cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 16px; margin-bottom: 30px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .stat-label { font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.stat-card .stat-value { font-family: var(--font-en); font-size: 2rem; font-weight: 700; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.cyan   .stat-value { color: var(--cyan); }
.stat-card.green  .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; justify-content: center; padding: 30px 0; flex-wrap: wrap; }
.pagination a, .pagination span { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; border: 1.5px solid var(--border); font-size: .88rem; color: var(--muted); text-decoration: none; transition: all .15s; }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Upload area ---- */
.upload-drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px; text-align: center; cursor: pointer; transition: all .18s; }
.upload-drop:hover, .upload-drop.active { border-color: var(--accent); background: rgba(59,130,246,.06); }
.upload-drop .ud-icon { font-size: 3rem; display: block; margin-bottom: 10px; }

/* ---- Badge ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 100px; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.badge-active  { background: rgba(16,185,129,.2);  color: #6EE7B7; }
.badge-draft   { background: rgba(245,158,11,.2);  color: #FCD34D; }
.badge-hidden  { background: rgba(100,116,139,.2); color: #94A3B8; }
.badge-admin   { background: rgba(59,130,246,.2);  color: #93C5FD; }
.badge-user    { background: rgba(100,116,139,.2); color: #94A3B8; }

/* ---- Category icon classes (emoji-free, MySQL-safe) ---- */
.cat-icon { display:block; font-size:2rem; margin-bottom:8px; line-height:1; }
.cat-icon::before { font-style:normal; }
.cat-icon--software::before    { content: '\1F4BB'; }
.cat-icon--documents::before   { content: '\1F4C4'; }
.cat-icon--images::before      { content: '\1F5BC'; }
.cat-icon--music::before       { content: '\1F3B5'; }
.cat-icon--videos::before      { content: '\1F3AC'; }
.cat-icon--code::before        { content: '\2699'; }
.cat-icon--games::before       { content: '\1F3AE'; }
.cat-icon--others::before      { content: '\1F4E6'; }
/* fallback for any unknown slug */
.cat-icon:not([class*="cat-icon--"])::before,
.cat-icon--::before            { content: '\1F4C1'; }

/* ---- Site footer ---- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 80px; padding: 50px 0 0; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; }
.footer-brand .brand-icon { font-size: 1.8rem; }
.footer-brand strong { font-family: var(--font-en); font-size: 1.1rem; }
.footer-brand p { color: var(--muted); font-size: .85rem; margin-top: 8px; max-width: 240px; }
.footer-links h4 { font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.footer-links a { display: block; color: var(--muted); font-size: .88rem; margin-bottom: 7px; text-decoration: none; }
.footer-links a:hover { color: var(--text); }
.footer-bottom { border-top: 1px solid var(--border); padding: 18px 0; margin-top: 40px; color: var(--muted); font-size: .8rem; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .file-detail { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: span 2; }
}
@media (max-width: 640px) {
  .nav-search { display: none; }
  .nav-toggle { display: block; }
  .navbar.open .nav-search  { display: flex; position: absolute; top: 64px; left: 0; right: 0; border-radius: 0; border-left: 0; border-right: 0; }
  .navbar.open .nav-actions { display: flex; position: absolute; top: 116px; left: 0; right: 0; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .hero h1 { font-size: 1.8rem; }
  .hero-stats { gap: 20px; }
  .footer-inner, .footer-brand { grid-column: 1; grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .auth-box { padding: 24px 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; } }
