/* Reset básico - Remove margens, paddings e define box-sizing para todos os elementos */
/* Isso garante consistência no layout, evitando comportamentos padrão do navegador */
* {
    margin: 0;
    /* Remove margem externa de todos os elementos */
    padding: 0;
    /* Remove preenchimento interno de todos os elementos */
    box-sizing: border-box;
    /* Inclui padding e border no cálculo da largura/altura total */
}

/* Variáveis CSS para os cores dos temas */
:root[data-theme="dark"] {
    --bg-color: #000;
    /* Cor de fundo para modo escuro */
    --text-color: #fff;
    /* Cor do texto para modo escuro */
    --border-color: #ffffff;
    /* Cor da borda para modo escuro */
    --button-bg: rgba(0, 0, 0, 0.7);
    /* Cor de fundo do botão para modo escuro */
}

:root[data-theme="light"] {
    --bg-color: #f5f5f5;
    /* Cor de fundo para modo claro */
    --text-color: #000;
    /* Cor do texto para modo claro */
    --border-color: #000;
    /* Cor da borda para modo claro */
    --button-bg: rgba(255, 255, 255, 0.9);
    /* Cor de fundo do botão para modo claro */
}

/* Define variáveis padrão (dark mode) */
:root {
    --bg-color: #000;
    --text-color: #fff;
    --border-color: #ffffff;
    --button-bg: rgba(0, 0, 0, 0.7);
}

/* Estilos para o elemento html - Base da página */
html {
    width: 100%;
    /* Largura total */
    height: 100%;
    /* Altura total */
    overflow-x: hidden;
    /* Evita scroll horizontal em mobile */
}

/* Estilos para o corpo da página - Define aparência geral da página */
body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    /* Define a família de fontes */
    background-color: var(--bg-color);
    /* Cor de fundo usando variável CSS */
    width: 100%;
    /* Largura total da viewport */
    height: 100vh;
    /* Altura total da viewport */
    color: var(--text-color);
    /* Cor do texto usa variável CSS */
    min-height: 100vh;
    /* Altura mínima de 100% da viewport para ocupar toda a tela */
    display: flex;
    /* Usa flexbox para layout */
    flex-direction: column;
    /* Direção vertical dos filhos */
    align-items: center;
    /* Centraliza horizontalmente os filhos */
    justify-content: center;
    /* Centraliza verticalmente os filhos */
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Transição suave ao mudar tema */
}

/* Classe para elementos invisíveis para leitores de tela - Acessibilidade */
/* Esconde visualmente o elemento, mas mantém acessível para tecnologias assistivas */
.sr-only {
    position: absolute;
    /* Remove do fluxo normal e posiciona absolutamente */
    width: 1px;
    /* Largura mínima */
    height: 1px;
    /* Altura mínima */
    padding: 0;
    /* Sem preenchimento */
    margin: -1px;
    /* Margem negativa para esconder */
    overflow: hidden;
    /* Esconde conteúdo que ultrapassa */
    clip: rect(0, 0, 0, 0);
    /* Corta o elemento */
    white-space: nowrap;
    /* Evita quebra de linha */
    border: 0;
    /* Remove borda */
}

/* Estilos para o cabeçalho - Centraliza o título principal */
header {
    text-align: center;
    /* Alinha o texto ao centro */
    margin-bottom: 2rem;
    /* Espaço inferior de 2 rem */
    display: flex;
    /* Usa flexbox */
    justify-content: center;
    /* Centraliza horizontalmente */
    align-items: center;
    /* Alinha verticalmente */
    position: relative;
    /* Posicionamento relativo */
}

/* Estilos para o h1 dentro do header - Título principal */
header h1 {
    font-size: 3rem;
    /* Tamanho da fonte grande */
    font-weight: 400;
    /* Peso da fonte normal */
    color: var(--text-color);
    /* Cor usa variável CSS */
}

/* Estilos para o main - Conteúdo principal da página */
main {
    width: 100%;
    /* Largura total */
    max-width: 1200px;
    /* Largura máxima para telas grandes */
    padding: 0 2rem;
    /* Preenchimento lateral */
}

/* Estilos para o container de perfis - Layout flexível */
.profiles {
    display: flex;
    /* Usa flexbox */
    justify-content: center;
    /* Centraliza os itens horizontalmente */
    gap: 1.5rem;
    /* Espaço entre itens - reduzido para 4 perfis */
    flex-wrap: wrap;
    /* Permite quebra de linha em telas pequenas */
    list-style: none;
    /* Remove os pontos da lista não ordenada */
}

