/**
 * =====================================
 * Estilos Principales - Ruleta Imagining
 * =====================================
 */

:root {
    --primary: #b33eff;
    --primary-hover: #9c2eed;
    --secondary: #ff27c6;
    --secondary-hover: #e51ab1;
    --success: #6cc12f;
    /* Boton Comenzar */
    --success-hover: #5ab120;
    --text-main: #333333;
    --text-muted: #888888;
    --bg-main: #f5f6f8;
    --bg-sidebar: #ffffff;
    --border-color: #eaeaea;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;

    /* Variables dinámicas desde JS para la ruleta */
    --roulette-bg: #8d24c6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
}

/* ---------------------------------
   LAYOUT PRINCIPAL
   --------------------------------- */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* El header original arriba. Puede ocultarse o adaptarse en fullscreen */
.app-header {
    background-color: white;
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* El header por defecto oculto si replicamos el layout del screenshot donde no hay header arriba, 
   o visible. Lo dejaremos oculto por defecto y lo usaremos en el modal o si el user lo requiere arriba */
.app-header {
    display: none;
}

.main-content {
    display: flex;
    flex: 1;
    height: 100vh;
    /* Ocupa pantalla completa en inicio */
}

/* ---------------------------------
   SIDEBAR (CONTROLES)
   --------------------------------- */
.sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.02);
}

.tabs-container {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tab-btn:last-child {
    border-bottom: none;
}

.tab-btn i {
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 16px;
    transition: color 0.2s;
}

.tab-btn:hover {
    background-color: #fcfcfc;
}

.tab-btn.active {
    background-color: #f7f3fe;
    /* Fondo suave morado */
    color: var(--primary);
    border-left: 4px solid var(--primary);
    padding-left: 16px;
    /* Compensar borde */
}

.tab-btn.active i {
    color: var(--primary);
}

.tab-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------------------------
   CONTROLES DE FORMULARIO
   --------------------------------- */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-main);
    transition: all 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(179, 62, 255, 0.1);
}

.form-group input[type="text"].ruleta-titulo-input {
    border: 2px solid var(--secondary);
    border-radius: var(--radius-sm);
}

