/* ===================================================================
   Estilos do Jogo Principal - TAP Game (Versão Final e Otimizada)
   =================================================================== */

/* ---- 1. Variáveis e Estilos Globais ---- */
:root {
    --bg-color: #343a40;
    --flash-color: #495057;
    --primary-color: #8A2BE2;
    --text-color: #FFFFFF;
    --label-color: #adb5bd;
    --dark-hr: #212529;
    --warning-color: #ffc107;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.1s ease;
    touch-action: manipulation; 
}

/* ---- 2. Layout Principal da Página ---- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    font-size: 0.9em;
    font-weight: bold;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-logo {
    width: 150px;
    height: auto;
}

.header-nav {
    position: fixed;
    top: 50%; /* AJUSTE: Alterado de 30% para 50% para centralizar */
    transform: translateY(-50%); /* Puxa o elemento para cima pela metade da sua própria altura */
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    z-index: 1001;
}

.nav-icon {
    color: #888;
    font-size: 1.1em;
    text-decoration: none;
    transition: color 0.2s, transform 0.2s;
}

.nav-icon:hover {
    color: var(--text-color);
    transform: scale(1.1);
}

.main-content {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 800px;
}

.user-info {
    padding: 0 20px 20px;
}

.user-info hr {
    border: none;
    height: 2px;
    background-color: var(--dark-hr);
    margin-bottom: 15px;
}

#user-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    min-height: 40px;
    cursor: pointer;
}

#user-display img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-text {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    text-align: left;
}

#auth-link {
    color: var(--text-color);
    font-weight: bold;
    text-decoration: none;
}

/* REGRA UNIFICADA: Link de Sair */
#logout-link {
    font-size: 0.8em;
    color: var(--label-color);
    text-decoration: underline;
    font-weight: normal;
}

#logout-link:hover {
    color: var(--text-color);
}


/* ---- 3. Elementos do Jogo e Animações ---- */
.button-container {
    text-align: center;
    position: relative;
}

#main-button {
    width: 180px;
    height: 180px;
    background-color: var(--primary-color);
    color: var(--text-color);
    font-size: 3em;
    font-weight: bold;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), inset 0 -5px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease-out;
    transform-style: preserve-3d;
    touch-action: manipulation; 
}

#main-button:active {
    transform: scale(0.95);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.4), inset 0 0px 8px rgba(0, 0, 0, 0.5);
}

#main-button:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.4), inset 0 0px 8px rgba(0, 0, 0, 0.5);
}

.pot-container {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.pote-label {
    color: var(--label-color);
    font-size: 1.1em;
    display: none;
}

#pot-value {
    font-size: 1.2em;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.flash-bg {
    background-color: var(--flash-color);
}

.tap-animation-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5em;
    font-weight: bold;
    color: var(--text-color);
    opacity: 0;
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
}

@keyframes float-up {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
    100% { transform: translate(-50%, -250%) scale(1.2); opacity: 0; }
}

/* ---- 4. Estilos Gerais para Modais ---- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background-color: var(--bg-color);
    padding: 20px 30px 30px 30px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--primary-color);
    width: 90%;
    max-width: 650px;
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-content h2 {
    margin-bottom: 10px;
    font-size: 1.8em;
    flex-shrink: 0;
}

.modal-content p {
    margin-bottom: 20px;
    font-size: 1em;
    color: var(--label-color);
    flex-shrink: 0;
}

.scrollable-content {
    text-align: left;
    overflow-y: auto;
    padding-right: 15px;
    margin-top: 15px;
}

.scrollable-content h3 {
    margin-top: 15px;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.scrollable-content p {
    color: var(--text-color);
    line-height: 1.6;
}

.close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--label-color);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: auto;
    margin-top: 0;
}

.close-modal-btn:hover {
    color: var(--text-color);
}

.modal-content > .modal-button.close-modal-btn {
    position: static;
    width: 100%;
    margin-top: 20px;
}

.modal-close-x {
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 10; /* Garante que fique sobre outros elementos do modal */

    /* Reseta completamente os estilos de botão de formulário */
    width: auto;
    height: auto;
    padding: 5px;
    margin: 0;

    /* Aparência e Ação */
    font-family: Arial, sans-serif; /* Fonte mais consistente para o 'X' */
    font-size: 30px;
    font-weight: bold;
    line-height: 1;
    color: var(--label-color);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.modal-close-x:hover {
    color: var(--text-color);
    transform: scale(1.1);
}


/* ---- 5. Estilos Gerais para Formulários nos Modais ---- */
.modal-content input,
.modal-content select {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 5px;
    border: 1px solid #777;
    background-color: #555;
    color: white;
    font-size: 1.1em;
}

.modal-content input::placeholder { color: #aaa; }

.modal-content select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23adb5bd%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 0.65em auto;
    padding-right: 2.5rem;
}

.modal-button,
.modal-content button {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    margin-top: 10px;
}

.modal-button.primary {
    background-color: var(--primary-color);
    color: var(--text-color);
}

.modal-button.whatsapp {
    background-color: #25D366;
    color: white;
}

.modal-button.whatsapp:hover {
    background-color: #1DAA50;
}

#delivery-form,
#second-win-form,
#profile-form { /* Unificado para todos os formulários com scroll */
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 5px 15px 5px 5px;
    margin-right: -15px;
    text-align: left;
}

.form-label-date {
    font-size: 0.8em;
    color: var(--label-color);
    margin: 5px 0 2px 0;
}

#delivery-form input[type="date"] { margin-bottom: 16px; }

.form-link-p {
    margin-top: 15px;
    font-size: 0.9em;
}

.form-link-p a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}