/* Estilos para cada perfil - Aparência e interatividade */
.profile {
    cursor: pointer;
    /* Cursor de mão para indicar clicável */
    text-align: center;
    /* Alinha texto ao centro */
    transition: transform 0.3s ease;
    /* Transição suave para transformações */
}

/* Estilos para o link dentro do perfil */
.profile a {
    text-decoration: none;
    /* Remove o underline padrão do link */
    color: inherit;
    /* Herda a cor do texto */
    display: block;
    /* Faz o link ocupar todo o espaço do item */
}

/* Estilos para perfil no hover - Efeito de escala */
.profile:hover {
    transform: scale(1.05);
    /* Aumenta ligeiramente o tamanho */
}

/* Estilos para a figure dentro do perfil - Container da imagem e legenda */
.profile figure {
    margin: 0;
    /* Remove margem padrão */
}

/* Estilos para a imagem do perfil - Aparência circular */
.profile img {
    width: 140px;
    /* Largura fixa - reduzida para 4 perfis */
    height: 140px;
    /* Altura fixa - reduzida para 4 perfis */
    border-radius: 50%;
    /* Forma circular */
    object-fit: cover;
    /* Ajusta a imagem sem distorcer */
    border: 3px solid transparent;
    /* Borda transparente inicial */
    transition: border-color 0.3s ease;
    /* Transição para cor da borda */
}

/* Estilos para imagem no hover - Borda branca */
.profile:hover img {
    border-color: var(--border-color);
    /* Borda usa variável CSS no hover */
}

/* Estilos para a legenda da imagem - Texto abaixo da imagem */
.profile figcaption {
    margin-top: 1rem;
    /* Espaço superior */
    font-size: 1.2rem;
    /* Tamanho da fonte */
    font-weight: 300;
    /* Peso leve */
    color: var(--text-color);
    /* Cor usa variável CSS */
}

/* Estilos para o botão de toggle tema - Alterna entre dark e light mode */
.theme-toggle {
    position: fixed;
    /* Posicionamento fixo na tela */
    right: 2rem;
    /* Distância do lado direito */
    top: 2rem;
    /* Distância do topo */
    z-index: 1000;
    /* Aparece acima de todo conteúdo */
    background-color: var(--button-bg);
    /* Fundo usa variável CSS */
    border: 2px solid var(--border-color);
    /* Borda usa variável CSS */
    color: var(--text-color);
    /* Cor usa variável CSS */
    font-size: 1.5rem;
    /* Tamanho da fonte */
    padding: 0.5rem 0.8rem;
    /* Preenchimento interno */
    border-radius: 50%;
    /* Forma circular */
    cursor: pointer;
    /* Cursor de mão */
    transition: all 0.3s ease;
    /* Transição suave */
}

/* Estilos para o botão no hover */
.theme-toggle:hover {
    transform: scale(1.1);
    /* Aumenta ligeiramente o tamanho */
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    /* Adiciona sombra */
}

/* Estilos para o ícone do tema */
.theme-icon {
    display: inline-block;
    /* Exibe como bloco inline */
    transition: transform 0.3s ease;
    /* Transição suave */
}

.theme-toggle:hover .theme-icon {
    transform: rotate(20deg);
    /* Rotaciona o ícone no hover */
}

/* Responsividade - Ajustes para telas menores */

/* ========== MOBILE PEQUENO (até 480px) ========== */
@media (max-width: 480px) {
    body {
        padding: 0 1rem;
        justify-content: flex-start;
        padding-top: 1rem;
    }

    main {
        padding: 0 1rem;
        max-width: 100%;
    }

    header {
        margin-bottom: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
        font-weight: 300;
    }

    .theme-toggle {
        position: absolute;
        right: 1rem;
        top: 1rem;
        font-size: 1rem;
        padding: 0.4rem 0.6rem;
    }

    .profiles {
        gap: 1rem;
        justify-content: center;
    }

    .profile {
        flex: 0 1 calc(50% - 0.5rem);
    }

    .profile img {
        width: 100px;
        height: 100px;
    }

    .profile figcaption {
        font-size: 0.9rem;
        margin-top: 0.8rem;
    }
}

