/* ================ Tân Hưng - palette ================ */
:root {
  --th-green:        #00a651;   /* xanh lá chính từ logo */
  --th-green-dark:   #008342;
  --th-green-light:  #a6ce39;
  --th-cyan:         #00aeef;
  --th-red:          #ed1c24;
  --th-bg:           #f3f7f4;   /* nền sáng phớt xanh */
  --th-card-shadow:  0 1px 3px rgba(0, 70, 35, .06), 0 1px 2px rgba(0, 70, 35, .04);
  --th-border:       #d9e4dc;
  --th-text:         #1c2920;
  --th-muted:        #6b7d72;
}

/* ================ Reset / base ================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--th-bg);
  color: var(--th-text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--th-green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================ Layout ================ */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

.topbar {
  background: linear-gradient(135deg, var(--th-green) 0%, var(--th-green-dark) 100%);
  color: #fff;
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  box-shadow: 0 2px 4px rgba(0, 70, 35, .12);
}
.topbar-brand {
  display: flex; align-items: center;
}
.topbar-brand a {
  display: inline-flex; align-items: center;
  text-decoration: none;
  transition: opacity .15s;
}
.topbar-brand a:hover { text-decoration: none; opacity: .85; }
.topbar-brand img {
  height: 42px; width: auto; display: block;
}
.topbar-user {
  display: flex; flex-direction: column; align-items: flex-end;
  font-size: 14px; line-height: 1.3; gap: 1px;
  flex: 1; min-width: 0;
}
.topbar-user small { font-size: 11px; opacity: .85; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.06); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.15); }
.topbar a { color: #fff; }

/* ================ Card ================ */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--th-card-shadow);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--th-border);
}
.card h1, .card h2 { margin: 0 0 14px; color: var(--th-green-dark); }
.card-actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--th-muted); font-size: 14px; }

/* ================ Auth pages ================ */
.auth-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
  background:
    radial-gradient(1200px 600px at 100% -20%, rgba(0, 174, 239, .12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(166, 206, 57, .18), transparent 60%),
    var(--th-bg);
}
.auth-page .card {
  width: 100%; max-width: 420px;
  border-top: 4px solid var(--th-green);
  padding-top: 28px;
}
.auth-brand {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin-bottom: 18px;
}
.auth-brand img { height: 78px; width: auto; display: block; margin-bottom: 8px; }
.auth-brand h1 { font-size: 18px; margin: 0; color: var(--th-green-dark); font-weight: 600; }
.auth-brand .tagline { font-size: 13px; color: var(--th-muted); margin-top: 4px; }

/* ================ Forms ================ */
label { display: block; margin-bottom: 14px; font-size: 14px; color: #2c3a31; }
label > span { display: block; margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="date"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--th-border);
  border-radius: 7px;
  font-size: 15px;
  background: #fff;
  color: var(--th-text);
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--th-green);
  box-shadow: 0 0 0 3px rgba(0, 166, 81, .15);
}
textarea { resize: vertical; }

