:root{
  --gov-blue:#0A6BD6;
  --bg:#2d2723;
  --panel:#3b332f;
  --muted:#d0c5bd;
  --border:#554c47;
  --accent:#ffca63;
  --radius:10px;
  --gap:14px;
  --card-shadow:0 6px 18px rgba(8,32,63,0.04);
  font-family:Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme:dark;
  color:#f4ece6;
}

/* ===============================
   LIGHT MODE (khi người dùng chọn)
   =============================== */
body.light{
  --bg:#f0f4f8;
  --panel:#ffffff;
  --muted:#6b7684;
  --border:#cbd5e0;
  --accent:#0A6BD6;
  --card-shadow:0 2px 8px rgba(0,0,0,0.1);
  color-scheme:light;
  color:#333;
}

/* ============================
   TOPBAR (FIXED)
============================ */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:12px 20px;
  background:linear-gradient(90deg,#d68e2c,#ffca63);
  color:white;
  gap:0;
  overflow:visible;

  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 36px);
  max-width: calc(100vw - 36px);
  z-index: 999;
  box-sizing: border-box;
  border-radius: 0 0 12px 12px;
  height:68px;
}

.topbar-left{
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
  min-width:0;
  overflow:visible;
  margin-right:auto;
  height:100%;
}

@media (max-width:1000px){
  .topbar-left{
    gap:4px;
  }
}

.brand{
  display:flex;
  gap:8px;
  align-items:center;
}

.brand-logo{
  width:44px;
  height:44px;
  border-radius:10px;
  overflow:hidden;
  background:transparent;
  flex-shrink:0;
  transition:opacity 0.3s ease, transform 0.3s ease;
  cursor:pointer;
}

.brand-logo:hover{
  opacity:0.8;
  transform:scale(1.05);
}

.brand-logo:active{
  opacity:0.6;
  transform:scale(0.95);
}

.brand-logo img{
  width:100%;
  height:100%;
  object-fit:contain;
  transform:scale(1.35);
  cursor:pointer;
  pointer-events:none;
}

.brand-title,
.brand-sub{
  color:#ff3b3b !important;
  font-weight:800;
}

.icon-btn{
  background:transparent;
  border:0;
  color:white;
  font-size:18px;
  padding:8px;
  border-radius:8px;
  cursor:pointer;
}

/* GOOGLE SEARCH BAR */
.topbar-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:12px;
  flex:1 1 auto;
  margin-left:auto;
  margin-right:20px;
}

.google-search{
  display:flex;
  align-items:center;
  background:#fff;
  border-radius:24px;
  padding:0 10px;
  height:44px;
  box-shadow:0 2px 5px rgba(0,0,0,0.1);
  border:1px solid transparent;
  transition:all 0.2s;
  flex:1 1 auto;
  min-width:0;
  max-width:300px;
  gap:6px;
}

.google-search:hover{
  box-shadow:0 2px 8px rgba(0,0,0,0.15);
}

.google-search:focus-within{
  box-shadow:0 2px 8px rgba(0,0,0,0.2);
  border-color:#dfe1e5;
}

.google-search .search-icon{
  width:20px;
  height:20px;
  color:#9aa0a6;
  flex-shrink:0;
}

.google-search input[type="text"]{
  flex:1;
  border:none;
  outline:none;
  background:transparent;
  font-size:16px;
  color:#000;
  padding:0;
  margin:0;
  min-width:0;
}

.google-search input[type="text"]::placeholder{
  color:#9aa0a6;
}

.clear-btn{
  display:none;
  width:40px;
  height:40px;
  border:none;
  background:transparent;
  border-radius:50%;
  cursor:pointer;
  align-items:center;
  justify-content:center;
  padding:0;
  color:#70757a;
  flex-shrink:0;
  transition:background 0.2s;
}

.clear-btn.show{
  display:flex;
}

.clear-btn:hover{
  background:#f1f3f4;
}

.clear-btn svg{
  width:20px;
  height:20px;
}

.search-tools{
  display:flex;
  align-items:center;
  gap:4px;
  flex-shrink:0;
  padding-left:8px;
  border-left:1px solid #dfe1e5;
}

.tool-btn{
  width:40px;
  height:40px;
  border:none;
  background:transparent;
  border-radius:50%;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
  color:#70757a;
  transition:background 0.2s;
  flex-shrink:0;
}

.tool-btn:hover{
  background:#f1f3f4;
}

.tool-btn svg{
  width:20px;
  height:20px;
}

/* Dark mode */
body.dark .google-search{
  background:#303134;
  border-color:#5f6368;
}

