/* ============================================
   NZK ADMIN DASHBOARD — style.css
   ============================================ */

/* --- VARIÁVEIS --- */
:root { 
    --bg: #1e1f22; 
    --sidebar: #2b2d31; 
    --card: #313338; 
    --accent: #5865f2; 
    --accent-hover: #4752c4;
    --text-main: #f2f3f5; 
    --text-muted: #b5bac1;
    --danger: #ed4245; 
    --success: #23a559; 
    --gold: #f1c40f;
    --silver: #95a5a6;
    --bronze: #e67e22;
}

/* --- BASE --- */
/* Reserva o espaço da scrollbar vertical sempre, mesmo quando o conteúdo
   ainda não precisa dela. Sem isso, toda vez que a altura da página muda
   rápido (ex: troca de servidor no select, que mostra loading e depois
   carrega os dados), a barra de rolagem aparece/some e a página inteira
   "pula" de largura — o efeito de tremor que o usuário reportou.
   scrollbar-gutter cobre os navegadores modernos; overflow-y: scroll é o
   fallback pra quem ainda não suporta. */
html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    color: var(--text-main); 
    margin: 0; 
    padding: 20px;
    line-height: 1.5;
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    animation: fadeIn 0.5s ease; 
}

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

h1 { font-size: 24px; margin-bottom: 30px; font-weight: 800; }

/* --- GRID DE SERVIDORES --- */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 20px;
    width: 100%;
}

