/* ==========================================================================
   Geral & Variáveis
   ========================================================================== */
:root { 
    color-scheme: dark; 
    --sb-width: 288px;
    --accent: #6366f1;
    --bg-main: #0a0a0a;
    --bg-card: rgba(23, 23, 23, 0.6);
    --border-color: #262626;
    --mobile-header-h: 64px;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent;
}

.app-body {
    background-color: var(--bg-main);
    color: #f5f5f5;
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Novo Breakpoint Mobile: Vai até 1023px (Cobre celulares deitados e tablets verticais) */
@media (max-width: 1023px) {
    .app-body {
        padding-top: calc(var(--mobile-header-h) + env(safe-area-inset-top, 20px));
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
}

/* ==========================================================================
   Scrollbar Customizada
   ========================================================================== */
::-webkit-scrollbar { 
    width: 6px; 
    height: 6px; 
}

::-webkit-scrollbar-track { 
    background: transparent; 
}

::-webkit-scrollbar-thumb { 
    background: #333; 
    border-radius: 10px; 
}

::-webkit-scrollbar-thumb:hover { 
    background: #444; 
}

/* ==========================================================================
   Layout Principal e Respiros (Clean UI)
   ========================================================================== */
.container { 
    max-width: 1400px; 
    margin: 0 auto; 
    padding: 32px 24px; 
}

/* Afastamento base para todas as main views */
.dashboard-main,
.finance-main,
.monitor-main,
.rooms-main,
.view-main {
    min-height: 100vh;
    padding-bottom: 40px; 
}

/* ==========================================================================
   Header Desktop
   ========================================================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background-color: rgba(10, 10, 10, 0.75);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    height: 64px;
}

.header-container {
    max-width: 1400px; 
    height: 100%; 
    margin: 0 auto; 
    padding: 0 24px;
    display: flex; 
    align-items: center; 
    justify-content: space-between;
}

.header-meta { 
    font-size: 0.875rem; 
    color: #737373; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

.header-right { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

/* ==========================================================================
   Sidebar & Navigation (Leftbar)
   ========================================================================== */
body.sidebar-collapsed { 
    --sb-width: 80px; 
}

body { 
    transition: padding-left 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
}

/* Desktop começa apenas a partir de 1024px */
@media (min-width: 1024px) { 
    body { 
        padding-left: var(--sb-width); 
    } 
}

/* Header Mobile (Fixed com SafeArea) */
.mobile-nav {
    display: flex; 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    z-index: 100;
    width: 100%; 
    background-color: #000; 
    border-bottom: 1px solid var(--border-color);
    padding-top: env(safe-area-inset-top, 20px);
    padding-left: calc(20px + env(safe-area-inset-left, 0px)); 
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    height: calc(var(--mobile-header-h) + env(safe-area-inset-top, 20px));
    align-items: center; 
    justify-content: space-between; 
}

@media (min-width: 1024px) { 
    .mobile-nav { 
        display: none; 
    } 
}

/* Barra Lateral */
.sidebar {
    position: fixed; 
    inset: 0 auto 0 0; 
    z-index: 110; 
    width: var(--sb-width);
    background-color: #080808; 
    border-right: 1px solid var(--border-color);
    display: flex; 
    flex-direction: column; 
    transition: transform 0.3s;
    padding-top: env(safe-area-inset-top, 20px);
    padding-left: env(safe-area-inset-left, 0px);
}

@media (max-width: 1023px) { 
    .sidebar { 
        transform: translateX(-100%); 
        width: 280px; 
        width: calc(280px + env(safe-area-inset-left, 0px));
    }
    .sidebar.open { 
        transform: translateX(0); 
        box-shadow: 20px 0 50px rgba(0,0,0,0.9); 
    }
}

.sidebar-head { 
    height: 64px; 
    padding: 0 20px; 
    display: flex; 
    align-items: center; 
    border-bottom: 1px solid var(--border-color); 
    position: relative; 
    flex-shrink: 0; 
}

.nav-list { 
    flex: 1; 
    overflow-y: auto; 
    padding: 24px 16px; 
    list-style: none; 
    margin: 0; 
}

.nav-item { 
    margin-bottom: 8px; 
}

.nav-link { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    padding: 12px 16px; 
    border-radius: 10px; 
    color: #94a3b8; 
    text-decoration: none; 
    transition: 0.2s; 
    font-size: 0.925rem; 
}

.nav-link:hover, 
.nav-link.active { 
    background-color: #171717; 
    color: #fff; 
}

.nav-link.active { 
    border: 1px solid var(--border-color); 
}

.nav-link i { 
    font-size: 1.3rem; 
    color: #64748b; 
}

.nav-link:hover i, 
.nav-link.active i { 
    color: var(--accent); 
}

.sidebar-collapsed .sidebar-label { 
    display: none; 
}

.btn-sb { 
    background: none; 
    border: none; 
    color: #737373; 
    cursor: pointer; 
    padding: 8px; 
    display: flex; 
    align-items: center; 
}

.btn-collapse { 
    position: absolute; 
    right: -12px; 
    top: 50%; 
    transform: translateY(-50%); 
    background: #111; 
    border: 1px solid var(--border-color); 
    border-radius: 6px; 
    display: none; 
    padding: 4px; 
    z-index: 10;
}

@media (min-width: 1024px) { 
    .btn-collapse { 
        display: flex; 
    } 
}

.logout-wrap { 
    padding: 20px 16px; 
    border-top: 1px solid var(--border-color); 
    margin-bottom: env(safe-area-inset-bottom); 
}

.btn-logout { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 10px; 
    width: 100%; 
    padding: 12px; 
    background: #111; 
    color: #f87171; 
    border: 1px solid var(--border-color); 
    border-radius: 10px; 
    text-decoration: none; 
    transition: 0.2s;
}

.btn-logout:hover { 
    background-color: rgba(220, 38, 38, 0.1); 
    border-color: #ef4444; 
}

.sb-backdrop { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.7); 
    backdrop-filter: blur(4px); 
    z-index: 105; 
    display: none; 
}

.sb-backdrop.show { 
    display: block; 
}

/* ==========================================================================
   Componentes Globais (Cards, Inputs, Buttons)
   ========================================================================== */
.card { 
    border-radius: 16px; 
    border: 1px solid var(--border-color); 
    background-color: var(--bg-card); 
    padding: 28px; 
}

.btn-primary, 
.btn-submit, 
.btn-validate { 
    border-radius: 10px; 
    background-color: var(--accent); 
    color: #fff; 
    padding: 12px 24px; 
    font-weight: 600; 
    cursor: pointer; 
    border: none; 
    transition: 0.2s;
}

.btn-primary:hover, 
.btn-submit:hover { 
    filter: brightness(1.1); 
}

.btn-action { 
    display: inline-flex; 
    align-items: center; 
    gap: 8px; 
    border-radius: 10px; 
    border: 1px solid var(--border-color); 
    background-color: #0a0a0a; 
    padding: 10px 16px; 
    font-size: 0.875rem; 
    color: #e5e5e5; 
    cursor: pointer; 
    text-decoration: none; 
    transition: 0.2s;
}

.btn-action:hover {
    background-color: #171717;
}

.btn-danger { 
    border-color: rgba(159, 18, 57, 0.6); 
    background-color: rgba(159, 18, 57, 0.2); 
    color: #fecdd3; 
}

.btn-danger:hover {
    background-color: rgba(159, 18, 57, 0.4); 
}

.input-base, 
.input-control,
.form-input { 
    width: 100%; 
    border-radius: 10px; 
    background-color: #050505; 
    border: 1px solid var(--border-color); 
    color: #fff; 
    padding: 14px 16px; 
    outline: none; 
    transition: 0.2s;
}

.input-base:focus, 
.input-control:focus,
.form-input:focus { 
    border-color: var(--accent); 
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* ==========================================================================
   Modais de Sistema
   ========================================================================== */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.7); 
    backdrop-filter: blur(6px); 
    z-index: 150; 
    display: none; 
}

