/* CSS Final e Completo */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 115px 2rem 2rem 2rem;
    box-sizing: border-box;
}

h1, h2 {
    text-align: center;
    font-weight: 500;
    color: #2c3e50;
}

h2 {
    margin: 0;
    padding: 20px 20px 0 20px;
}

#setup {
    max-width: 900px;
    margin: 0 auto 2rem auto;
    padding: 2rem;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.instructions {
    margin: 2rem 0 0.75rem 0;
    line-height: 1.4;
    color: #333;
    text-align: center;
}

textarea {
    width: 95%;
    height: 200px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1.5;
    margin-top: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#setup .generate-btn-main {
    margin-top: 1.5rem;
    padding: 12px 25px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    background-color: #041A4A;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
#setup .generate-btn-main:hover {
    background-color: #0A2F78;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    background-color: #f0f2f5;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 1rem 2rem;
    box-sizing: border-box; 
}

.header-title-container {
    text-align: center;
    flex-grow: 1;
    position: relative;
}
.header-title-container h1 {
    margin: 0;
    font-size: 1.5rem;
}
#main-tournament-subtitle {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 4px;
}

#title-display-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
#edit-title-icon {
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s ease;
    user-select: none;
}
#edit-title-icon:hover {
    transform: scale(1.2);
}
#title-edit-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
#title-edit-area input {
    font-size: 1rem;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#title-edit-area button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
}

.header-buttons-left, .header-buttons-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: 150px; 
}
.header-buttons-right {
    justify-content: flex-end;
}

/* MUDANÇA: Seletor de grupo agora só para os botões de ícone restantes */
#undo-btn, #redo-btn {
    width: 40px;
    height: 40px;
    background-color: transparent;
    border: 2px solid #041A4A;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    padding: 0;
    background-repeat: no-repeat;
    background-position: center;
}

/* MUDANÇA: Nova regra de estilo dedicada para o botão de fotos */
#show-photos-btn {
    display: inline-block;
    width: auto;
    height: 40px;
    padding: 0 16px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 40px;
}
#show-photos-btn:hover {
    background-color: #0056b3;
}


/* MUDANÇA: Seletor de grupo agora só para os ícones restantes */
#undo-btn:hover, #redo-btn:hover {
    background-color: #041A4A;
}

#undo-btn:hover::after, #redo-btn:hover::after {
    filter: invert(1);
}

/* MUDANÇA: Seletor de grupo agora só para os ícones restantes */
#undo-btn::after, #redo-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background-color: #041A4A;
    transition: filter 0.2s ease;
}

#undo-btn:disabled, #redo-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: transparent !important;
}
#undo-btn:disabled::after, #redo-btn:disabled::after {
    filter: none !important;
}

#undo-btn::after {
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000000'%3E%3Cpath d='M12.5 8C9.85 8 7.45 8.99 5.6 10.6L2 7V16H11L7.38 12.38C8.77 11.22 10.54 10.5 12.5 10.5C15.24 10.5 17.54 11.94 18.64 14.04L20.36 13.26C18.91 10.44 15.96 8.5 12.5 8Z'/%3E%3C/svg%3E") no-repeat center;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000000'%3E%3Cpath d='M12.5 8C9.85 8 7.45 8.99 5.6 10.6L2 7V16H11L7.38 12.38C8.77 11.22 10.54 10.5 12.5 10.5C15.24 10.5 17.54 11.94 18.64 14.04L20.36 13.26C18.91 10.44 15.96 8.5 12.5 8Z'/%3E%3C/svg%3E") no-repeat center;
}

#redo-btn::after {
     -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000000'%3E%3Cpath d='M11.5 8C14.15 8 16.55 8.99 18.4 10.6L22 7V16H13L16.62 12.38C15.23 11.22 13.46 10.5 11.5 10.5C8.76 10.5 6.46 11.94 5.36 14.04L3.64 13.26C5.09 10.44 8.04 8.5 11.5 8Z'/%3E%3C/svg%3E") no-repeat center;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000000'%3E%3Cpath d='M11.5 8C14.15 8 16.55 8.99 18.4 10.6L22 7V16H13L16.62 12.38C15.23 11.22 13.46 10.5 11.5 10.5C8.76 10.5 6.46 11.94 5.36 14.04L3.64 13.26C5.09 10.44 8.04 8.5 11.5 8Z'/%3E%3C/svg%3E") no-repeat center;
}