.file-label {
    display: block;
    padding: 10px;
    background-color: #6c757d;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    margin-bottom: 15px;
}

.file-label:hover { background-color: #5a6268; }

.terms-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.terms-container input[type="checkbox"] {
    width: auto;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--primary-color);
}

.terms-container label {
    font-size: 0.9em;
    color: var(--label-color);
}

.terms-container label a {
    color: var(--text-color);
    text-decoration: underline;
    font-weight: bold;
}

.form-hr {
    width: 100%;
    border: none;
    height: 1px;
    background-color: var(--border-color);
    margin: 15px 0;
}


/* ---- 6. Estilos de Modais Específicos ---- */

/* Modal de Vitória */
.fullscreen {
    background-color: rgba(15, 15, 15, 0.95);
    flex-direction: column;
}

.win-content { text-align: center; }

.win-title {
    font-size: 8vw;
    color: var(--primary-color);
    text-transform: uppercase;
    text-shadow: 0 0 15px var(--primary-color);
}

.win-amount-text {
    font-size: 5vw;
    color: var(--text-color);
    margin: -50px 0 5px 0;
}

.win-amount-text-extra {
    font-size: 3vw;
    font-weight: bold;
    color: var(--text-color);
    margin: 0 0 40px 0;
}

.close-win-link {
    margin-top: 40px;
    font-size: 1.2em;
    color: var(--text-color);
    text-decoration: none;
    border: 1px solid var(--text-color);
    padding: 10px 20px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}

.close-win-link:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Overlay de Carregamento */
.loading-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(52, 58, 64, 0.9);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    border-radius: 10px;
}

.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 40px; height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ---- 7. Modal de Perfil ---- */

.modal-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    object-fit: cover;
}

.profile-avatar-label {
    position: relative;
    display: block;
    cursor: pointer;
    margin-bottom: 15px;
    flex-shrink: 0;
    width: 80px; /* Alinhado ao tamanho do avatar */
    margin-left: auto;
    margin-right: auto;
}

.profile-avatar-label span {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.7em;
    padding: 4px 0;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
    opacity: 0;
    transition: opacity 0.3s;
}

.profile-avatar-label:hover span { opacity: 1; }

.profile-code-display {
    width: 100%;
    padding: 10px;
    background-color: var(--dark-hr);
    border-radius: 5px;
    margin: 0 0 15px 0;
    font-family: monospace;
    font-size: 1.1em;
    word-wrap: break-word;
    flex-shrink: 0;
}

.profile-code-display strong { color: var(--text-color); }

.profile-nav {
    width: 100%;
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    flex-shrink: 0;
    overflow-x: auto;
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.profile-nav::-webkit-scrollbar { display: none; } /* Chrome, Safari */

.nav-tab {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--label-color);
    border-bottom: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap; /* Impede quebra de linha */
}

.nav-tab.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

.tab-content {
    width: 100%;
    display: none;
    flex-grow: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.active { display: flex; }

.profile-stats-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
    flex-shrink: 0;
}

.stat-box {
    background-color: #000000;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-box i {
    font-size: 2em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.stat-box h3 {
    margin-top: 0;
    font-size: 0.7em;
    color: var(--label-color);
    font-weight: normal;
    text-transform: uppercase;
}

.stat-box p {
    font-size: 1.3em;
    font-weight: bold;
    margin: 5px 0 0 0;
    color: var(--text-color);
}

#prizes-list,
#transfer-history-list {
    overflow-y: auto;
    flex-grow: 1;
    text-align: left;
    width: 100%;
}

.prize-item, .transfer-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.prize-item:last-child, .transfer-item:last-child { border-bottom: none; }

.prize-item p { margin: 0; }

.prize-admin-note {
    color: var(--warning-color) !important;
    font-size: 0.9em;
    margin-top: 5px !important;
    padding-left: 10px;
}

.prize-admin-note strong { color: var(--warning-color); }

.transfer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
}

.transfer-details { flex-grow: 1; }
.transfer-details small { color: var(--label-color); display: block; }

.transfer-amount { font-weight: bold; min-width: 100px; text-align: right; }
.transfer-amount.sent { color: #ff6b6b; }
.transfer-amount.received { color: #51cf66; }

#transfer-button.sending { animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.02); } }


/* ---- 8. Outros Componentes ---- */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: var(--primary-color);
    color: var(--text-color);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    font-size: 1.1em;
    font-weight: bold;
    transform: translateX(120%);
    transition: transform 0.5s ease-in-out;
}

.toast-notification.show { transform: translateX(0); }

#invite-modal textarea {
    background-color: var(--dark-hr);
    border-color: var(--label-color);
    resize: none;
    text-align: center;
    padding: 15px;
    font-size: 1em;
    color: var(--text-color);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    width: 100%;
}

.modal-actions .modal-button {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.ranking-list {
    width: 100%;
    margin-top: 20px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 10px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 10px 5px;
    border-bottom: 1px solid var(--dark-hr);
}
.ranking-item:last-child { border-bottom: none; }

.ranking-position {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--label-color);
    width: 50px;
    flex-shrink: 0;
}

.ranking-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;
    border: 2px solid var(--primary-color);
}

.ranking-name { font-weight: 500; }
.ranking-points { font-size: 1.1em; font-weight: bold; margin-left: auto; }

/* ---- Lógica de Visibilidade (Pré e Pós-Login) ---- */
/* Por padrão, esconde os elementos que só devem aparecer para usuários logados */
.header-logo,
#balance-top,
.pot-container,
.user-info {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

/* Classe auxiliar para mostrar os elementos com uma transição suave */
.logged-in-visible {
    display: flex; /* ou 'block' dependendo do elemento */
    opacity: 1;
}