/* ═══════════════════════════════════════════════════════════
   WuzManager — Gerenciador de Instâncias Wuzapi
   Design: Dark profundo com acento violeta-índigo
   Fonte: Plus Jakarta Sans + JetBrains Mono
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --sidebar-w: 230px;

    --bg:        #08090e;
    --bg-card:   #0f1117;
    --bg-input:  #151720;
    --bg-hover:  #151720;

    --border:    rgba(255,255,255,0.06);
    --border-md: rgba(255,255,255,0.1);

    --txt:       #e8eaf0;
    --txt-2:     #8b8fa8;
    --txt-3:     #3d4060;

    --accent:    #7c6af7;
    --accent-2:  #6355e0;
    --accent-glow: rgba(124,106,247,0.12);
    --accent-border: rgba(124,106,247,0.3);

    --green:  #22c55e;
    --red:    #ef4444;
    --yellow: #f59e0b;
    --blue:   #3b82f6;

    --r:  8px;
    --rl: 14px;
    --rx: 20px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--txt);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ───────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 22px 18px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 36px; height: 36px;
    background: var(--accent-glow);
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}

.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.brand-sub  { font-size: 10px; color: var(--txt-3); letter-spacing: .5px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }

.nav-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--txt-3);
    padding: 10px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r);
    color: var(--txt-2);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .15s;
    margin-bottom: 2px;
}

.nav-item:hover { background: var(--bg-hover); color: var(--txt); }
.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

.nav-icon { width: 16px; height: 16px; opacity: .7; flex-shrink: 0; }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }

.nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-user { font-size: 12px; color: var(--txt-2); }
.btn-sair {
    color: var(--txt-3); padding: 6px; border-radius: var(--r);
    display: flex; align-items: center; transition: all .15s;
    text-decoration: none;
}
.btn-sair:hover { color: var(--red); background: rgba(239,68,68,.08); }

/* ── MAIN ─────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

.topbar {
    height: 58px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 14px;
    position: sticky; top: 0;
    background: rgba(8,9,14,.9);
    backdrop-filter: blur(12px);
    z-index: 50;
}

.page-title { flex: 1; font-size: 15px; font-weight: 600; }
.page-sub { font-size: 12px; color: var(--txt-2); margin-left: 10px; }

.badge-data {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--txt-3);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 20px;
}

.page-body { padding: 28px; flex: 1; }

/* ── FLASH ────────────────────────────────────────────────── */
.flash {
    margin: 0 28px 0;
    padding: 12px 16px;
    border-radius: var(--r);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13.5px;
    font-weight: 500;
    animation: slideDown .3s ease;
    margin-top: 16px;
}
.flash-sucesso { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25); color: var(--green); }
.flash-erro    { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.25);  color: var(--red); }
.flash button  { background: none; border: none; color: inherit; cursor: pointer; opacity: .6; }

/* ── STAT CARDS ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--rl);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: border-color .2s, transform .2s;
}
.stat-card:hover { border-color: var(--border-md); transform: translateY(-1px); }
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    border-radius: var(--rl) var(--rl) 0 0;
}
.stat-card.violeta::before { background: var(--accent); }
.stat-card.verde::before   { background: var(--green); }
.stat-card.vermelho::before{ background: var(--red); }
.stat-card.azul::before    { background: var(--blue); }

.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; color: var(--txt-3); margin-bottom: 10px; }
.stat-value { font-family: 'JetBrains Mono', monospace; font-size: 30px; font-weight: 700; line-height: 1; }
.stat-card.violeta  .stat-value { color: var(--accent); }
.stat-card.verde    .stat-value { color: var(--green); }
.stat-card.vermelho .stat-value { color: var(--red); }
.stat-card.azul     .stat-value { color: var(--blue); }
.stat-desc { font-size: 12px; color: var(--txt-3); margin-top: 5px; }

/* ── CARDS ────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--rl);
    padding: 22px 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.card-title { font-size: 14px; font-weight: 600; }
.card-sub   { font-size: 12px; color: var(--txt-2); margin-top: 2px; }

/* ── GRID DE INSTÂNCIAS ────────────────────────────────────── */
.instancias-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.instancia-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--rl);
    padding: 20px;
    transition: border-color .2s, transform .2s;
    cursor: pointer;
    text-decoration: none;
    display: block;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.instancia-card:hover {
    border-color: var(--border-md);
    transform: translateY(-2px);
}