body.dark .google-search:hover,
body.dark .google-search:focus-within{
  box-shadow:0 2px 8px rgba(0,0,0,0.3);
  border-color:#5f6368;
}

body.dark .google-search .search-icon{
  color:#9aa0a6;
}

body.dark .google-search input[type="text"]{
  color:#fff;
}

body.dark .google-search input[type="text"]::placeholder{
  color:#9aa0a6;
}

body.dark .clear-btn{
  color:#9aa0a6;
}

body.dark .clear-btn:hover{
  background:#3c4043;
}

body.dark .search-tools{
  border-left-color:#5f6368;
}

body.dark .tool-btn{
  color:#9aa0a6;
}

body.dark .tool-btn:hover{
  background:#3c4043;
  color:#e8eaed;
}

/* Responsive */
@media (max-width:1000px){
  .google-search{
    padding:0 8px;
    height:40px;
    max-width:250px;
    gap:4px;
  }
  
  .google-search .search-icon{
    width:18px;
    height:18px;
  }
  
  .google-search input[type="text"]{
    font-size:15px;
  }
  
  .clear-btn,
  .tool-btn{
    width:36px;
    height:36px;
  }
  
  .clear-btn svg,
  .tool-btn svg{
    width:18px;
    height:18px;
  }
}

@media (max-width:768px){
  .google-search{
    padding:0 6px;
    height:36px;
    max-width:220px;
    gap:3px;
  }
  
  .google-search .search-icon{
    width:16px;
    height:16px;
  }
  
  .google-search input[type="text"]{
    font-size:14px;
  }
  
  .clear-btn,
  .tool-btn{
    width:32px;
    height:32px;
  }
  
  .clear-btn svg,
  .tool-btn svg{
    width:16px;
    height:16px;
  }
  
  .search-tools{
    gap:2px;
    padding-left:3px;
  }
}

@media (max-width:480px){
  .google-search{
    padding:0 5px;
    height:32px;
    max-width:200px;
    gap:2px;
  }
  
  .google-search .search-icon{
    width:14px;
    height:14px;
  }
  
  .google-search input[type="text"]{
    font-size:13px;
  }
  
  .clear-btn,
  .tool-btn{
    width:28px;
    height:28px;
  }
  
  .clear-btn svg,
  .tool-btn svg{
    width:14px;
    height:14px;
  }
  
  .search-tools{
    gap:1px;
    padding-left:2px;
  }
}

.ai-mode-btn{
  background:#303134;
  border:1px solid transparent;
  border-radius:20px;
  padding:6px 14px;
  cursor:pointer;
  transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display:flex;
  align-items:center;
  gap:8px;
  color:#ffffff;
  font-size:14px;
  font-weight:500;
  white-space:nowrap;
  flex-shrink:0;
  min-width:auto;
  height:36px;
  overflow:visible;
  z-index:10;
  position:relative;
}

/* Gradient border effect */
.ai-mode-btn::before{
  content:'';
  position:absolute;
  inset:-1px;
  border-radius:20px;
  padding:1px;
  background:linear-gradient(90deg, #4285f4, #34a853, #fbbc04, #ea4335, #4285f4);
  background-size:200% 100%;
  -webkit-mask:linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite:xor;
  mask-composite:exclude;
  opacity:0;
  transition:opacity 0.3s;
  animation:gradientShift 3s linear infinite;
}

.ai-mode-btn:hover::before{
  opacity:1;
}

@keyframes gradientShift{
  0%{background-position:0% 50%}
  100%{background-position:200% 50%}
}

.ai-mode-btn svg{
  width:18px;
  height:18px;
  flex-shrink:0;
  filter:drop-shadow(0 0 2px rgba(255,255,255,0.3));
}

.ai-mode-btn span{
  white-space:nowrap;
  display:inline-block;
}

.ai-mode-btn:hover{
  background:#3c4043;
  box-shadow:0 2px 8px rgba(0,0,0,0.2);
  transform:translateY(-1px);
}

.ai-mode-btn svg{
  width:18px;
  height:18px;
  flex-shrink:0;
}

#btnTheme{
  flex-shrink:0;
  display:flex;
  align-items:center;
  justify-content:center;
  height:44px;
  width:44px;
  font-size:20px;
  background:transparent;
  border:none;
  cursor:pointer;
  border-radius:50%;
  transition:all 0.2s;
}

#btnTheme:hover{
  background:rgba(255,255,255,0.1);
}

/* ============================
   BODY & BACKGROUND
============================ */
body{
  background:var(--bg);
  margin:0;
  min-height:100vh;
}