/* ================ Buttons ================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border: 1px solid var(--th-border);
  border-radius: 7px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  background: #fff;
  color: var(--th-text);
  font-family: inherit;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f3f8f4; border-color: #c2d5c8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, var(--th-green) 0%, var(--th-green-dark) 100%);
  color: #fff; border-color: var(--th-green-dark);
  box-shadow: 0 1px 2px rgba(0, 70, 35, .15);
}
.btn-primary:hover { background: linear-gradient(180deg, #00b257 0%, var(--th-green-dark) 100%); border-color: var(--th-green-dark); }
.btn-danger {
  background: var(--th-red); color: #fff; border-color: var(--th-red);
}
.btn-danger:hover { background: #c5161e; border-color: #c5161e; }
.btn-ghost { background: transparent; border-color: var(--th-border); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ================ Alerts ================ */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: var(--th-green-dark); border: 1px solid #a7e2bf; }
.alert-info    { background: #ecf8ff; color: #0568a0; border: 1px solid #bfe1f4; }

/* ================ Campaign selector (radio cards) ================ */
.campaign-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.campaign-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border: 1.5px solid var(--th-border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  margin-bottom: 0;
}
.campaign-card:hover { border-color: var(--th-green-light); }
.campaign-card:has(input:checked) { border-color: var(--th-green); background: #e7f6ec; }
.campaign-card input { margin-top: 3px; flex-shrink: 0; accent-color: var(--th-green); }
.campaign-card-body { line-height: 1.3; min-width: 0; flex: 1; }
.campaign-card-body strong { display: block; color: var(--th-green-dark); font-size: 14px; }
.campaign-card-body small { color: var(--th-muted); font-size: 12px; display: block; margin-top: 2px; }
@media (max-width: 640px) {
  .campaign-list { grid-template-columns: 1fr; }
}

/* ================ Dropzone ================ */
.dropzone {
  border: 2px dashed #b5d4c1;
  border-radius: 12px;
  padding: 36px 16px;
  text-align: center;
  cursor: pointer;
  background:
    linear-gradient(180deg, #f8fcf9 0%, #f1f8f3 100%);
  transition: background .15s, border-color .15s;
  margin: 16px 0;
}
.dropzone:hover, .dropzone.is-dragging {
  background: linear-gradient(180deg, #e9f7ee 0%, #ddf0e3 100%);
  border-color: var(--th-green);
}
.dropzone-icon {
  font-size: 42px; line-height: 1; color: var(--th-green); margin-bottom: 8px;
  font-weight: 300;
}
.dropzone-text { color: #4a5b50; font-size: 14px; }
.dropzone-text strong { color: var(--th-green-dark); }

/* ================ File list ================ */
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li {
  padding: 10px 12px;
  border: 1px solid var(--th-border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
  font-size: 14px;
}
.file-list .file-row { display: flex; gap: 10px; align-items: center; }
.file-list .file-thumb {
  width: 48px; height: 48px;
  border-radius: 6px;
  background: #e8f0ea;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.file-list .file-thumb img,
.file-list .file-thumb video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.file-list .file-thumb.is-video::after {
  content: "▶";
  position: absolute;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  font-size: 14px;
  pointer-events: none;
}
.file-list .file-thumb.is-other { color: var(--th-muted); font-size: 22px; }
.file-list .file-info { flex: 1; min-width: 0; line-height: 1.3; }
.file-list .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-list .file-meta { color: var(--th-muted); font-size: 12px; white-space: nowrap; }
.file-list .file-status { font-size: 12px; font-weight: 600; white-space: nowrap; }
.file-list .file-remove {
  width: 28px; height: 28px;
  border: 1px solid var(--th-border);
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  color: var(--th-muted);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: all .15s;
}
.file-list .file-remove:hover { background: var(--th-red); color: #fff; border-color: var(--th-red); }
.file-list .file-remove:disabled { opacity: .3; cursor: not-allowed; }
.file-list .file-remove:disabled:hover { background: #fff; color: var(--th-muted); border-color: var(--th-border); }
.status-pending   { color: var(--th-muted); }
.status-uploading { color: var(--th-cyan); }
.status-done      { color: var(--th-green); }
.status-error     { color: var(--th-red); }

.progress { height: 5px; background: #e3ebe6; border-radius: 99px; margin-top: 6px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--th-cyan); transition: width .25s; }
.progress-bar.done { background: var(--th-green); }
.progress-bar.error { background: var(--th-red); }

/* ================ Admin ================ */
.admin-nav {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--th-border);
}
.admin-nav a {
  padding: 10px 16px;
  color: #4a5b50;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.admin-nav a.active { color: var(--th-green-dark); border-bottom-color: var(--th-green); }

/* ================ Lightbox (xem ảnh/video full screen) ================ */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .92);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.lightbox.is-open { display: flex; }
.lightbox-content {
  max-width: 95vw; max-height: 90vh;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-content img,
.lightbox-content video {
  max-width: 95vw; max-height: 90vh;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  background: #000;
}
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none; border-radius: 50%;
  font-size: 22px; font-weight: 300;
  cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.3); }
.lightbox-caption {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.6); color: #fff;
  padding: 6px 14px; border-radius: 20px;
  font-size: 13px;
  max-width: 90vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ================ PWA Install Banner (popup đáy trang) ================ */
.install-prompt {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--th-border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 70, 35, .15), 0 2px 4px rgba(0, 70, 35, .08);
  padding: 12px 14px;
  animation: install-slide-up .25s ease-out;
}
@keyframes install-slide-up {
  from { transform: translateY(120%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.install-prompt-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.install-prompt-icon img {
  border-radius: 10px;
  display: block;
}
.install-prompt-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.install-prompt-text strong {
  color: var(--th-green-dark);
  font-size: 14px;
}
.install-prompt-sub {
  color: var(--th-muted);
  font-size: 12px;
  line-height: 1.35;
}
.install-prompt-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.install-prompt-actions .btn-link-mini {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--th-muted);
  font-size: 20px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background .12s, color .12s;
}
.install-prompt-actions .btn-link-mini:hover {
  background: var(--th-bg);
  color: var(--th-green-dark);
}
@media (min-width: 540px) {
  .install-prompt {
    left: auto; right: 16px; bottom: 16px; max-width: 380px;
  }
}

/* ================ Modal (popup hoàn tất) ================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 2000;
  padding: 16px;
  animation: modal-fade .15s ease-out;
}
.modal-overlay.is-open { display: flex; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-dialog {
  background: #fff;
  border-radius: 14px;
  max-width: 400px; width: 100%;
  padding: 28px 24px 20px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  animation: modal-slide .2s ease-out;
}
@keyframes modal-slide { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(0,166,81,.12);
  color: var(--th-green-dark);
  font-size: 36px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.modal-icon.error { background: rgba(237,28,36,.12); color: var(--th-red); }
.modal-dialog h3 { margin: 0 0 8px; color: var(--th-text); font-size: 18px; font-weight: 600; }
.modal-dialog p { margin: 0 0 18px; color: var(--th-muted); font-size: 14px; line-height: 1.45; }
.modal-dialog .btn { min-width: 100px; }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px;
}
.filters > * { flex: 1; min-width: 160px; }
.filters label { margin-bottom: 0; }
.filters .filter-actions { flex: 0 0 auto; display: flex; gap: 8px; min-width: auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.grid-empty { padding: 40px; text-align: center; color: var(--th-muted); }

.tile {
  background: #fff; border: 1px solid var(--th-border); border-radius: 10px;
  overflow: hidden; display: flex; flex-direction: column;
  position: relative;
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.tile:hover { border-color: var(--th-green-light); box-shadow: 0 4px 10px rgba(0, 70, 35, .08); }
.tile.is-selected { border-color: var(--th-green); box-shadow: 0 0 0 2px rgba(0, 166, 81, .25); }
.tile-check {
  position: absolute; top: 8px; left: 8px;
  width: 22px; height: 22px;
  z-index: 2;
  accent-color: var(--th-green);
}
.tile-thumb {
  background: #0f1a14; aspect-ratio: 4 / 3;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-thumb .placeholder { color: #cbd5e1; font-size: 42px; }
.tile-body { padding: 10px 12px; font-size: 13px; flex: 1; }
.tile-body .who { font-weight: 600; color: var(--th-green-dark); }
.tile-body .when { color: var(--th-muted); font-size: 12px; }
.tile-body .caption { margin-top: 6px; color: #34433a; word-break: break-word; }
.tile-actions { padding: 8px 10px; border-top: 1px solid #eef3ef; display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 500; }
.badge-video { background: #e6f8ff; color: #0568a0; }
.badge-image { background: #e7f6ec; color: var(--th-green-dark); }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-campaign { background: #fef3c7; color: #92400e; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.badge-user  { background: #e6f8ff; color: #0568a0; }
.badge-off   { background: #fee2e2; color: #991b1b; }
.badge-on    { background: #dcfce7; color: #166534; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--th-border); }
th { background: #f3f8f4; font-weight: 600; color: var(--th-green-dark); }
tr:hover td { background: #fafcfa; }

.pagination { margin-top: 16px; display: flex; gap: 6px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--th-border); border-radius: 7px; color: var(--th-text); }
.pagination span.current { background: var(--th-green); color: #fff; border-color: var(--th-green); }

/* ================ Footer ================ */
.site-footer {
  text-align: center;
  padding: 18px 12px;
  color: var(--th-muted);
  font-size: 12px;
}

@media (max-width: 640px) {
  /* Topbar mobile: row 1 = [logo + buttons], row 2 = [greeting full-width] */
  .topbar { gap: 6px 8px; padding: 10px 14px; }
  .topbar-brand { order: 1; flex: 1; min-width: 0; }
  .topbar-brand img { height: 34px; max-width: 100%; }
  .topbar-actions { order: 2; flex-shrink: 0; gap: 4px; }
  .topbar-actions .btn { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
  .topbar-user {
    order: 3; flex: 0 0 100%;
    flex-direction: row; flex-wrap: wrap;
    align-items: baseline;
    gap: 0 6px;
    font-size: 12px;
    padding-top: 4px;
    border-top: 1px solid rgba(255,255,255,.18);
  }
  .topbar-user small { font-size: 11px; opacity: 1; }

  .filters > * { flex: 1 1 100%; }
  .container { padding: 16px 12px; }
  .auth-brand img { height: 64px; }
}
