@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    /* Paleta Base - Fintech / Modern App */
    --bg-dark: #1A1C22;
    --bg-light: #F4F5F9;
    --card-bg: #FFFFFF;
    
    /* Textos */
    --text-main: #1D1E25;
    --text-muted: #848A9C;
    
    /* Cores de Destaque */
    --accent-color: #27D18A;
    --accent-gradient: linear-gradient(135deg, #4DE7A8 0%, #10D29E 100%);
    --accent-hover: linear-gradient(135deg, #3BCF93 0%, #0CA87D 100%);
    --danger: #FF5A5F;
    --warning: #FFB020;
    
    /* Formatos e Sombras */
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 12px;
    --shadow-card: 0 8px 24px rgba(149, 157, 165, 0.1);
    --shadow-btn: 0 8px 20px rgba(39, 209, 138, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
    -webkit-tap-highlight-color: transparent; /* Remove o flash azul ao clicar no celular */
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* Scrollbar Customizada (Estilo App) */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* -----------------------------------
   1. CABEÇALHOS E GRID
------------------------------------ */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

h1, h2, h3 { font-weight: 600; color: var(--text-main); }
header h1 { font-size: 1.8rem; color: var(--bg-dark); letter-spacing: -0.5px; }

.grid {
    display: grid;
    gap: 24px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-card);
    border: none;
    margin-bottom: 24px;
}

/* -----------------------------------
   2. BOTÕES PREMIUM
------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: all 0.3s ease;
    gap: 8px;
    text-align: center;
}

.btn-primary, .btn-accent {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-btn);
}

.btn-primary:hover, .btn-accent:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(39, 209, 138, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid #E5E7EB;
    color: var(--text-main);
    box-shadow: none;
}

.btn-outline:hover {
    border-color: var(--bg-dark);
    color: var(--bg-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 8px 20px rgba(255, 90, 95, 0.3);
}

.btn-small { padding: 8px 18px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* -----------------------------------
   3. BADGES (Tags)
------------------------------------ */
.badge {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: inline-block;
}
.bg-blue { background: rgba(39, 209, 138, 0.1); color: var(--accent-color); }
.bg-green { background: rgba(39, 209, 138, 0.15); color: #0CA87D; }
.bg-danger { background: rgba(255, 90, 95, 0.1); color: var(--danger); }
.bg-gray { background: #F3F4F6; color: var(--text-muted); }

/* -----------------------------------
   4. FORMULÁRIOS
------------------------------------ */
.form-group { margin-bottom: 20px; }
label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 8px; color: var(--text-muted); }
input, select, textarea {
    width: 100%;
    padding: 15px 20px;
    background-color: #F8F9FB;
    border: 1px solid #E5E7EB;
    border-radius: var(--border-radius-md);
    font-size: 1rem; /* Mínimo de 16px (1rem) evita zoom no iPhone */
    color: var(--text-main);
    transition: all 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: #FFFFFF;
    box-shadow: 0 0 0 4px rgba(39, 209, 138, 0.1);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* -----------------------------------
   5. TABELAS (View Desktop)
------------------------------------ */
.table-wrapper { background: transparent; border: none; overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0 16px; }
th { background: transparent; text-align: left; padding: 0 24px 8px 24px; font-size: 0.85rem; text-transform: capitalize; color: var(--text-muted); font-weight: 500; border: none; }
td { background: var(--card-bg); padding: 20px 24px; font-size: 0.95rem; vertical-align: middle; border: none; }
tr td:first-child { border-top-left-radius: var(--border-radius-md); border-bottom-left-radius: var(--border-radius-md); }
tr td:last-child { border-top-right-radius: var(--border-radius-md); border-bottom-right-radius: var(--border-radius-md); }
tr { box-shadow: 0 4px 15px rgba(0,0,0,0.02); transition: transform 0.2s, box-shadow 0.2s; }
tr:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }

/* -----------------------------------
   6. TELA DE LOGIN/AUTH
------------------------------------ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    padding: 20px;
}
.auth-card {
    background: var(--card-bg);
    padding: 45px 40px;
    border-radius: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}
.auth-card h2 { color: var(--bg-dark); font-size: 1.8rem; margin-bottom: 30px; }
.auth-card p a { color: var(--accent-color); text-decoration: none; font-weight: 500; }

/* =========================================================================
   📱 MODO RESPONSIVO TOTAL (SMARTPHONES E TABLETS)
========================================================================= */

/* Tablets (iPad, etc) */
@media (max-width: 992px) {
    /* Força o grid do PHP (que estava inline) a virar coluna única */
    .grid[style] {
        grid-template-columns: 1fr !important;
    }
}

/* Smartphones (iPhone, Android) */
@media (max-width: 768px) {
    .container { padding: 15px 15px 30px 15px; }
    
    /* Header Empilhado */
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        border-bottom: none;
        padding-bottom: 10px;
    }
    
    header div {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        width: 100%;
    }
    
    header div a {
        flex: 1; /* Faz os botões do topo ocuparem o espaço todo */
        min-width: 45%;
        padding: 12px;
    }

    /* Cards Internos */
    .card { padding: 20px 15px; }

    /* Magia da Tabela: Transforma linhas (TR) em Cartões App */
    table, thead, tbody, th, td, tr { display: block; }
    
    /* Esconde o topo da tabela visualmente, mas mantém acessível */
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    
    tr {
        background: var(--card-bg);
        border-radius: var(--border-radius-lg);
        margin-bottom: 20px;
        padding: 20px;
        box-shadow: var(--shadow-card);
    }
    
    td {
        padding: 8px 0;
        text-align: left;
        border: none;
        border-bottom: 1px solid rgba(0,0,0,0.04);
        position: relative;
    }
    
    td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        padding-top: 15px;
        display: flex;
        justify-content: center;
    }

    /* Remove os arredondamentos antigos da tabela desktop */
    tr td:first-child, tr td:last-child { border-radius: 0; }

    /* Faz o botão da tabela ficar de lado a lado na tela */
    td a.btn, td button.btn { width: 100%; }

    /* Formulários de Sincronização e IA */
    .form-row { grid-template-columns: 1fr; gap: 0; }
    
    /* Auth Ajustes */
    .auth-card {
        padding: 35px 25px;
        border-radius: 24px;
    }
}