.modal-overlay.show { 
    display: block; 
}

.modal { 
    position: fixed; 
    inset: 0; 
    z-index: 160; 
    display: none; 
}

.modal.show { 
    display: block; 
}

.modal-wrapper { 
    height: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 16px; 
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
}

.modal-box { 
    width: 100%; 
    max-width: 500px; 
    background: #0f0f0f; 
    border: 1px solid var(--border-color); 
    border-radius: 16px; 
    padding: 0; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    overflow: hidden;
}

.modal-box.sm {
    max-width: 400px;
}

.modal-head {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #141414;
}

.modal-body {
    padding: 24px;
    max-height: 70vh; 
    overflow-y: auto;
}

/* ==========================================================================
   Login & PIN
   ========================================================================== */
.login-screen { 
    min-height: 100vh; 
    display: grid; 
    place-items: center; 
    padding: 0 16px; 
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
}

.login-container { 
    width: 100%; 
    max-width: 400px; 
}

.login-card { 
    background-color: rgba(23, 23, 23, 0.8); 
    border: 1px solid var(--border-color); 
    border-radius: 20px; 
    padding: 32px; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

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

.login-header h1 {
    font-size: 1.5rem;
    margin: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: #a3a3a3;
}

.modal-pin { 
    position: fixed; 
    inset: 0; 
    z-index: 200; 
    display: none; 
}

.modal-pin.show { 
    display: block; 
}

.modal-content-wrapper { 
    position: relative; 
    z-index: 10; 
    display: flex; 
    min-height: 100%; 
    align-items: center; 
    justify-content: center; 
    padding: 16px; 
}

.pin-grid { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 8px; 
}

.pinbox { 
    width: 48px; 
    height: 56px; 
    text-align: center; 
    font-size: 1.5rem; 
    border-radius: 12px; 
    background-color: #0f0f0f; 
    border: 1px solid var(--border-color); 
    color: #fff; 
    outline: none; 
    transition: 0.2s;
}

.pinbox:focus {
    border-color: var(--accent);
}

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--border-color);
    color: #a3a3a3;
    padding: 12px;
    border-radius: 10px;
    flex: 1;
    cursor: pointer;
}

