/* =========================================
   ROOT & BASE
========================================= */
:root{
  --bg:#f7f9fc;
  --card:#ffffff;
  --accent:#1e60b8;
  --accent-2:#3b82c4;
  --muted:#6b7280;
  --text:#0f172a;
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family:Inter,Arial,Helvetica,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
}

/* =========================================
   TOP BAR (PC LAYOUT GIỮ NGUYÊN)
========================================= */
.topbar {
  position: relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 18px;
  background:linear-gradient(180deg,#fbfdff,#f6f9ff);
  border-bottom:1px solid #e6ecf6;
  min-height:62px;
}

.top-left { display:flex; align-items:center; gap:12px; }
.dropdown-wrapper { position: relative; display:inline-block; }

.page-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:8px;
  border:1px solid #d6e0ec;
  background:white;
  cursor:pointer;
  font-size:14px;
}

.top-title{
  position:absolute;
  left:50%;
  transform:translateX(-50%);
  text-align:center;
  pointer-events:none;
}
.top-title .title{font-size:20px;font-weight:700;color:var(--accent);}
.top-title .sub{font-size:12px;color:var(--muted);margin-top:2px;}

.top-right{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:2px;
}
.user-info{ font-size:12px;color:var(--muted); }

/* =========================================
   PAGE / CARD
========================================= */
.page{ padding:18px; }

.card{
  background:var(--card);
  padding:16px;
  border-radius:12px;
  box-shadow:0 6px 18px rgba(16,24,40,0.04);
  margin-bottom:18px;
}

/* =========================================
   FILTERS
========================================= */
.filters{
  display:grid;
  grid-template-columns:1fr 220px 120px;
  column-gap:18px;
  align-items:flex-start;
  margin-bottom:14px;
}

.chips{
  display:flex;
  gap:8px;
  overflow-x:auto;
  white-space:nowrap;
  padding-bottom:4px;
}

.chip{
  padding:8px 12px;
  border-radius:999px;
  border:1px solid #e6eef6;
  background:#fff;
  cursor:pointer;
  font-size:13px;
}
.chip.active{
  background:var(--accent);
  color:white;
  border-color:var(--accent);
}

.input{
  padding:8px 10px;
  border-radius:8px;
  border:1px solid #d9e2ec;
  width:100%;
}

/* =========================================
   TABLE
========================================= */
#tableWrap{
  max-height:62vh;
  overflow:auto;
  margin-top:12px;
  border-radius:8px;
}

table{
  width:100%;
  border-collapse:separate;
  table-layout:fixed;
  background:white;
  min-width:700px;
}

thead th{
  background:linear-gradient(180deg,var(--accent),var(--accent-2));
  color:white;
  padding:10px;
  text-align:center!important;
  position:sticky;
  top:0;
  z-index:6;
  font-size:13px;
}

th,td{
  padding:10px;
  border-bottom:1px solid #eef4fb;
  vertical-align:middle;
  font-size:14px;
}

tbody tr:nth-child(even){ background:#f8fbff; }

.thumb{
  width:80px;
  height:56px;
  object-fit:cover;
  border-radius:6px;
  cursor:pointer;
}

/* =========================================
   DROPDOWN
========================================= */
.page-dropdown{
  position:absolute;
  top:110%;
  left:0;
  display:none;
  background:white;
  border-radius:8px;
  box-shadow:0 8px 30px rgba(0,0,0,0.12);
  padding:8px;
  min-width:220px;
  max-height:260px;
  overflow-y:auto;
  z-index:99999;
}

.page-dropdown button{
  display:block;
  width:100%;
  padding:8px 10px;
  border:none;
  background:none;
  text-align:left;
  border-radius:6px;
  cursor:pointer;
}
.page-dropdown button:hover{
  background:#eef4ff;
}

/* =========================================
   MODALS
========================================= */
.modal{
  position:fixed;
  inset:0;
  background:rgba(2,6,23,0.55);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:10000;
}
.modal .box{
  background:white;
  padding:16px;
  border-radius:12px;
  max-width:95%;
  max-height:90%;
  overflow-y:auto;
}

/* =========================================
   IMAGE VIEWER
========================================= */
.image-viewer{
  width:90vw;
  max-width:900px;
  height:85vh;
  background:#111;
  border-radius:14px;
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
}

#bigImg{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  user-select:none;
}

.img-toolbar{
  position:absolute;
  bottom:14px;
  left:50%;
  transform:translateX(-50%);
  display:flex;
  gap:10px;
  background:rgba(255,255,255,0.12);
  padding:8px 14px;
  border-radius:10px;
}

/* CLOSE BUTTON */
#closeImg{
  position:absolute;
  top:14px;
  right:14px;
  background:rgba(255,50,50,0.9);
  color:white;
  padding:10px 14px;
  border-radius:10px;
  border:none;
  cursor:pointer;
  z-index:10001;
}

/* =========================================
   MOBILE VIEW — FINAL CLEAN VERSION
========================================= */
@media (max-width: 768px){

  /* --- TOPBAR chuyển thành dạng 2 hàng --- */
  .topbar{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:12px;
    padding:14px 10px;
  }

  /* --- TITLE lên hàng đầu --- */
  .top-title{
    order:1;
    position:static!important;
    transform:none!important;
    width:100%;
    text-align:center;
  }

  /* --- Hàng Dropdown + Login --- */
  .top-left,
  .top-right{
    order:2;
    width:100%;
    display:flex;
    align-items:center;
  }

  /* Dropdown trái */
  .top-left{
    justify-content:flex-start;
  }

  /* Login phải */
  .top-right{
    justify-content:flex-end;
  }

  /* Nút trong mobile */
  .page-btn{
    padding:8px 12px;
    font-size:14px;
    max-width:180px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  /* Ẩn last update */
  #lastUpdate{
    display:none!important;
  }

  /* FILTERS mobile */
  .filters{
    grid-template-columns:1fr!important;
    gap:12px;
  }

  table{ display:none!important; } /* dùng card nếu có */
}