/* Checkbox Moderno */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.checkbox-group label {
    margin-bottom: 0;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Entradas */
.actions-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-action {
    flex: 1;
    background-color: #eef0f3;
    border: none;
    padding: 10px 0;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    color: #4a5568;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-action:hover {
    background-color: #e2e5e9;
}

.form-group textarea {
    resize: none;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* Diseño / Uploads */
.flex-upload {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border-color);
}

.label-info {
    display: flex;
    flex-direction: column;
}

.small-text {
    font-size: 11px;
    color: var(--text-muted);
}

.upload-btn {
    color: #3182ce;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.upload-btn:hover {
    text-decoration: underline;
}

.d-none {
    display: none;
}

/* Paletas y Colores */
.theme-palettes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.theme-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.theme-btn:hover {
    transform: scale(1.1);
}

.color-pickers {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.color-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-input-wrapper input[type="text"] {
    width: 80px;
    padding: 6px 10px;
}

.color-input-wrapper input[type="color"] {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

/* Sidebar Footer Boton Comenzar */
.sidebar-footer {
    padding: 20px;
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
}

.btn-primary {
    background-color: var(--success);
    color: white;
}

.btn-primary:hover {
    background-color: var(--success-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 193, 47, 0.3);
}

/* Si añadimos boton de guardar */
.btn-secondary {
    background-color: var(--secondary);
    color: white;
}

/* ---------------------------------
   ÁREA DE LA RULETA MAIN CONTENT
   --------------------------------- */
.roulette-area {
    flex: 1;
    background-color: var(--roulette-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

.roulette-wrapper {
    position: relative;
    width: 500px;
    height: 500px;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.2));
    transform: scale(1.4);
    transition: transform 0.3s ease;
}

#rouletteCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    /* Sombra interna o resplandor de la ruleta */
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Indicador (Puntero) a la derecha */
.roulette-pointer {
    position: absolute;
    right: -25px;
    top: 50%;
    transform: translateY(-50%);
    width: 65px;
    height: 65px;
    z-index: 5;
    transform-origin: center right;
}

@keyframes pointerTick {
    0% {
        transform: translateY(-50%) rotate(0deg);
    }

    30% {
        transform: translateY(-50%) rotate(15deg);
    }

    100% {
        transform: translateY(-50%) rotate(0deg);
    }
}

.roulette-pointer.ticking {
    animation: pointerTick 0.1s ease-out;
}

.roulette-pointer svg {
    width: 100%;
    height: 100%;
}

/* Logo central de la ruleta */
.center-logo-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background-color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.center-logo-wrapper img {
    max-width: 60%;
    max-height: 60%;
    object-fit: contain;
}

/* Título de la ruleta (en interfaz) */
.roulette-title-display {
    position: absolute;
    right: 15%;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 32px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Controles inferiores rapidos de la ruleta */
.quick-palettes {
    position: absolute;
    bottom: 30px;
    left: 30px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 8px;
    display: flex;
    gap: 6px;
    backdrop-filter: blur(10px);
}

.quick-palettes .theme-btn {
    width: 20px;
    height: 20px;
}

/* ---------------------------------
   MODO FULLSCREEN Y ANIMACIONES
   --------------------------------- */
.app-container.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
}

.app-container.is-fullscreen .sidebar {
    display: none;
    /* Ocultar sidebar en fullscreen */
}

.app-container.is-fullscreen .roulette-wrapper {
    transform: scale(1.6);
    /* AÚN MÁS GRANDE EN MODO SORTEO / FS */
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* SweetAlert customization */
.swal2-container {
    z-index: 10001 !important;
    /* Above fullscreen app container */
}

.swal2-popup {
    border-radius: 20px !important;
    padding: 0 !important;
    overflow: hidden;
    border: 4px solid var(--primary) !important;
    background: #ffffff !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
}

.custom-swal-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 30px 20px 20px;
    color: white;
    text-align: center;
}

.custom-swal-header h2 {
    color: white !important;
    margin-bottom: 0;
    font-size: 28px;
    font-weight: 800;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.custom-swal-header img {
    max-height: 80px;
    margin-bottom: 15px;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.swal2-html-container {
    margin: 0 !important;
}

.winner-name {
    font-size: 36px;
    font-weight: 900;
    color: var(--secondary) !important;
    margin: 20px 0 20px;
    text-transform: uppercase;
    animation: pulse 1s infinite alternate;
}

.swal-prize-text {
    font-size: 20px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.swal-prize-text b {
    color: var(--primary);
}

.swal2-actions {
    margin-bottom: 25px !important;
}

.swal2-styled.swal2-confirm {
    background-color: var(--primary) !important;
    border-radius: 30px !important;
    padding: 14px 35px !important;
    font-weight: 700 !important;
    font-size: 18px !important;
    transition: all 0.2s;
}

.swal2-styled.swal2-confirm:hover {
    transform: scale(1.05);
    background-color: var(--primary-hover) !important;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.05);
    }
}

/* ---------------------------------
   TABLA DE RESULTADOS (GANADORES)
   --------------------------------- */
.winners-results-container {
    display: none;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 600px;
    z-index: 50;
    text-align: center;
    animation: fadeInUp 0.5s ease-out;
}

.results-title {
    color: var(--primary);
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.results-table-wrapper {
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.results-table th {
    background-color: #f7f3fe;
    color: var(--primary);
    font-weight: 700;
    padding: 15px;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.results-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-main);
    vertical-align: middle;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table tr:hover td {
    background-color: #fafbfc;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------------------------
   RESPONSIVE DESIGN
   --------------------------------- */
@media screen and (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }

    .main-content {
        flex-direction: column-reverse;
        height: auto;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .roulette-area {
        min-height: 60vh;
        overflow: hidden;
    }

    .roulette-wrapper {
        transform: scale(0.9);
    }

    .app-container.is-fullscreen .roulette-wrapper {
        transform: scale(1.1);
    }
}

@media screen and (max-width: 600px) {
    .roulette-wrapper {
        transform: scale(0.7);
        margin-top: 20px;
    }

    .app-container.is-fullscreen .roulette-wrapper {
        transform: scale(0.9);
    }

    .roulette-title-display {
        font-size: 3rem;
        margin-left: 20px;
    }

    .quick-palettes {
        bottom: 10px;
        right: 10px;
    }

    .winners-results-container {
        width: 95%;
        padding: 20px;
    }
}

@media screen and (max-width: 400px) {
    .roulette-wrapper {
        transform: scale(0.55);
    }

    .app-container.is-fullscreen .roulette-wrapper {
        transform: scale(0.7);
    }
}

/* ==============================================
   SISTEMA DE AUTENTICACIÓN - LOGIN / REGISTRO
   ============================================== */

/* Overlay de fondo */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a0533 0%, #3b0e7a 50%, #6b1fa3 100%);
    padding: 20px;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.auth-overlay--hidden {
    display: none;
}

/* Card central */
.auth-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
}

/* Logo en el modal */
.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo img {
    max-height: 80px;
    max-width: 200px;
    object-fit: contain;
}

/* Tabs login / registro */
.auth-tabs {
    display: flex;
    background: #f1f3f5;
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 28px;
    gap: 4px;
}

.auth-tab-btn {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.auth-tab-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Paneles de formulario */
.auth-form-pane {
    display: none;
}

.auth-form-pane.active {
    display: block;
}

/* Grupos de campo */
.auth-form-group {
    margin-bottom: 16px;
}

.auth-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.auth-form-group label i {
    color: var(--primary);
    margin-right: 5px;
    width: 14px;
}

.auth-form-group input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.auth-form-group input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(179, 62, 255, 0.12);
}

/* Mensaje de error */
.auth-error {
    background: #fff3f3;
    border: 1px solid #ffcdd2;
    color: #c62828;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-error::before {
    content: '\26A0';
    font-size: 14px;
}

/* Botón submit */
.auth-submit-btn {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 4px;
}

.auth-submit-btn:hover {
    opacity: 0.92;
}

.auth-submit-btn:active {
    transform: scale(0.98);
}

.auth-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==============================================
   BARRA DE USUARIO EN EL SIDEBAR
   ============================================== */

.user-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(90deg, rgba(179,62,255,0.07), rgba(255,39,198,0.07));
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.user-bar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    overflow: hidden;
}

.user-bar-info i {
    font-size: 18px;
    flex-shrink: 0;
}

.user-bar-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Indicador de guardado */
.save-status {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color 0.3s;
}

.save-status.saving {
    color: #f59e0b;
}

.save-status.saved {
    color: #16a34a;
}

.save-status.error {
    color: #dc2626;
}

/* Botón logout */
.btn-logout {
    background: none;
    border: 1.5px solid #e0e0e0;
    border-radius: 6px;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fff5f5;
}