.instancia-card.conectada {
    border-color: rgba(34,197,94,.2);
}

.instancia-card.conectada::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--green);
}

.instancia-card.desconectada::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--txt-3);
}

.inst-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
}

.inst-avatar {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--accent-glow);
    border: 1px solid var(--accent-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

.inst-nome { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.inst-desc { font-size: 12px; color: var(--txt-2); }

.inst-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.inst-status.ok {
    background: rgba(34,197,94,.1);
    color: var(--green);
    border: 1px solid rgba(34,197,94,.2);
}

.inst-status.off {
    background: rgba(61,64,96,.2);
    color: var(--txt-3);
    border: 1px solid var(--border);
}

.inst-status.aguardando {
    background: rgba(245,158,11,.1);
    color: var(--yellow);
    border: 1px solid rgba(245,158,11,.2);
}

.inst-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.inst-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.inst-info-item { font-size: 11.5px; }
.inst-info-label { color: var(--txt-3); margin-bottom: 2px; }
.inst-info-value { color: var(--txt-2); font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* ── QR CODE PANEL ────────────────────────────────────────── */
.qr-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--rl);
    padding: 32px;
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.qr-wrap {
    width: 220px; height: 220px;
    background: #fff;
    border-radius: var(--r);
    margin: 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.qr-wrap img { width: 200px; height: 200px; display: block; }

.qr-status {
    font-size: 13px;
    color: var(--txt-2);
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.qr-title { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.qr-sub   { font-size: 13px; color: var(--txt-2); line-height: 1.6; }

/* ── FORMULÁRIOS ─────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--txt-2);
}

input, select, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-md);
    border-radius: var(--r);
    color: var(--txt);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13.5px;
    padding: 10px 14px;
    width: 100%;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder { color: var(--txt-3); }
select option { background: var(--bg-card); }
textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 11.5px; color: var(--txt-3); }

/* ── BOTÕES ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--r);
    border: 1px solid transparent;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn-secondary { background: transparent; color: var(--txt); border-color: var(--border-md); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: rgba(239,68,68,.08); color: var(--red); border-color: rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.15); }
.btn-success { background: rgba(34,197,94,.08); color: var(--green); border-color: rgba(34,197,94,.25); }
.btn-success:hover { background: rgba(34,197,94,.15); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .4; pointer-events: none; }

/* ── TABELAS ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    background: rgba(255,255,255,.02);
    color: var(--txt-3);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 12px 14px; vertical-align: middle; }
.td-muted { color: var(--txt-2); font-size: 12.5px; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent); }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--txt-3); }
.empty-state svg { opacity: .15; margin-bottom: 14px; }
.empty-state h3 { font-size: 15px; color: var(--txt-2); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ── SPINNER ─────────────────────────────────────────────── */
.spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}

/* ── TOAST ───────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-md);
    border-radius: var(--rl);
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(0,0,0,.6);
    animation: toastIn .3s ease;
}
.toast.ok   { border-left: 3px solid var(--green); }
.toast.erro { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.saindo { animation: toastOut .3s ease forwards; }

/* ── LOGIN ───────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--rx);
    padding: 40px 36px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo-icon {
    width: 60px; height: 60px;
    background: var(--accent-glow);
    border: 1px solid var(--accent-border);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    font-size: 26px;
}

.login-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.login-sub   { font-size: 13px; color: var(--txt-2); margin-top: 4px; }

/* ── ANIMAÇÕES ───────────────────────────────────────────── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

.pulsing { animation: pulse 1.5s ease-in-out infinite; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .instancias-grid { grid-template-columns: 1fr; }
}