.error-msg {
    color: #f87171;
    font-size: 0.875rem;
    margin-top: 12px;
    text-align: center;
}

/* ==========================================================================
   Financeiro & Cobranças
   ========================================================================== */
.grid-layout { 
    display: grid; 
    gap: 24px; 
    grid-template-columns: 1fr; 
}

@media (min-width: 1024px) { 
    .grid-layout { 
        grid-template-columns: 2fr 1fr; 
    } 
}

.grid-finance {
    display: grid;
    gap: 24px;
    grid-template-columns: 1fr; 
}

@media (min-width: 640px) {
    .grid-finance {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1280px) {
    .grid-finance {
        grid-template-columns: repeat(3, 1fr);
    }
}

.card-balance { 
    border-radius: 16px; 
    border: 1px solid var(--border-color); 
    background-color: var(--bg-card); 
    padding: 24px; 
    transition: transform 0.2s;
}

.card-balance:hover {
    transform: translateY(-2px);
    border-color: #404040;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.card-brand img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    background-color: #fff; 
    padding: 4px;
}

.card-brand h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: #e5e5e5;
}

.time-text {
    font-size: 0.75rem;
    color: #737373;
}

.balance-value { 
    margin-top: 20px; 
    font-size: 2.5rem; 
    font-weight: 700; 
    letter-spacing: -1px;
    color: #fff;
}

.charge-item { 
    border-radius: 12px; 
    border: 1px solid var(--border-color); 
    background-color: rgba(10, 10, 10, 0.4); 
    padding: 16px; 
    margin-bottom: 12px; 
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.radio-label { 
    display: flex; 
    align-items: center; 
    gap: 16px; 
    border-radius: 12px; 
    border: 1px solid var(--border-color); 
    background-color: #111; 
    padding: 16px; 
    cursor: pointer; 
    transition: 0.2s;
}

.radio-label:hover {
    border-color: #404040;
}

.client-mode-container {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.radio-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    margin-top: 16px;
}

@media (min-width: 640px) {
    .radio-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ==========================================================================
   Monitoramento VPS (Organizado em Cards Grid)
   ========================================================================== */
.monitor-layout { 
    display: flex; 
    flex-direction: column; 
    gap: 24px; 
}

#cards { 
    display: grid; 
    gap: 24px; 
    grid-template-columns: 1fr; 
}

@media (min-width: 640px) {
    #cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1280px) { 
    #cards { 
        grid-template-columns: repeat(3, 1fr);
    } 
}

.bar-group {
    margin-bottom: 16px;
}

.bar-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.875rem;
    color: #a3a3a3;
}

.bar-bg { 
    height: 8px; 
    width: 100%; 
    border-radius: 9999px; 
    background-color: #262626; 
    overflow: hidden; 
}

.bar-fill { 
    height: 100%; 
    border-radius: 9999px;
    transition: width 0.3s; 
}

