/* Kalodata Video Ranking Console — style.css v2 (V0/Vercel-inspired) */
:root{
  --bg:#0b0e13;
  --card:#161a22;
  --card2:#222834;
  --border:#2a3441;
  --border2:#455267;
  --text:#fafafa;
  --muted:#a7b0c0;
  --accent:#4f8cff;
  --accent2:#6366f1;
  --success:#22c55e;
  --error:#ef4444;
  --warning:#f59e0b;
  --radius:16px;
  --radius-sm:10px;
  --shadow:0 2px 8px rgba(0,0,0,.24), 0 14px 34px rgba(0,0,0,.28);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(circle at 8% -12%, rgba(79,140,255,.10), transparent 34%),
    radial-gradient(circle at 92% 0%, rgba(124,108,255,.07), transparent 30%),
    var(--bg);
  color:var(--text);
  line-height:1.55;
  min-height:100vh;
  -webkit-font-smoothing:antialiased;
}
a{color:var(--accent)}
code{background:var(--card2); padding:2px 7px; border-radius:6px; font-size:.84em; border:1px solid var(--border)}

/* Topbar */
.topbar{
  position:sticky; top:0; z-index:20;
  backdrop-filter: blur(16px) saturate(180%);
  background: rgba(9,9,11,.82);
  border-bottom:1px solid var(--border);
}
.topbar-inner{
  max-width:1320px; margin:0 auto; padding:14px 24px;
  display:flex; align-items:center; justify-content:space-between; gap:16px;
}
.brand{display:flex; align-items:center; gap:14px}
.brand-icon{
  width:40px; height:40px; border-radius:12px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
  font-weight:800; font-size:17px; color:white;
  box-shadow: 0 0 20px rgba(99,102,241,.4);
}
.brand h1{margin:0; font-size:16px; font-weight:700; letter-spacing:-.01em}
.brand p{margin:2px 0 0; color:var(--muted); font-size:12px}
.brand p span{color:#e4e4e7; font-family:'JetBrains Mono','Fira Code',ui-monospace,monospace; font-size:11px}

/* Global progress bar — ngay duoi topbar */
.global-progress{
  position:fixed; top:60px; left:0; right:0; z-index:19;
  height:3px; background:var(--card2);
  overflow:hidden; transition: opacity .3s;
}
.global-progress.hidden{opacity:0; pointer-events:none}
.global-progress-fill{
  height:100%; width:0%;
  background:linear-gradient(90deg,#3b82f6,#6366f1);
  transition:width .3s;
  box-shadow:0 0 8px rgba(99,102,241,.5);
}
.global-progress-text{
  position:fixed; top:64px; left:50%; transform:translateX(-50%); z-index:19;
  font-size:11px; color:var(--muted); background:var(--card);
  padding:2px 10px; border-radius:6px; border:1px solid var(--border);
  opacity:0; transition:opacity .3s; pointer-events:none;
}
.global-progress-text.visible{opacity:1}
/* Fetch row — tabs + auto inputs cung dong */
.fetch-row{
  display:flex; align-items:center; gap:12px; flex-wrap:nowrap;
}
.fetch-mode-tabs{display:flex;gap:6px;flex-shrink:0}
.auto-mode-fields{
  display:flex; align-items:flex-end; gap:10px;
  margin-left:auto;
  flex-shrink:1; overflow:hidden;
}
.auto-field{display:flex; flex-direction:column; gap:4px;}
.auto-field label{font-size:11px; color:var(--muted); white-space:nowrap;}
.auto-field input{
  width:110px; max-width:130px;
  padding:7px 10px; font-size:13px;
  background:var(--bg); border:1px solid var(--border2);
  border-radius:var(--radius-sm); color:var(--text);
}
.card-fetch-mode .card-head-actions{gap:8px;}
.card-fetch-mode .card-head-actions .btn{padding:11px 22px; font-size:14px;}

.topbar-actions{display:flex; gap:8px}

/* Container */
.container{max-width:1320px; margin:20px auto; padding:0 24px 48px; display:flex; flex-direction:column; gap:14px}

/* ===== 2-COLUMN LAYOUT — 2 bên cân đối 50/50 ===== */
.main-layout{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:20px;
  width:100%;
  max-width:100%;
  padding:20px 24px 0 24px;
  align-items:stretch;
}
.left-column{
  display:flex; flex-direction:column; gap:16px; min-width:0; min-height:0;
}
#apiForm{display:flex; flex-direction:column; gap:16px; min-width:0; margin:0;}
.right-column{
  display:flex; flex-direction:column; gap:16px; min-width:0; min-height:0;
}
.right-column .card{min-height:0}
.card-fetch-mode{border-color:rgba(59,130,246,.25); background:rgba(59,130,246,.04); flex-shrink:0;}
.card-fetch-mode .card-head{border-bottom-color:rgba(59,130,246,.15)}

/* Bottom section — căn giữa, full-width có giới hạn */
.bottom-section{
  max-width:1280px;
  margin:0 auto;
  padding:20px 24px 48px;
  display:flex; flex-direction:column; gap:14px;
  width:100%;
}

.card-bottom{width:100%}

/* Topbar tràn rộng hơn */
.topbar-inner{max-width:100%;}

/* Responsive */
@media (max-width: 960px){
  .main-layout{grid-template-columns:1fr; padding:16px 12px 0 12px}
  .left-column{max-width:100%}
  .right-column{max-width:100%}
  .bottom-section{max-width:100%}
}

/* Card */
.card{
  background: var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
  transition: border-color .15s;
}
.card:hover{border-color: var(--border2)}
.card-head{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  min-width:0;
  padding:14px 20px;
  background:linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,0));
  border-bottom:1px solid var(--border);
}
.card-head > *{min-width:0}
.left-column .card-head{padding-left:16px; padding-right:16px}
.card-head h2{margin:0; font-size:14px; font-weight:600; letter-spacing:.1px; display:flex; align-items:center; gap:7px; color:#eef1f7}
.card-head .icon{font-size:14px}
.card-head-actions{display:flex; align-items:center; gap:10px}
.card-body{padding:16px 20px}
.badge{font-size:11px; padding:3px 9px; border-radius:999px; background:rgba(99,102,241,.12); color:#a5b4fc; border:1px solid rgba(99,102,241,.2); font-weight:500}
.hint{color:var(--muted); font-size:12px}
.req{color:var(--error)}

/* Forms */
.grid{display:grid; gap:14px; margin-bottom:14px}
.grid-4{grid-template-columns: repeat(4, 1fr)}
.grid-3{grid-template-columns: repeat(3, 1fr)}
@media (max-width: 1024px){ .grid-4{grid-template-columns: repeat(2, 1fr)} }
@media (max-width: 640px){ .grid-4, .grid-3{grid-template-columns: 1fr} }

.form-row{display:flex; flex-direction:column; gap:5px}
.form-row label{font-size:12px; font-weight:500; color:#a1a1aa; letter-spacing:.1px}
.form-row input, .form-row select{
  width:100%; padding:9px 12px;
  background: var(--bg);
  border:1px solid var(--border2);
  border-radius: var(--radius-sm);
  color:var(--text); font-size:13.5px; outline:none;
  transition: border-color .15s, box-shadow .15s;
}
.form-row input:focus, .form-row select:focus{
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-row input::placeholder{color:#52525b}
.input-with-action{display:flex; gap:8px; align-items:center}
.input-with-action input{flex:1}

.form-actions{display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:6px}
.validation-msg{color:var(--error); font-size:13px; min-height:18px}

/* Buttons */
.btn{
  appearance:none; border:1px solid var(--border2);
  background: var(--card2); color:#e4e4e7;
  padding:8px 14px; border-radius: var(--radius-sm);
  font-size:13px; font-weight:500; cursor:pointer;
  transition: all .15s; font-family:inherit;
}
.btn:hover{border-color:#52525b; background:#3f3f46; transform: translateY(-1px)}
.btn:active{transform: translateY(0)}
.btn-primary{
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-color: transparent; color:white;
  padding:10px 20px; font-size:14px; font-weight:600;
  box-shadow: 0 4px 14px rgba(59,130,246,.35);
}
.btn-primary:hover{filter:brightness(1.08); box-shadow: 0 6px 20px rgba(59,130,246,.45)}
.btn-primary:disabled{opacity:.55; cursor:not-allowed; transform:none; filter:none}
.btn-sm{padding:5px 10px; font-size:12px}
.btn-ghost{background: transparent; border-color: transparent}
.btn-ghost:hover{background:var(--card2); border-color:var(--border2)}

/* Code blocks */
.code-block{
  margin:0; padding:14px 16px;
  background: #09090b;
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family:'JetBrains Mono','Fira Code',ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-size:12px; line-height:1.65;
  white-space: pre-wrap; word-break: break-word;
  max-height: 400px; overflow:auto;
  color:#d4d4d8;
}
.code-block.small{max-height:280px; font-size:11.5px}

/* Tabs */
.tabs{display:flex; gap:4px; background: var(--bg); padding:4px; border-radius:10px; border:1px solid var(--border)}
.tab{
  padding:6px 14px; border-radius:8px; border:none;
  background: transparent; color:var(--muted);
  font-size:13px; font-weight:500; cursor:pointer;
  transition: all .15s; font-family:inherit;
}
.tab.active{background: var(--accent); color:white; box-shadow: 0 2px 8px rgba(59,130,246,.3)}

/* Meta bar */
.meta-bar{
  display:flex; flex-wrap:wrap; gap:6px; align-items:center;
  padding:8px 12px; margin-bottom:8px;
  background: rgba(59,130,246,.06);
  border:1px solid rgba(59,130,246,.15);
  border-radius: var(--radius-sm);
  font-size:12px; line-height:1.2;
}
.meta-item{padding:4px 10px; background: rgba(255,255,255,.04); border-radius:6px; font-weight:500}
.meta-item.hint{background: transparent; color:var(--muted); font-weight:400}

/* Alerts */
.alert{padding:12px 16px; border-radius: var(--radius-sm); font-size:13px; margin-bottom:12px}
.alert-error{background: rgba(239,68,68,.1); border:1px solid rgba(239,68,68,.25); color:#fca5a5}
.hidden{display:none !important}
.empty-state{text-align:center; padding:36px 16px; color:var(--muted)}
.empty-state p{margin:6px 0}
.empty-state strong{color:var(--text)}

/* Table */
.table-wrap{overflow:auto; border:1px solid var(--border); border-radius: var(--radius-sm)}
.data-table{width:100%; border-collapse:collapse; font-size:11.5px; line-height:1.3;}
.data-table th{
  position:sticky; top:0; z-index:2;
  background:#18181b; color:#a1a1aa;
  text-align:left; padding:6px 8px;
  font-size:10.5px; line-height:1.25; letter-spacing:.35px; text-transform:uppercase; font-weight:600;
  border-bottom:1px solid var(--border);
  white-space:nowrap;
}
.data-table td{
  padding:4px 8px; line-height:1.2; border-bottom:1px solid rgba(39,39,42,.8);
  vertical-align:middle; max-width:260px;
  color:#d4d4d8;
}
.data-table tbody tr{transition: background .1s}
.data-table tbody tr:nth-child(even){background:rgba(255,255,255,.018)}
.data-table tbody tr:hover{background: rgba(59,130,246,.04)}
.data-table td.mono{font-family:'JetBrains Mono','Fira Code',ui-monospace,monospace; font-size:11px; line-height:1.2; word-break:break-all; color:#a1a1aa}
.data-table td.title{max-width:220px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:#e4e4e7}
.badge-bool.yes{background: rgba(34,197,94,.12); color:#86efac; border:1px solid rgba(34,197,94,.2)}
.badge-bool.no{background: rgba(239,68,68,.1); color:#fca5a5; border:1px solid rgba(239,68,68,.18)}

/* Pagination */
.pagination{display:flex; align-items:center; justify-content:center; gap:12px; margin-top:14px; padding-top:14px; border-top:1px solid var(--border)}
.page-info{font-size:13px; color:var(--muted); font-weight:500}

/* Raw tab */
.tab-panel{display:none}
.tab-panel.active.active-table{display:flex; flex-direction:column; flex:1; min-height:0; overflow:hidden}
.tab-panel.active{display:block}
.raw-actions{display:flex; gap:8px; margin-bottom:10px; justify-content:flex-end}

/* Debug */
.collapsible .card-head{cursor:pointer; user-select:none}
.chevron{transition: transform .2s; color:var(--muted); font-size:11px}
.collapsible.open .chevron{transform: rotate(180deg)}
.debug-grid{display:grid; grid-template-columns: repeat(2, 1fr); gap:10px; margin-bottom:14px; font-size:13px}
@media (max-width:640px){ .debug-grid{grid-template-columns:1fr} }
.debug-section{margin-top:12px}
.debug-section h4{margin:0 0 6px; font-size:11px; color:var(--muted); letter-spacing:.4px; text-transform:uppercase; font-weight:600}

/* Footer */
.footer{text-align:center; padding:12px; color:#52525b; font-size:12px; border-top:1px solid var(--border)}

/* Toast */
.toast{
  position:fixed; bottom:24px; left:50%; transform: translateX(-50%);
  background:#27272a; color:var(--text);
  border:1px solid var(--border2); padding:10px 18px;
  border-radius:12px; font-size:13px; font-weight:500;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index:50; backdrop-filter: blur(8px);
}
.toast.success{border-color: rgba(34,197,94,.35); background: rgba(34,197,94,.1)}
.toast.error{border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.1)}

/* Scrollbar */
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#3f3f46;border-radius:999px}
::-webkit-scrollbar-thumb:hover{background:#52525b}
/* Fetch Mode Tabs */

.fetch-tab{
  padding:8px 16px;border-radius:10px;border:1px solid var(--border2);
  background:var(--card2);color:var(--muted);
  font-size:13px;font-weight:600;cursor:pointer;
  transition:all .15s;font-family:inherit;
}
.fetch-tab:hover{border-color:#52525b;background:#3f3f46}
.fetch-tab.active{background:var(--accent);color:white;border-color:transparent;box-shadow:0 2px 8px rgba(59,130,246,.3)}

/* Export buttons tren title Ket qua */
.export-top{
  display:flex; align-items:center; gap:6px;
}
.export-top .btn-sm{
  padding:4px 10px; font-size:11.5px;
  border-radius:8px;
}





/* Progress */
.progress-bar{
  height:2px;background:var(--card2);border-radius:999px;
  overflow:hidden;margin-bottom:6px;
}
.progress-fill{
  height:100%;background:linear-gradient(90deg,#3b82f6,#6366f1);
  border-radius:999px;transition:width .3s;
  box-shadow:0 0 10px rgba(99,102,241,.4);
}
.progress-text{font-size:13px;color:var(--muted);font-weight:500}
.progress-text .accent{color:var(--accent);font-weight:700}
/* ===== CÂN ĐỐI 2 CỘT ===== */
.right-column .table-wrap{
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow:auto;
  flex:1;
  min-height:0;
}
.right-column .empty-state{
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  min-height:0; padding: 48px 24px;
}
.left-column .card-fetch-mode .card-body{ padding:14px 16px; }
/* Đảm bảo grid trong cột trái không bị vỡ */
.left-column .grid-4{ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.left-column .grid-3{ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
@media (max-width: 640px){
  .left-column .grid-4, .left-column .grid-3{ grid-template-columns: 1fr; }
}

/* Right column: responseCard fill */

.right-column #responseCard{flex:1;display:flex;flex-direction:column;height:100%;min-height:0}
.right-column #responseCard .card-body{flex:1;display:flex;flex-direction:column;overflow:hidden;min-height:0}
/* Right column: stretch equal height with left */
.right-column{display:flex;flex-direction:column;gap:16px}
.right-column>.card{flex:1;display:flex;flex-direction:column}
.right-column>.card .card-body{flex:1;display:flex;flex-direction:column;min-height:0}

/* Form inputs fill full width */
.left-column .form-row input,
.left-column .form-row select{
  width:100%;
  padding:8px 12px;
  font-size:13px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border:1px solid var(--border2);
  color:var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.left-column .form-row input:focus,
.left-column .form-row select:focus{
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.left-column .card-body{padding:14px 16px}

/* Pagination */
.smart-pagination{display:flex;align-items:center;justify-content:center;gap:5px;flex-wrap:wrap}
.pagination .page-num{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:34px;height:34px;padding:0 8px;
  border:1px solid var(--border2);border-radius:8px;
  background:var(--card2);color:var(--muted);
  font-size:13px;font-weight:600;cursor:pointer;
  transition:all .15s;font-family:inherit;
}
.pagination .page-num:hover{background:#3f3f46;color:#e4e4e7;border-color:#52525b}
.pagination .page-num.active{
  background:var(--accent);color:white;border-color:transparent;
  box-shadow:0 2px 8px rgba(59,130,246,.35);
  cursor:default;
}
.pagination .page-num:disabled{opacity:.4;cursor:not-allowed}
.pagination .page-num.ellipsis{
  border:none;background:none;color:var(--muted);cursor:default;
  letter-spacing:2px;font-size:14px;
}
.pagination .page-num.ellipsis:hover{background:none;color:var(--muted)}


/* Fetch-row: fixed height de khong thay doi khi toggle auto */
.card-fetch-mode .fetch-row{
  min-height:64px;
  align-items:center;
}
.card-fetch-mode .auto-mode-fields{
  margin-left:auto;
}
