/* --- ESTILOS GENERALES --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    text-align: center;
    padding: 20px;
    margin: 0;
}

h1, h2 {
    color: #4a4a4a;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* --- CONTENEDORES Y FORMULARIOS --- */
.form-container,
.portal-container {
    max-width: 600px;
    margin: 30px auto;
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    text-align: left;
}

.portal-container {
    text-align: center;
}

.form-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.form-container input[type="text"],
.form-container input[type="email"],
.form-container input[type="password"],
.form-container input[type="tel"],
.form-container input[type="number"],
.form-container input[type="date"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

.form-container button,
.portal-button {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.form-container button:hover,
.portal-button:hover {
    background-color: #0056b3;
}

/* --- MENSAJES DE FORMULARIO --- */
.mensaje-exito {
    color: #28a745;
    text-align: center;
    background-color: #e9f7ef;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.mensaje-error {
    color: #dc3545;
    text-align: center;
    background-color: #f8d7da;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.form-enlace-inferior {
    text-align: center;
    margin-top: 15px;
}

.mensaje-info {
    text-align: center;
    margin-top: 30px;
    color: #555;
}


/* --- CUADRÍCULA DE LA RIFA --- */
.grid-rifa {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.numero {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60px;
    border-radius: 5px;
    font-size: 1.5em;
    font-weight: bold;
    color: white;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.numero.disponible {
    background-color: #28a745;
    cursor: pointer;
}

.numero.disponible:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.numero.ocupado {
    background-color: #dc3545;
    cursor: not-allowed;
    opacity: 0.7;
}

.numero-elegido {
    background-color: #ffc107;
    padding: 5px 10px;
    border-radius: 5px;
    color: #333;
}

/* --- TABLAS DE ADMINISTRACIÓN --- */
.admin-table {
    width: 100%;
    margin: 20px auto;
    border-collapse: collapse;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    background-color: white;
    overflow: hidden;
    border-radius: 8px;
}
.admin-table th, .admin-table td {
    border-bottom: 1px solid #ddd;
    padding: 12px 15px;
    text-align: left;
    vertical-align: middle;
}
.admin-table th {
    background-color: #007bff;
    color: white;
}
.admin-table tr:nth-child(even) {
    background-color: #f8f9fa;
}
.admin-table tr:hover {
    background-color: #e9ecef;
}
.admin-table input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
}
.celda-numero {
    text-align: center;
    font-weight: bold;
}

/* --- BOTONES DE COMPARTIR Y CONTACTO --- */
.botones-compartir {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.botones-compartir .btn-copiar,
.botones-compartir .btn-whatsapp-share,
.btn-whatsapp {
    flex-grow: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    color: white !important;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.9em;
}

.botones-compartir .btn-copiar {
    background-color: #6c757d;
}
.botones-compartir .btn-copiar:hover {
    background-color: #5a6268;
    text-decoration: none;
}
.botones-compartir .btn-copiar.copiado {
    background-color: #28a745;
}

.botones-compartir .btn-whatsapp-share,
.btn-whatsapp {
    background-color: #25D366;
}
.botones-compartir .btn-whatsapp-share:hover,
.btn-whatsapp:hover {
    background-color: #1DA851;
    color: white;
    text-decoration: none;
}

.botones-compartir i {
    margin-right: 5px;
}

/* --- BOTONES DE GESTIÓN (VER/EDITAR/ELIMINAR) --- */
.botones-gestion {
    display: flex;
    flex-direction: column;    
    gap: 8px;    
}

.btn-gestion {
    padding: 10px;
    border-radius: 5px;
    color: white !important;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    transition: opacity 0.2s;
    border: none;
    width: 100%;
    cursor: pointer;
    font-size: 1em;
}

.btn-gestion:hover {
    opacity: 0.85;
    text-decoration: none;
    color: white !important;
}

.btn-gestion.btn-ver {
    background-color: #17a2b8; /* Azul-verde (info) */
}

.btn-gestion.btn-editar {
    background-color: #ffc107; /* Amarillo (warning) */
    color: #333 !important;
}

.btn-gestion.btn-eliminar {
    background-color: #dc3545; /* Rojo (peligro) */
}

.btn-gestion.btn-liberar {
    background-color: #6c757d; /* Gris (secundario) */
}

.btn-gestion[disabled] {
    background-color: #b0b0b0;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-gestion[disabled]:hover {
    opacity: 0.6;
}


/* --- ESTILOS PARA BUSCADOR DE GANADORES --- */
.ganadores-container {
    background-color: #eef7ff;
    border: 1px solid #bce0fd;
    border-radius: 8px;
    padding: 20px;
    margin: 30px auto;
    max-width: 900px;
}
.ganadores-container h2 {
    margin-top: 0;
}
.campos-ganadores {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}
.campos-ganadores .campo {
    flex: 1;
}
.campos-ganadores label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}
.campos-ganadores input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1.2em;
    text-align: center;
}
.btn-buscar-ganadores {
    width: 100%;
    padding: 12px;
    font-size: 1.2em;
    font-weight: bold;
    color: white;
    background-color: #ff9800;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}
.btn-buscar-ganadores:hover {
    background-color: #f57c00;
}

/* --- ESTILOS PARA RESULTADOS DE GANADORES --- */
.resultados-ganadores {
    background-color: #fff;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    padding: 20px;
    margin: 30px auto;
    max-width: 900px;
    text-align: left;
}
.resultados-ganadores h2 {
    color: #4CAF50;
    margin-top: 0;
    text-align: center;
}
.ganador-item {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding: 15px 0;
}
.ganador-item:last-child {
    border-bottom: none;
}
.premio-label {
    flex-basis: 30%;
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}
.ganador-info {
    flex-basis: 70%;
}
.ganador-info p {
    margin: 2px 0;
    font-size: 1.1em;
}

/* --- ESTILOS PARA ESTADO DE PAGO Y ACCIONES --- */
.estado-pago {
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 0.9em;
    color: white;
    text-align: center;
    display: inline-block;
}
.estado-pago.pagado {
    background-color: #28a745; /* Verde */
}
.estado-pago.pendiente {
    background-color: #ffc107; /* Amarillo */
    color: #333;
}

.acciones-participante {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.form-accion {
    margin: 0;
}
.btn-accion-pago {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    background-color: #007bff; /* Azul */
    font-size: 1em;
}
.btn-accion-pago:hover {
    opacity: 0.85;
}

/* --- ESTILOS ESPECÍFICOS DEL CHECKBOX DE POLÍTICAS EN LA PÁGINA PRINCIPAL --- */
.privacy-agreement {
    margin-bottom: 40px; /* **AJUSTADO AQUÍ PARA MÁS ESPACIO** */
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center; /* Centra el contenido horizontalmente */
}

.privacy-agreement input[type="checkbox"] {
    width: auto;
    margin: 0;
    min-width: 16px;
    min-height: 16px;
    cursor: pointer;
}

.privacy-agreement label {
    font-size: 0.9em;
    color: #555;
    cursor: pointer;
    margin: 0;
}

.privacy-agreement label a {
    color: #007bff;
    text-decoration: none;
    font-weight: bold;
}

.privacy-agreement label a:hover {
    text-decoration: underline;
}

/* Estilos para el botón cuando está deshabilitado */
.portal-button[style*="pointer-events: none"] {
    cursor: not-allowed;
    background-color: #cccccc; /* Un gris más claro para indicar inactividad */
    opacity: 0.6; /* Mantener la opacidad, ya que JS ya la establece */
}

/* --- ESTILOS PARA DOCUMENTOS LEGALES (POLÍTICAS Y TÉRMINOS) --- */
.politicas-container {
    max-width: 800px; /* Ancho máximo para el contenido */
    margin: 40px auto; /* Centra el contenedor y le da margen superior/inferior */
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    text-align: left; /* Alinea el texto a la izquierda */
    line-height: 1.6; /* Espaciado entre líneas para mejor lectura */
    color: #444; /* Color de texto más suave */
}

.politicas-container h1 {
    text-align: center; /* Centra el título principal */
    color: #2c3e50; /* Un color más oscuro para el título */
    margin-bottom: 20px;
}

.politicas-container .last-updated {
    text-align: center;
    font-size: 0.9em;
    color: #777;
    margin-bottom: 30px;
}

.politicas-container h2 {
    color: #34495e; /* Color para los subtítulos de sección */
    margin-top: 30px; /* Espacio antes de cada sección */
    margin-bottom: 15px;
    border-bottom: 1px solid #eee; /* Línea divisoria bajo los títulos de sección */
    padding-bottom: 5px;
}

.politicas-container h3 {
    color: #555; /* Color para sub-subtítulos */
    margin-top: 20px;
    margin-bottom: 10px;
}

.politicas-container p {
    margin-bottom: 15px; /* Espacio después de cada párrafo */
}

.politicas-container ul {
    list-style-type: disc; /* Viñetas para las listas */
    margin-left: 20px; /* Indentación de las listas */
    margin-bottom: 15px;
}

.politicas-container li {
    margin-bottom: 8px; /* Espacio entre elementos de la lista */
}

.politicas-container strong {
    font-weight: bold; /* Asegura que el texto en negrita se vea fuerte */
}

.politicas-container .back-to-home {
    text-align: center;
    margin-top: 40px;
}

.politicas-container .back-to-home a {
    display: inline-block;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.politicas-container .back-to-home a:hover {
    background-color: #0056b3;
    text-decoration: none;
}


/* --- ESTILOS PARA ENLACES DE PIE DE PÁGINA DEL PORTAL --- */
.portal-footer-links {
    margin-top: 20px; /* Espacio arriba de los enlaces */
    font-size: 0.9em; /* Un poco más pequeño */
}

.portal-footer-links a {
    color: #555; /* Un color más suave para enlaces de pie de página */
    margin: 0 10px; /* Espacio entre los enlaces */
}

.portal-footer-links a:hover {
    color: #007bff; /* Cambia a azul al pasar el mouse */
}


/* --- ESTILOS RESPONSIVOS PARA CELULARES (TABLET Y MÓVIL GENERAL) --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.8em;
    }

    .form-container,
    .portal-container,
    .ganadores-container,
    .resultados-ganadores,
    .politicas-container { /* Añadido .politicas-container aquí */
        width: auto;
        padding: 20px;
        margin: 15px 0;
    }

    .grid-rifa {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 5px;
        padding: 10px;
    }

    .numero {
        height: 50px;
        font-size: 1.2em;
    }
    
    .admin-table {
        border: none;
    }

    .admin-table thead {
        display: none;
    }

    .admin-table tr {
        display: block;
        border: 1px solid #ddd;
        border-radius: 5px;
        margin-bottom: 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    
    .admin-table td {
        display: block;
        text-align: right;
        padding-left: 50%;
        position: relative;
        border: none;
        border-bottom: 1px solid #eee;
    }

    .admin-table td:last-child {
        border-bottom: none;
    }

    .admin-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        font-weight: bold;
        text-align: left;
    }
    
    .admin-table input[type="text"] {
        width: 100%;
        font-size: 0.9em;
    }

    .botones-compartir {
        flex-direction: row;    
    }

    .botones-gestion {
        flex-direction: column;    
    }
    
    .acciones-participante {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .acciones-participante .form-accion,
    .acciones-participante .btn-whatsapp {
        flex-grow: 1;
        flex-basis: 40%;    
    }

    .campos-ganadores {
        flex-direction: column;
    }
    .ganador-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Ajuste para el checkbox en móviles */
    .privacy-agreement {
        flex-direction: column; /* Apila el checkbox y el texto en columnas */
        align-items: center; /* Centra el contenido apilado */
        text-align: center; /* Centra el texto del label */
        gap: 5px; /* Reduce el espacio entre checkbox y texto */
    }
    .privacy-agreement input[type="checkbox"] {
        margin-bottom: 5px; /* Un poco de espacio debajo del checkbox */
    }

    /* Ajustes específicos para títulos en documentos legales en móviles */
    .politicas-container h1 {
        font-size: 1.6em;
    }

    .politicas-container h2 {
        font-size: 1.3em;
    }
}

/* --- ESTILOS RESPONSIVOS PARA CELULARES MUY PEQUEÑOS --- */
@media (max-width: 400px) {

    body,
    .grid-rifa {
        /* Reducimos aún más el espaciado para ganar cada píxel. */
        padding: 5px;
    }

    .form-container,
    .portal-container,
    .ganadores-container,
    .resultados-ganadores,
    .politicas-container { /* Añadido .politicas-container aquí */
        /* Menos relleno interno en los contenedores. */
        padding: 15px;
    }
    
    .admin-table td {
        /* Ajuste clave para la tabla: 
            Reducimos el espacio para la etiqueta para dar más espacio al contenido. */
        padding-left: 120px;    
    }

    .admin-table td::before {
        /* Hacemos que la etiqueta ocupe un poco menos. */
        width: 110px;
    }

    .botones-compartir {
        /* Forzamos los botones de compartir a apilarse verticalmente. */
        flex-direction: column;
    }
    
    .botones-compartir .btn-copiar,
    .botones-compartir .btn-whatsapp-share {
        /* Aseguramos que los botones ocupen todo el ancho disponible. */
        width: 100%;
        box-sizing: border-box;
    }

    .btn-gestion {
        /* Hacemos los botones de gestión un poco más pequeños. */
        font-size: 0.9em;
        padding: 8px;
    }
}