.bg-emerald { background-color: #10b981; }
.bg-amber { background-color: #f59e0b; }
.bg-rose { background-color: #f43f5e; }
.bg-neutral { background-color: #525252; }

.load-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.load-chips {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap; 
}

.chip { 
    font-size: 0.75rem; 
    padding: 4px 10px; 
    border-radius: 6px; 
    border: 1px solid transparent; 
}

.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 16px; 
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.75rem;
    color: #a3a3a3;
    margin-bottom: 4px;
}

.stat-val {
    font-size: 0.875rem;
    color: #e5e5e5;
    font-weight: 500;
}

/* ==========================================================================
   Salas & Rooms View
   ========================================================================== */
.block-card { 
    border-radius: 16px; 
    border: 1px solid var(--border-color); 
    background-color: var(--bg-card); 
    overflow: hidden; 
    margin-bottom: 24px;
}

.block-header { 
    padding: 20px 24px; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
}

.block-label {
    font-size: 1.125rem;
    font-weight: 600;
    color: #f5f5f5;
}

.block-sublabel {
    font-size: 0.875rem;
    color: #737373;
    margin-top: 4px;
}

.table-wrapper { 
    overflow-x: auto; 
}

.data-table { 
    width: 100%; 
    border-collapse: collapse; 
}

.data-table th { 
    text-align: left; 
    padding: 16px 24px; 
    font-size: 0.75rem; 
    text-transform: uppercase;
    color: #737373; 
    border-bottom: 1px solid var(--border-color); 
    background-color: rgba(0,0,0,0.2);
}

.data-table td { 
    padding: 16px 24px; 
    border-bottom: 1px solid var(--border-color); 
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: rgba(255,255,255,0.02);
}

.badge { 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    padding: 4px 10px; 
    border-radius: 6px; 
    font-size: 0.75rem; 
    font-weight: 500;
}

.badge-dot { 
    width: 6px; 
    height: 6px; 
    border-radius: 50%; 
}

.badge-success { 
    background: rgba(16, 185, 129, 0.1); 
    color: #10b981; 
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-success .badge-dot { 
    background: #10b981; 
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1); 
    color: #ef4444; 
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-danger .badge-dot {
    background: #ef4444; 
}

.badge-neutral {
    background: #111;
    color: #a3a3a3;
    border: 1px solid var(--border-color);
}

/* Rooms View Iframe */
.view-card { 
    border-radius: 16px; 
    border: 1px solid var(--border-color); 
    background-color: var(--bg-card); 
    overflow: hidden; 
}

.view-toolbar {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.game-aspect { 
    aspect-ratio: 16/9; 
    width: 100%; 
    min-height: 70vh; 
    background: #000;
}

.game-iframe { 
    width: 100%; 
    height: 100%; 
    border: none; 
}

.tag { 
    display: inline-flex; 
    padding: 4px 10px; 
    border-radius: 6px; 
    border: 1px solid var(--border-color); 
    background: #111; 
    font-size: 0.75rem; 
    color: #d4d4d4;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #111;
    border: 1px solid var(--border-color);
    color: #a3a3a3;
    transition: 0.2s;
    cursor: pointer;
    text-decoration: none;
}

.btn-icon:hover {
    color: #fff;
    border-color: #525252;
}

/* ==========================================================================
   Helpers e Utilitários
   ========================================================================== */
.blur-sm { filter: blur(4px); }
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-muted { color: #a3a3a3; }
.title-xl { font-size: 1.5rem; font-weight: 600; color: #fff; margin: 0 0 8px 0; }

/* ==========================================================================
   Otimizações para Paisagem (Landscape) em Telas Pequenas
   ========================================================================== */
@media (max-width: 1023px) and (orientation: landscape) {
    .container {
        padding: 24px 16px;
    }
    
    .card {
        padding: 16px;
    }
    
    .card-balance {
        padding: 16px;
    }
    
    .balance-value {
        font-size: 2rem;
        margin-top: 12px;
    }

    /* Encurta drasticamente os cards de Monitoramento */
    .bar-group { margin-bottom: 10px; }
    .bar-info { margin-bottom: 4px; }
    .load-container { margin-top: 12px; padding-top: 12px; }
    .stats-grid { margin-top: 12px; padding-top: 12px; gap: 12px; }

    /* Evita que o Iframe do Aviator fique gigante demais verticalmente */
    .game-aspect {
        min-height: calc(100vh - var(--mobile-header-h) - 40px); 
    }
}