/* ============================
   LAYOUT
============================ */
.container{
  display:flex;
  gap:18px;
  padding:18px;
  align-items:flex-start;
}

.main{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:12px;
  background:var(--bg);

  /* FIX: tránh topbar che card */
  padding-top:76px !important;
}

/* ============================
   SIDEBAR
============================ */
#overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.45);
  display:none;
  z-index:998;
}

.sidebar{
  position:fixed;
  top:0;
  left:-320px;
  width:auto;
  min-width:fit-content;
  max-width:fit-content;
  height:auto;
  max-height:100vh;
  background:var(--panel);
  border-right:1px solid var(--border);
  padding:12px;
  box-shadow:0 10px 30px rgba(0,0,0,0.28);
  transition:left .28s cubic-bezier(.2,.8,.2,1);
  z-index:999;
  overflow-y:auto;
  white-space:nowrap;
  border-radius:12px;
  margin:12px;
}

.sidebar.open{ left:0; }

.sidebar-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:8px;
}

.sidebar-head h4{
  color:#d82727;
  font-weight:700;
}

.badge{
  background:var(--accent);
  color:white;
  padding:6px 10px;
  border-radius:999px;
  font-weight:700;
  font-size:13px;
}

.folder-tree{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding-bottom:8px;
  width:100%;
}

/* ============================
   TOP MENU (ẨN)
============================ */
.topmenu{ display:none !important; }

/* ============================
   CONTENT + CARD
============================ */
.content{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(280px,1fr));
  gap:14px;
  margin-top:0 !important;
  margin-left:auto;
  margin-right:auto;
  overflow:visible;
  padding:14px;
  max-width:100%;
  box-sizing:border-box;
}

.card{
  display:flex;
  gap:12px;
  padding:12px;
  background:var(--panel);
  border-radius:10px;
  border:1px solid var(--border);
  box-shadow:var(--card-shadow);
  align-items:center;
  transition:transform .12s;
  position:relative;
}

/* BORDER ANIMATION */
.link-card{
  position:relative;
  overflow:visible;
  background:var(--panel);
  border:1px solid var(--border);
  min-height:115px !important;

  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  padding:14px;
  padding-right:50px;
  border-radius:12px;
}