#back-to-list-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #041A4A;
    background-color: transparent;
    border: 2px solid #041A4A;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#back-to-list-btn:hover {
    background-color: #041A4A;
    color: #FFFFFF;
}

#save-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background-color: #28a745;
    border: 2px solid #28a745;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}
#save-btn:hover {
    background-color: #218838;
    border-color: #218838;
}

.tournament-type-selector { margin: 1.5rem 0; text-align: center; }
.tournament-type-selector p { margin: 0 0 1rem 0; font-weight: 500; color: #333; }
.tournament-type-selector div { display: inline-block; margin: 0 10px; }
.tournament-type-selector label { padding: 8px 15px; border: 1px solid #ccc; border-radius: 20px; cursor: pointer; transition: all 0.2s ease; }
.tournament-type-selector input[type="radio"] { display: none; }
.tournament-type-selector input[type="radio"]:checked + label { background-color: #041A4A; color: #fff; border-color: #041A4A; }

.main-content { 
    display: flex; 
    gap: 2rem; 
    align-items: flex-start;
    justify-content: flex-start; 
}

.brackets-column { 
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    min-width: 0;
}

#winners-bracket-container, #losers-bracket-container, #grand-final-container { background-color: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.05); width: 100%; }
.bracket-area { overflow-x: auto; padding: 1.5rem; }
.bracket-wrapper { position: relative; width: fit-content; padding: 0; }
.bracket-matches { display: flex; position: relative; }
.round { position: relative; flex-shrink: 0; }
.match { position: absolute; }
.connector-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.bracket-matches { z-index: 2; position: relative; }
.svg-text-name, .svg-text-score { font-size: 15px; font-weight: 500; }
.svg-text-seed, .svg-text-id { font-size: 12px; font-weight: 600; }
.svg-text-id { font-weight: 700; }
.svg-text-placeholder { font-style: italic; fill: #99aab5; }

.score-select {
    width: 100%;
    height: 100%;
    border: 1px solid #0A2F78;
    background-color: #041A4A;
    color: #FFFFFF;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    padding-left: 5px;
}

.score-select:disabled {
    background-color: transparent;
    border-color: #E9ECEF;
    color: #99aab5;
    cursor: default;
    opacity: 0.8;
}

.public-view .score-select:disabled {
    background-color: #041A4A;
    border-color: #0A2F78;
    color: #FFFFFF;
    cursor: default;
    opacity: 1;
}


.full-width-input { width: 95%; padding: 10px; font-size: 1rem; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 1rem; display: block; margin-left: auto; margin-right: auto;}
.setup-section { padding: 1.5rem; border: 1px solid #e0e0e0; border-radius: 8px; margin-top: 1.5rem; }
.setup-divider { font-size: 1.2rem; font-weight: bold; color: #ccc; margin: 2rem 0; text-align: center; }
#tournament-list-container { max-width: 800px; margin: 2rem auto; }
#tournament-list ul { list-style: none; padding: 0; }
#tournament-list li a { display: block; padding: 1rem 1.5rem; background-color: #fff; border-radius: 8px; margin-bottom: 1rem; text-decoration: none; color: #333; box-shadow: 0 4px 12px rgba(0,0,0,0.05); transition: all 0.2s ease; }
#tournament-list li a:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.08); }
.tournament-name { font-weight: 600; font-size: 1.2rem; color: #041A4A; display: block; margin-bottom: 0.25rem; }
.tournament-details { font-size: 0.9rem; color: #777; }

/* --- ESTILOS ATUALIZADOS PARA A LISTA DE ADMIN --- */
#admin-tournament-list table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    table-layout: fixed;
}
#admin-tournament-list th {
    font-weight: 600;
    color: #6c757d;
    font-size: 0.9rem;
    text-transform: none;
    text-align: center;
    padding: 0 8px 10px 8px;
    border-bottom: 2px solid #e0e0e0;
}
#admin-tournament-list th:nth-child(1) { 
    width: 50%;
    text-align: left; 
}
#admin-tournament-list th:nth-child(2) { width: 120px; }
#admin-tournament-list th:nth-child(3) { width: 120px; }
#admin-tournament-list th:nth-child(4) { width: 240px; }

#admin-tournament-list td {
    padding: 1rem 8px;
    font-size: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}
#admin-tournament-list td:nth-child(1) {
    white-space: normal;
}
#admin-tournament-list tbody tr:last-child td {
    border-bottom: none;
}
#admin-tournament-list .tournament-name {
    font-size: 1rem;
    font-weight: 500;
    color: #041A4A;
}
.admin-btn-compact {
    box-sizing: border-box;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    margin-left: 5px;
    width: 70px;
    text-align: center;
}
.admin-btn-compact.view-btn {
    border-color: #007bff;
    color: #007bff;
}
.admin-btn-compact.view-btn:hover {
    background-color: #007bff;
    color: #fff;
}
.admin-btn-compact.edit-btn {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}
.admin-btn-compact.edit-btn:hover {
    background-color: #5a6268;
    border-color: #545b62;
}
.admin-btn-compact.delete-btn {
    border-color: #dc3545;
    color: #dc3545;
}
.admin-btn-compact.delete-btn:hover {
    background-color: #dc3545;
    color: #fff;
}
.actions-column {
    text-align: right;
    white-space: nowrap;
}
/* FIM DOS ESTILOS DA LISTA DE ADMIN */


#ranking-column { width: 360px; flex-shrink: 0; background-color: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.05); }
#ranking-column h2 { margin: 0; padding: 20px; font-size: 1.2rem; border-bottom: 1px solid #eee; }
#ranking-table { padding: 0 20px 20px 20px; }
#ranking-table table { width: 100%; border-collapse: collapse; font-size: 1rem; }
#ranking-table th, #ranking-table td { padding: 12px 8px; text-align: left; border-bottom: 1px solid #f0f0f0; }
#ranking-table tr:last-child td { border-bottom: none; }
#ranking-table thead { background-color: #f9fafb; }
#ranking-table th { font-weight: 600; color: #6c757d; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
#ranking-table tbody tr:hover { background-color: #f8f9fa; }
#ranking-table td { font-size: 1rem; }
#ranking-table td:first-child { font-weight: 700; color: #041A4A; text-align: center; font-variant-numeric: tabular-nums; }
#ranking-table td:nth-child(2) { font-weight: 500; font-size: 1rem; }
#admin-photo-manager { margin-top: 2.5rem; background-color: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.05); width: 100%; }
.photo-upload-area { padding: 0 20px 20px 20px; }
#photo-upload-form p { margin-top: 0; margin-bottom: 1rem; color: #333; }
#photo-upload-form input[type="file"] { display: block; margin-bottom: 1rem; }
#photo-upload-form button { padding: 10px 20px; font-size: 1rem; font-weight: bold; color: #fff; background-color: #007bff; border: none; border-radius: 6px; cursor: pointer; transition: background-color 0.2s ease; }
#photo-upload-form button:hover { background-color: #0056b3; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { position: relative; padding: 20px; width: 90vw; max-width: 1000px; height: 90vh; }
.modal-close-btn { position: absolute; top: -15px; right: -15px; width: 35px; height: 35px; background-color: #fff; border: none; border-radius: 50%; font-size: 24px; font-weight: bold; color: #333; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,0.2); display: flex; justify-content: center; align-items: center; }
.swiper-container { width: 100%; height: 100%; }
.swiper-slide { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    text-align: center;
    position: relative;
}
.swiper-slide img, .swiper-slide video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }

/* --- NOVO ESTILO PARA O BOTÃO DE APAGAR FOTO --- */
.delete-photo-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: rgba(220, 53, 69, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s ease;
}
.delete-photo-btn:hover {
    background-color: rgba(220, 53, 69, 1);
}

/* --- NOVOS ESTILOS PARA FEEDBACK VISUAL --- */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #041A4A;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 15px 25px;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s ease-in-out;
}
.toast.show {
    opacity: 1;
    transform: translateX(0);
}
.toast.success {
    background-color: #28a745;
}
.toast.error {
    background-color: #dc3545;
}
