/* ========== VARIAVEIS GLOBAIS ========== */
/* Replicas exatas do design original do IF-Info Java */
:root {
    --color-green: #2ecc71;
    --color-yellow: #f1c40f;
    --color-blue: #3498db;
    --color-bg: #f5f6fa;
    --color-text: #2c3e50;
    --color-white: #ffffff;
    --spacing-md: 1rem;
    --border-radius: 8px;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

    /* ========== VIEWPORT SEGURO ==========
     * Barra de tarefas do Windows: ~40px (padrao)
     * Margem de seguranca dobrada:  80px (garante visibilidade total)
     * 100dvh = dynamic viewport height (exclui barra do browser automaticamente)
     * Subtraimos 80px adicionais para nunca cortar conteudo sob a taskbar.
     */
    --taskbar-win: 40px;
    --safe-offset: calc(var(--taskbar-win) * 2);   /* 80px */
    --vh-seguro: calc(100dvh - var(--safe-offset));  /* altura util garantida */
}

/* ========== RESET ========== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* Remove highlight azul feio do mobile */
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
    overscroll-behavior-y: none;
    /* Evitar pull-to-refresh acidental do Chrome/Safari  */
}

/* ========== CONTAINER ========== */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--spacing-md);
    /* padding-bottom garante que o conteudo nao fique escondido
       atras da bottom-nav fixa (60px) + offset da taskbar do Windows (80px) */
    padding-bottom: calc(60px + var(--safe-offset));
}

/* ========== BOTOES ========== */
button,
.btn,
.btn-back {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border: none;
    border-radius: var(--border-radius);
    padding: 10px 20px;
    font-size: 1rem;
    font-family: inherit;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.2s;
    -webkit-user-select: none;
    user-select: none;
    /* Impedir copia de texto em cliques longos */
}

.btn-primary {
    background-color: var(--color-blue);
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}



/* Botao neutro (Voltar/Admin) */
.btn-default,
.btn-back {
    background-color: #ecf0f1;
    color: var(--color-text);
    border: 1px solid #bdc3c7;
}

.btn-default:hover,
.btn-back:hover {
    background-color: #bdc3c7;
}

/* Botao de perigo */
.btn-danger {
    background-color: #fae5e5;
    color: #c0392b;
    border: 1px solid #e74c3c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Modificador para fixar o botão na base da tela */
.btn-fixed-bottom {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 40px);
    max-width: 560px;
    /* Alinhado ao max-width do container - padding */
    box-shadow: var(--shadow);
}

/* Container para fixar múltiplos botões lado a lado na base */
.fixed-bottom-actions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 40px);
    max-width: 560px;
    display: flex;
    gap: 10px;
}

.fixed-bottom-actions .btn,
.fixed-bottom-actions button {
    flex: 1;
    box-shadow: var(--shadow);
    width: 100%;
}


/* ========== HEADER PADRAO ========== */
.admin-header-img {
    background: white;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
}

.admin-header-img img {
    width: auto;
    max-width: 100%;
    max-height: 80px;
    object-fit: contain;
    display: block;
}

header div {
    display: flex;
    align-items: center;
    gap: 10px;
    -webkit-user-select: none;
    user-select: none;
}

/* ========== BARRA DE NAVEGACAO INFERIOR ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    /* Centraliza a barra horizontalmente e limita ao max-width do container */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;   /* Mesmo max-width do .container e do banner */
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    /* Arredondamento no topo para destacar o limite da barra */
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: center !important;
    align-items: center;
    gap: 15px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    /* Notch iOS/Android support */
    z-index: 2000 !important;
    -webkit-user-select: none;
    user-select: none;
}

/* Esconder bottom nav quando card esta expandido */
body.card-expanded .bottom-nav {
    display: none !important;
}

/* ========== FORMULARIOS ========== */
.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

input,
textarea,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    font-family: inherit;
}

.help-text {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
}

/* ========== ALERTAS ========== */
.alerta {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alerta-erro {
    background: #fee2e2;
    color: #c0392b;
    border: 1px solid #fecaca;
}

.alerta-sucesso,
.alerta-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* ========== RESPONSIVO MOBILE ========== */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .form-group {
        margin-bottom: 1.5rem;
    }
}

/* ========== DARK MODE ========== */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #1a1a2e;
        --color-text: #e0e0e0;
        --color-white: #16213e;
    }

    body {
        background-color: var(--color-bg);
        color: var(--color-text);
    }

    .container,
    .container-wide {
        color: var(--color-text);
    }

    .admin-header-img {
        background: #16213e;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    }

    input,
    textarea,
    select {
        background: #0f3460;
        border-color: #1a1a4e;
        color: #e0e0e0;
    }

    .btn-default,
    .btn-back {
        background-color: #16213e;
        color: #e0e0e0;
        border-color: #1a1a4e;
    }

    .alerta-sucesso {
        background: #1b4332;
        color: #95d5b2;
        border-color: #2d6a4f;
    }

    .alerta-erro {
        background: #3d0000;
        color: #ff6b6b;
        border-color: #6b0000;
    }

    .aviso-card,
    .admin-btn,
    .secao,
    .tabela {
        background: #16213e;
        color: #e0e0e0;
    }

    .tabela th {
        background: #0f3460;
    }

    .bottom-nav {
        background: #16213e;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    }
}