/* ========== TABLET (481px até 768px) ========== */
@media (min-width: 481px) and (max-width: 768px) {
    body {
        padding: 1rem;
    }

    main {
        padding: 0 1.5rem;
        max-width: 100%;
    }

    header {
        margin-bottom: 1.5rem;
        justify-content: space-between;
    }

    header h1 {
        font-size: 2rem;
    }

    .theme-toggle {
        right: 1.5rem;
        top: 1.5rem;
        font-size: 1.2rem;
        padding: 0.4rem 0.6rem;
    }

    .profiles {
        gap: 1.5rem;
        justify-content: center;
    }

    .profile {
        flex: 0 1 auto;
    }

    .profile img {
        width: 120px;
        height: 120px;
    }

    .profile figcaption {
        font-size: 1.05rem;
        margin-top: 1rem;
    }
}

/* ========== DESKTOP PEQUENO (769px até 1024px) ========== */
@media (min-width: 769px) and (max-width: 1024px) {
    header h1 {
        font-size: 2.5rem;
    }

    .theme-toggle {
        right: 2rem;
        top: 2rem;
        font-size: 1.3rem;
    }

    .profiles {
        gap: 1.5rem;
    }

    .profile img {
        width: 130px;
        height: 130px;
    }

    .profile figcaption {
        font-size: 1.1rem;
    }
}

/* ========== DESKTOP GRANDE (acima de 1025px) ========== */
@media (min-width: 1025px) {
    header h1 {
        font-size: 3rem;
    }

    .profile img {
        width: 140px;
        height: 140px;
    }

    .profile figcaption {
        font-size: 1.2rem;
    }
}

/* Garantir que imagens sempre se adaptam */
img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ========== SISTEMA DE PERFIS DINÂMICOS ========== */

/* Estilos para perfil dinâmico em li */
.profiles li {
    list-style: none;
}

.profiles li.profile-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.profiles li.profile-item:hover {
    transform: scale(1.1);
}

.profiles li.profile-item:hover img {
    border-color: #e50914;
    box-shadow: 0 0 15px rgba(229, 9, 20, 0.4);
}

.profiles li.profile-item img {
    border: 3px solid transparent;
    border-radius: 8px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.profile-item .delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ff6b6b;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.3s ease;
}

.profiles.edit-mode .profile-item .delete-btn {
    display: flex;
    opacity: 1;
}

.profile-item .delete-btn:hover {
    background: #c40812;
    transform: scale(1.1);
}

.profile-item {
    position: relative;
}

/* Botões de ação */
.action-buttons,
.edit-mode-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.edit-mode-buttons {
    display: none;
}

.btn-manage,
.btn-cancel,
.btn-delete-all,
.btn-save,
.btn-add-profile,
.close-modal {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-manage,
.btn-add-profile,
.btn-save {
    background-color: #e50914;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-manage:hover,
.btn-add-profile:hover,
.btn-save:hover {
    background-color: #c40812;
    transform: translateY(-2px);
}

.btn-cancel {
    background-color: transparent;
    color: var(--text-color);
    border: 2px solid var(--text-color);
}

.btn-cancel:hover {
    background-color: var(--bg-color);
}

.btn-delete-all {
    background-color: #ff6b6b;
    color: white;
}

.btn-delete-all:hover {
    background-color: #c40812;
}

/* Modal */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    z-index: 1001;
    max-width: 450px;
    width: 90%;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

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

.modal-header h2 {
    font-size: 1.3rem;
    margin: 0;
}

.close-modal {
    background: none;
    color: var(--text-color);
    font-size: 1.8rem;
    padding: 0;
    width: auto;
    height: auto;
}

.close-modal:hover {
    transform: scale(1.2);
}

.modal-body {
    padding: 1.5rem;
}

/* Formulário */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.form-group input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 0.95rem;
    transition: border-color 0.3s ease;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #e50914;
    box-shadow: 0 0 8px rgba(229, 9, 20, 0.3);
}

/* Seletor de avatares */
.avatar-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.75rem;
}

.avatar-option {
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.avatar-option input[type="radio"] {
    display: none;
}

.avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    display: block;
    min-height: 70px;
}

.avatar-option:hover img {
    opacity: 0.9;
}

.avatar-option input[type="radio"]:checked + img {
    opacity: 1;
}

.avatar-option:has(input[type="radio"]:checked) {
    border-color: #e50914;
    box-shadow: 0 0 10px rgba(229, 9, 20, 0.4);
}

/* Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modo edição */
body.edit-mode .profiles li.profile-item:not(.add-profile-item) {
    pointer-events: none;
    opacity: 0.6;
}

body.edit-mode .add-profile-item {
    display: none;
}

/* Mensagem de nenhum perfil */
.no-profiles-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-color);
    opacity: 0.7;
}