/* ── Base ──────────────────────────────────────────────────────────────────── */
body {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%) !important;
    background-color: #0f0f1a !important;
    color: white !important;
    font-family: 'Inter', 'Roboto', -apple-system, sans-serif;
    min-height: 100vh;
}

html {
    background-color: #0f0f1a !important;
}

.fundo-azul-claro {
    background-color: rgba(255,255,255,0.06);
    transition: background-color 0.3s ease;
}

.ocultar-conteudo {
    display: none;
}

/* ── Botão de app (navegação gerência/cidade/distrito) ─────────────────────── */
.btn-app {
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 12px 16px;
    margin: 6px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    display: inline-block;
}

.btn-app:hover {
    transform: scale(1.04) translateY(-1px);
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

/* ── Menu inferior fixo ────────────────────────────────────────────────────── */
.menu-inferior {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 15, 26, 0.85);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    /* Edge-to-edge: empurra botões acima da barra de gestos Android/iOS */
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    z-index: 100;
}

.menu-inferior button {
    color: rgba(255,255,255,0.75);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.menu-inferior button:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

/* ── Container principal ───────────────────────────────────────────────────── */
.container-app {
    max-width: 520px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* ── Cards de dispositivo (lista de userids) ───────────────────────────────── */
.userid-item {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.userid-item:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.22);
    transform: translateX(2px);
}

/* ── Tabela estilizada ─────────────────────────────────────────────────────── */
.table-app {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.table-app th,
.table-app td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    color: #e2e8f0;
    font-size: 12px;
}

.table-app th {
    background: rgba(30, 58, 95, 0.6);
    color: #93c5fd !important;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.table-app tr:nth-child(even) td {
    background: rgba(255,255,255,0.03);
}

.table-app tr:hover td {
    background: rgba(255,255,255,0.07);
}

.botao-ativo {
    background-color: rgba(251, 146, 60, 0.2);
    border-color: rgba(251, 146, 60, 0.5) !important;
    color: #fb923c;
}

/* ── Modal histórico ───────────────────────────────────────────────────────── */
#janelaHistorico > div {
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 16px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

#conteudoHistorico {
    overflow-y: auto;
    max-height: 70vh;
}

#janelaHistorico button {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 10;
}

#janelaHistorico button:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* ── Toasts ────────────────────────────────────────────────────────────────── */
.success-message,
.error-message,
.info-message {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10050;
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(16px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.45);
    max-width: 92vw;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    animation: _toast-in 0.25s ease-out;
}

@keyframes _toast-in {
    from { opacity:0; transform: translateX(-50%) translateY(-10px); }
    to   { opacity:1; transform: translateX(-50%) translateY(0); }
}

.success-message {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
    color: #34d399;
}
.error-message {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}
.info-message {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.35);
    color: #93c5fd;
}

/* ── Modal de configurações ────────────────────────────────────────────────── */
.config-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.config-container {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    color: white;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.config-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-close-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.config-close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.config-content {
    padding: 16px;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.config-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.config-card h4 {
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #93c5fd;
}

.config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.config-label {
    font-size: 0.87rem;
    color: rgba(255,255,255,0.6);
    margin-right: 8px;
    flex: 1;
    min-width: 160px;
}

.config-input-group {
    display: flex;
    align-items: center;
    min-width: 120px;
}

.config-input {
    width: 80px;
    padding: 7px 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: white;
    text-align: right;
    margin-right: 8px;
    font-size: 13px;
}

.config-input:focus {
    outline: none;
    border-color: rgba(99,102,241,0.6);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
}

.config-unit {
    color: rgba(255,255,255,0.4);
    font-size: 0.85rem;
    min-width: 30px;
}

.config-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.config-btn {
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.config-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.config-btn-save   { background: linear-gradient(135deg, #059669, #34d399); }
.config-btn-reset  { background: linear-gradient(135deg, #d97706, #fbbf24); }
.config-btn-cancel { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); }

/* ── Cards de resultado (layout lado a lado) ───────────────────────────────── */
.resultado-card {
    margin-top: 0;
    background: transparent;
}

.resultado-card > * {
    margin-top: 6px;
}

/* Scrollbar personalizada nos cards de dados */
[style*="overflow-y:auto"]::-webkit-scrollbar,
[style*="overflow-y: auto"]::-webkit-scrollbar {
    width: 4px;
}
[style*="overflow-y:auto"]::-webkit-scrollbar-track,
[style*="overflow-y: auto"]::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.04);
}
[style*="overflow-y:auto"]::-webkit-scrollbar-thumb,
[style*="overflow-y: auto"]::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

/* ── Mensagem legada oculta ─────────────────────────────────────────────────── */
#mensagem { display: none !important; }

/* ── Responsividade ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .config-grid {
        grid-template-columns: 1fr;
    }

    .config-container {
        max-width: 95%;
        max-height: 88vh;
    }

    .config-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .config-input-group {
        width: 100%;
        margin-top: 8px;
    }

    .config-input {
        width: 100%;
    }

    .config-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .config-btn {
        width: 100%;
        justify-content: center;
    }

    .container-app {
        padding: 12px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
}