.link-card::before{
  content:"";
  position:absolute;
  inset:-3px;
  border-radius:14px;
  padding:3px;
  background:linear-gradient(120deg,#ff1a1a,#ff7b7b,#ff1a1a);
  background-size:300% 300%;
  animation:borderRun 3s linear infinite;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite:xor;
          mask-composite:exclude;
  opacity:0;
  transition:opacity .25s;
}

.link-card:hover::before{ opacity:1; }
.link-card:hover{ transform:translateY(-3px); }

@keyframes borderRun{
  0%{background-position:0% 50%}
  50%{background-position:100% 50%}
  100%{background-position:0% 50%}
}

.card-left{
  flex-shrink:0;
  width:44px;
  height:44px;
}

.favicon{
  width:44px;
  height:44px;
  border-radius:8px;
  background:#f0f6ff;
  object-fit:contain;
  image-rendering:-webkit-optimize-contrast;
  image-rendering:crisp-edges;
  -webkit-backface-visibility:hidden;
  backface-visibility:hidden;
  transform:translateZ(0);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

.card-body{
  flex:1;
  padding:0 12px;
  overflow:visible;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
}

.card-title{
  word-wrap:break-word;
  overflow-wrap:break-word;
  word-break:break-word;
  font-size:16px;
  font-weight:600;
  line-height:1.4;
}

.card-url{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  opacity:.8;
  font-size:14px;
}

.card-actions{
  flex-shrink:0;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.copy-btn,.open-btn{
  border:1px solid var(--border);
  background:var(--panel);
  cursor:pointer;
  padding:8px 10px;
  border-radius:8px;
  font-size:16px;
  color:var(--muted);
  transition:all 0.2s ease;
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:36px;
  min-height:36px;
}

.copy-btn:hover,.open-btn:hover{
  background:var(--accent);
  color:#fff;
  border-color:var(--accent);
  transform:translateY(-2px);
  box-shadow:0 4px 8px rgba(0,0,0,0.15);
}

.copy-btn:active,.open-btn:active{
  transform:translateY(0);
  box-shadow:0 2px 4px rgba(0,0,0,0.1);
}

/* ===============================
   BADGE SỐ CARD
================================ */
.card-index{
  position:absolute;
  top:5px;
  right:10px;
  background:#e53935;
  color:white;
  padding:4px 10px;
  border-radius:50%;
  font-size:14px;
  font-weight:700;
  border:2px solid #ffffff;
  z-index:20;
  min-width:32px;
  text-align:center;
  box-sizing:border-box;
  white-space:nowrap;
}

/* ===============================
   FOLDER (MENU)
================================ */
.folder{
  padding:12px;
  border-radius:8px;
  background:#fff9e6;
  border:1px solid #e6d9b3;
  box-shadow:0 2px 8px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
  display:flex;
  justify-content:space-between;
  align-items:center;
  cursor:pointer;
  transition:all .2s ease;
  position:relative;
  width:100%;
  box-sizing:border-box;
}

.folder:hover{
  transform:translateY(-2px);
  background:#fff9e6;
  box-shadow:0 4px 12px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.1);
  border-color:#d4c5a0;
}

.folder-title{
  font-size:14px;
  font-weight:700;
  color:#c41e3a;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  flex:1;
  min-width:0;
}

.folder-count{
  position:relative;
  top:0;
  right:0;
  background:#ff3b3b;
  color:white;
  padding:4px 8px;
  border-radius:8px;
  font-size:13px;
  font-weight:700;
  flex-shrink:0;
  margin-left:8px;
}

/* ===============================
   LIGHT MODE OVERRIDES
================================ */
body.light .topbar{
  background:linear-gradient(90deg,var(--gov-blue),#0f77e0);
}

/* Search wrap giữ nguyên màu trắng ở cả dark và light mode */

body.light .card{
  background:#ffffff;
  border-color:#cbd5e0;
  border-width:1.5px;
  box-shadow:0 2px 8px rgba(0,0,0,0.1);
}

body.light .card:hover{
  background:#f8fafc;
  box-shadow:0 4px 12px rgba(0,0,0,0.15);
}

body.light .folder:hover{
  background:#f5f8ff;
}

body.light .folder-title{
  color:var(--gov-blue);
}


body.dark .ai-mode-btn{
  background:#303134;
  color:#ffffff;
}

body.dark .ai-mode-btn:hover{
  background:#3c4043;
}

body.dark .ai-mode-btn::before{
  opacity:0.8;
}

body.dark .ai-mode-btn:hover::before{
  opacity:1;
}

/* Light mode - subtle style */
body.light .ai-mode-btn{
  background:#f8f9fa;
  color:#5f6368;
  border-color:#dadce0;
}

body.light .ai-mode-btn:hover{
  background:#e8eaed;
  border-color:#dadce0;
}

body.light .ai-mode-btn::before{
  opacity:0.6;
}

body.light .ai-mode-btn:hover::before{
  opacity:0.9;
}

/* ===============================
   RESPONSIVE
================================ */
@media (max-width:1000px){
  .container{ flex-direction:column; padding:12px; }
  .sidebar{ width:auto; max-width:fit-content; left:-100%; }
  .sidebar.open{ left:0; width:auto; max-width:fit-content; }
  
  .topbar{
    padding:8px 12px;
    gap:12px;
  }
  
  .topbar-left{
    gap:8px;
    flex-shrink:0;
  }
  
  .ai-mode-btn{
    padding:6px 12px;
    font-size:13px;
    gap:6px;
    height:36px;
    background:#303134;
  }
  
  .ai-mode-btn svg{
    width:16px;
    height:16px;
  }
}

@media (max-width:768px){
  .topbar{
    padding:6px 8px;
    gap:8px;
    flex-wrap:nowrap;
  }
  
  .topbar-left{
    gap:2px;
    flex-shrink:0;
  }
}

@media (max-width:480px){
  /* KHÔNG ẩn icon - giữ nguyên như hình ảnh */
  
  .topbar{
    padding:4px 6px;
    gap:6px;
    flex-wrap:nowrap;
  }
  
  .topbar-left{
    gap:4px;
    flex-shrink:0;
  }
}

@media (max-width:900px){
  .content{ grid-template-columns:repeat(auto-fill,minmax(100%,1fr)); }
}

/* Màn hình lớn - tăng kích thước nút AI Mode */
@media (min-width:1200px){
  .ai-mode-btn{
    padding:10px 20px;
    font-size:15px;
    gap:10px;
    height:44px;
  }
  
  .ai-mode-btn svg{
    width:20px;
    height:20px;
  }
}
.card-note {
  font-size: 13px;
  color: var(--muted);
  padding-top: 4px;
  opacity: .85;
}
.card-note {
  word-break: break-word;
  line-height: 1.35;
}
.card-body{
  flex:1;
  padding:0 12px;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;   /* ĐẨY TÊN + LINK LÊN TOP */
}