.server-card { 
    background: var(--card); 
    padding: 30px; 
    border-radius: 16px; 
    cursor: pointer; 
    text-align: center; 
    border: 1px solid rgba(255,255,255,0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.server-card:hover { 
    border-color: var(--accent); 
    transform: translateY(-8px);
    background: #383a40;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.server-icon { font-size: 48px; margin-bottom: 15px; display: inline-block; }

.icon-wrapper {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.server-icon-img {
    width: 55px;
    height: 55px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.server-card:hover .server-icon-img {
    border-color: var(--accent);
    transform: scale(1.1);
}

/* --- EDITOR --- */
#editor { 
    background: var(--sidebar); 
    padding: 40px; 
    border-radius: 20px; 
    margin-top: 20px; 
    display: none; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 25px;
}

.editor-header h2 { margin: 0; }

.section-title { 
    padding-bottom: 12px; 
    margin-top: 50px; 
    color: var(--accent); 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* --- FORMULÁRIOS --- */
.form-row { 
    display: flex; 
    gap: 20px; 
    align-items: flex-end; 
    margin-bottom: 30px; 
    flex-wrap: wrap; 
    background: rgba(0,0,0,0.2); 
    padding: 25px; 
    border-radius: 12px; 
}

.field { display: flex; flex-direction: column; gap: 10px; flex-grow: 1; min-width: 0; }

label { font-size: 11px; color: var(--text-muted); font-weight: 800; }

input, select { 
    background: #1e1f22; 
    border: 1px solid #444; 
    color: white; 
    padding: 12px; 
    border-radius: 8px; 
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

input:focus, select:focus { border-color: var(--accent); }

/* --- BOTÕES --- */
button { 
    background: var(--accent); 
    color: white; 
    border: none; 
    padding: 12px 24px; 
    border-radius: 8px; 
    cursor: pointer; 
    font-weight: 700; 
    transition: 0.2s;
}

button:hover { background: var(--accent-hover); transform: scale(1.02); }
button.secondary { background: #4e5058; margin-bottom: 25px; }
button.success { background: var(--success); }
button.danger { background: var(--danger); padding: 12px 24px; font-size: 11px; }

/* --- ABAS --- */
.tab-container {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.3s ease;
    border-radius: 8px 8px 0 0;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active { color: var(--accent); }

.tab-btn.active::after {
    content: "";
    position: absolute;
    bottom: -7px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent);
    border-radius: 10px;
    box-shadow: 0 0 10px var(--accent);
}

/* --- TABELAS --- */
.table-wrapper {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 8px;
    margin-top: 15px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.1);
}

.table-wrapper th,
.table-wrapper td {
    white-space: nowrap;
}

.table-wrapper::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrapper::-webkit-scrollbar-thumb { background: var(--card); border-radius: 10px; }
.table-wrapper::-webkit-scrollbar-track { background: transparent; }

table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0 8px; 
    margin-top: 0;
}

th { 
    padding: 15px 20px; 
    color: var(--text-muted); 
    font-size: 11px; 
    text-transform: uppercase; 
    border: none; 
    text-align: left;
    position: sticky;
    top: 0;
    background: var(--sidebar);
    z-index: 10;
}

td { 
    padding: 15px 20px; 
    background: rgba(255, 255, 255, 0.03); 
    border: none;
    transition: all 0.2s ease;
}

td:first-child { border-radius: 10px 0 0 10px; }
td:last-child { border-radius: 0 10px 10px 0; }
tr:hover td { background: rgba(255, 255, 255, 0.07); transform: scale(1.005); }

/* --- RANKING --- */
.top-1 td { 
    background: rgba(241, 196, 15, 0.2) !important;
    border-top: 1px solid rgba(241, 196, 15, 0.25) !important;
    border-bottom: 1px solid rgba(241, 196, 15, 0.25) !important;
}

.top-1 b { color: var(--gold); text-shadow: 0 0 10px rgba(241, 196, 15, 0.5); }
.top-2 td { background: rgba(255, 255, 255, 0.3) !important; }
.top-3 td { background: rgba(230, 126, 34, 0.15) !important; }

.xp-bar-container { 
    width: 100%; 
    height: 4px; 
    background: rgba(0,0,0,0.3); 
    border-radius: 10px; 
    margin-top: 6px; 
    overflow: hidden; 
}

.xp-bar-fill { 
    height: 100%; 
    background: var(--accent); 
    box-shadow: 0 0 8px var(--accent); 
}

/* --- MISC --- */
code { 
    background: #1e1f22; 
    padding: 4px 8px; 
    border-radius: 6px; 
    color: var(--accent); 
    font-size: 12px; 
}

/* --- TOASTS --- */
.nzk-toast {
    position: fixed;
    bottom: -60px;
    right: 20px;
    padding: 15px 25px;
    background: var(--success);
    color: white;
    border-radius: 10px;
    font-weight: 700;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    z-index: 10000;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 0;
    display: flex;
    align-items: center;
}

.nzk-toast.show { bottom: 20px; opacity: 1; }
.nzk-toast.error { background: var(--danger); }

/* --- SCROLLBAR GLOBAL --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 10px; }

/* --- LOADING --- */
.loading-cell {
    text-align: center;
    padding: 30px !important;
    color: var(--text-muted);
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- ESTATÍSTICAS --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 15px;
    margin-bottom: 10px;
}

.stat-card {
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
}

/* --- CABEÇALHOS ORDENÁVEIS --- */
.th-sort {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.th-sort:hover { color: var(--accent); }

/* --- BOTÕES DA TABELA DE PATENTES --- */
.btn-table-action {
    padding: 8px 0 !important;
    font-size: 11px !important;
    width: 80px !important;
    margin-bottom: 0 !important;
    height: 34px !important;
    line-height: 1 !important;
}

/* --- SERVIDOR REMOVIDO --- */
.server-card-removido {
    border-color: var(--danger) !important;
    opacity: 0.7;
}

.server-removido-badge {
    font-size: 11px;
    color: var(--danger);
    margin-top: 8px;
    font-weight: 700;
}

/* --- RESPONSIVIDADE MOBILE --- */
@media (max-width: 640px) {
    body { padding: 12px; }

    h1 { font-size: 20px; }
    .editor-header h2 { font-size: 17px; }

    .section-title { font-size: 12px; margin-top: 34px; }

    .form-row { padding: 16px; gap: 14px; margin-bottom: 22px; }

    button { padding: 10px 16px; font-size: 13px; }
    button.danger { padding: 7px 12px; font-size: 10px; }

    .server-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
    .server-card { padding: 16px; }
    .server-icon { font-size: 34px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 18px; }

    th, td { padding: 10px 12px; font-size: 12.5px; }

    .tab-btn { padding: 10px 14px; font-size: 13px; }
}

/* --- SELECT DE IDIOMA COM BANDEIRA --- */
.lang-select { position: relative; }

.lang-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e1f22;
    border: 1px solid #444;
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.lang-trigger:hover { border-color: var(--accent); }

.lang-flag { width: 18px; height: 13px; object-fit: cover; border-radius: 2px; }

.lang-trigger::after {
    content: "▾";
    margin-left: 4px;
    color: var(--text-muted);
    font-size: 10px;
}

.lang-options {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--sidebar);
    border: 1px solid #444;
    border-radius: 10px;
    padding: 6px;
    margin: 0;
    list-style: none;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.lang-options[hidden] { display: none; }

.lang-options li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.lang-options li img { width: 18px; height: 13px; object-fit: cover; border-radius: 2px; }

.lang-options li:hover { background: rgba(255,255,255,0.07); }
.lang-options li[aria-selected="true"] { background: rgba(88,101,242,0.15); color: var(--accent); }

#serverTitle { white-space: nowrap; }

/* --- TIPO DO SERVIDOR --- */
.server-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;

    margin: 4px 0 10px;
    padding: 4px 10px;

    border-radius: 999px;

    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;

    white-space: nowrap;
}

.server-type-adm {
    color: var(--gold);
    background: rgba(241, 196, 15, 0.12);
    border: 1px solid rgba(241, 196, 15, 0.35);
}

.server-type-premium {
    color: #c084fc;
    background: rgba(192, 132, 252, 0.12);
    border: 1px solid rgba(192, 132, 252, 0.35);
}

/* --- CONFIGURAÇÕES GLOBAIS --- */

#globalServerList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.global-server-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding: 16px 18px;

    background: rgba(255, 255, 255, 0.025);

    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.global-server-info {
    min-width: 0;
}

.global-server-info strong {
    display: block;

    font-size: 14px;
    color: var(--text-main);

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}