/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Estilo Geral */
body {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    background: #f5f7fa; /* Light theme default */
    color: #2c3e50;
    overflow-x: hidden;
    animation: fadeInBody 0.8s ease-in-out;
}

/* Tema Escuro */
body.dark {
    background: #1e1e1e;
    color: #e0e0e0;
}

/* Animações */
@keyframes fadeInBody {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes slideIn {
    from { transform: translate(-50%, -60%); opacity: 0; }
    to { transform: translate(-50%, -50%); opacity: 1; }
}

/* Index.php - GIF de Carregamento */
.gif-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    animation: fadeInBody 0.5s ease-in-out;
}

.gif-container img {
    max-width: 300px;
    border-radius: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    animation: pulse 2s infinite ease-in-out;
}

@media (max-width: 768px) {
    .gif-container img {
        max-width: 200px;
    }
}

/* Painel.php - Container Principal */
.container {
    max-width: 1100px;
    margin: 20px auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

body.dark .container {
    background: #2c2c2c;
}

/* Dashboard */
.dashboard {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.dark .dashboard {
    background: #2c2c2c;
}

.dashboard h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #2c3e50;
}

body.dark .dashboard h2 {
    color: #e0e0e0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat {
    background: #f1f3f5;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

body.dark .stat {
    background: #3a3a3a;
}

.stat:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.stat span {
    color: #2ecc71;
    font-weight: bold;
}

/* Seções (Tema, Título, Cor, Tempo, GIF, Intervalo) */
.tema-section, .titulo-section, .cor-section, .tempo-section, .gif-section, .interval-section, .actions-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.dark .tema-section, body.dark .titulo-section, body.dark .cor-section, 
body.dark .tempo-section, body.dark .gif-section, body.dark .interval-section, 
body.dark .actions-section {
    background: #2c2c2c;
}

.tema-section h2, .titulo-section h2, .cor-section h2, .tempo-section h2, 
.gif-section h2, .interval-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #2c3e50;
}

body.dark .tema-section h2, body.dark .titulo-section h2, body.dark .cor-section h2, 
body.dark .tempo-section h2, body.dark .gif-section h2, body.dark .interval-section h2 {
    color: #e0e0e0;
}

.tema-section select, .titulo-section input, .cor-section input, .tempo-section input, 
.gif-section select, .gif-section input[type="file"], .interval-section input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

body.dark .tema-section select, body.dark .titulo-section input, body.dark .cor-section input, 
body.dark .tempo-section input, body.dark .gif-section select, body.dark .gif-section input[type="file"], 
body.dark .interval-section input {
    border-color: #555;
    background: #3a3a3a;
    color: #e0e0e0;
}

.tema-section select:focus, .titulo-section input:focus, .cor-section input:focus, 
.tempo-section input:focus, .gif-section select:focus, .gif-section input[type="file"]:focus, 
.interval-section input:focus {
    border-color: #2ecc71;
    outline: none;
}

.gif-section button, .tema-section button, .titulo-section button, .cor-section button, 
.tempo-section button, .interval-section button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gif-section button:hover, .tema-section button:hover, .titulo-section button:hover, 
.cor-section button:hover, .tempo-section button:hover, .interval-section button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.save-feedback {
    display: none;
    margin-left: 10px;
    color: #2ecc71;
    font-size: 14px;
    font-style: italic;
    transition: opacity 0.3s ease;
}

/* Tabela de Grupos */
table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

body.dark table {
    background: #2c2c2c;
}

th, td {
    padding: 15px;
    text-align: left;
    font-size: 14px;
}

th {
    background: #ecf0f1;
    color: #2c3e50;
    font-weight: 600;
}

body.dark th {
    background: #3a3a3a;
    color: #e0e0e0;
}

tr {
    transition: background 0.3s ease;
}

tr:hover {
    background: #f9fbfc;
}

body.dark tr:hover {
    background: #3a3a3a;
}

.btn {
    padding: 8px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.btn-edit {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #fff;
}

.btn-delete {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Botão de Adicionar */
.add-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border-radius: 50%;
    border: none;
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin: 20px auto;
}

.add-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Popups */
.popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff; /* Fundo claro, independente do tema */
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

body.dark .popup {
    background: #f0f0f0; /* Fundo mais claro no tema escuro pra melhor contraste */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.popup::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Backdrop escurecido */
    z-index: -1;
}

.popup h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #2c3e50;
}

body.dark .popup h2 {
    color: #333; /* Cor escura pro texto pra contraste no fundo claro */
}

.popup input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

body.dark .popup input {
    border-color: #aaa;
    background: #ffffff;
    color: #333;
}

.popup input:focus {
    border-color: #2ecc71;
    outline: none;
}

.popup button {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.popup button:not(.cancel) {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
}

.popup button.cancel {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
}

.popup button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Ações (Reset e Export) */
.actions-section {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.actions-section button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.actions-section button:first-child {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #fff;
}

.actions-section button:last-child {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #fff;
}

.actions-section button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Gráfico */
canvas#visitasChart {
    max-width: 100%;
    margin-top: 20px;
}

/* Responsividade */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .dashboard h2, .tema-section h2, .titulo-section h2, .cor-section h2, 
    .tempo-section h2, .gif-section h2, .interval-section h2 {
        font-size: 18px;
    }

    .stat {
        font-size: 14px;
    }

    .add-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    table {
        font-size: 13px;
    }

    th, td {
        padding: 10px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .stats {
        grid-template-columns: 1fr;
    }

    th, td {
        display: block;
        width: 100%;
        text-align: center;
    }

    tr {
        margin-bottom: 10px;
        padding: 10px 0;
        border-bottom: 1px solid #ddd;
    }

    body.dark tr {
        border-bottom: 1px solid #aaa;
    }

    .btn {
        display: inline-block;
        margin: 5px auto;
    }
}