/* Estilos generales */
:root {
    --primary-color: #103663;
    --secundary-color: #DE0D35;
    --background-color: #f5f7fa;
    --background-color-dark: #1a2533;
    --text-color: #333;
    --bg-gradient-light: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    --bg-gradient-dark: linear-gradient(135deg, #1a1a1a, #2a2a2a);
    --text-color-light: #000000;
    --text-color-dark: #e0e0e0;
    --accent-color: #1c2cd9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.45s;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    height: 100vh;
    width: 100vw;
    font-size: 16px;
    background: var(--bg-gradient-light);
    color: var(--text-color-light);
    overflow: hidden;
}

body.dark-mode {
    background: var(--bg-gradient-dark);
    color: var(--text-color-dark);

    .swal2-modal {
        background-color: var(--background-color-dark);
        color: var(--text-color-dark);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
    }

    .join-container {
        background-color: var(--background-color-dark) !important;
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
        color: var(--text-color-dark);
    }

    .join-container .form-control {
        background-color: #2c3e50;
        color: var(--text-color-dark);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    .join-container .form-control::placeholder {
        color: rgba(255, 255, 255, 0.4);
    }

    .join-container .text-primary {
        color: #90caf9 !important;
    }
}

#toggle-dark-mode {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    color: #fff;
    background-color: var(--accent-color);
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

#toggle-dark-mode:hover {
    background-color: #0f1fc9;
}

/* Estilos de join.html */
.join-container {
    width: 40vw;
    height: 40%;
    background-color: var(--background-color);

    .logoRD {
        object-fit: contain;
        width: 45%;
        max-width: 400px;
        height: auto;
        margin-top: -25px;
        margin-bottom: 1rem;
    }

    .text-primary {
        font-size: 1.5rem;
        color: #103663 !important;
        margin-bottom: 1rem;
    }

    .form-control {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
}

.btn-primary,
.swal2-confirm {
    font-size: 1rem;
    background-color: #103663;
    border-color: #103663;
    color: white;
}

.btn-primary:hover,
.swal2-confirm:hover,
.btn-primary:focus {
    background-color: #002244;
    border-color: #002244;
}

.btn-danger,
.swal2-cancel {
    font-size: 1rem;
    background-color: #DE0D35;
    border-color: #DE0D35;
    color: white;
}

.btn-danger:hover,
.swal2-cancel:hover,
.btn-danger:focus {
    background-color: #980c26;
    border-color: #980c26;
}

/* Estilos de call.html */
body.dark-mode {
    .call-container {
        background-color: var(--background-color-dark) !important;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
        color: var(--text-color-dark);
    }

    .camaraycontroles{
        background-color: var(--background-color-dark) !important;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
            color: var(--text-color-dark);
    }
}

.call-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Estilos header */
.room-info {
    align-items: center;
    background-color: #103663;
    padding: 7px 20px;
    z-index: 5;
    position: sticky;
    top: 0;
    display: flex;
    flex-wrap: nowrap;
    height: 70px;

    .logoRD {
        object-fit: contain;
        height: 55px;
        min-width: 100px;
        max-width: 180px;
    }

    #copy-room-id {
        display: flex;
        font-weight: bold;
        font-size: 1rem;
        width: fit-content;
        align-items: center;
        justify-content: center;
    }

    .timer {
        margin: 0 auto;
        max-width: 250px;
        font-family: monospace;
        font-size: 1rem;
        color: white;
    }
}

/* Estilo footer*/
.controls-container {
    position: sticky;
    bottom: 9px;
    z-index: 10;
    display: flex;
    height: 100px;
    width: 100%;
    justify-content: center;
    gap: 15px;
    align-items: end;
    flex-wrap: nowrap;
}

.control-button {
    height: 60px;
    width: 60px;
    background-color: #DE0D35;
    border: none;
    transition: background 0.3s ease, transform 0.2s ease;
}

.control-button svg {
    fill: white;
    width: 2.1rem;
    height: 2.1rem;
}

.control-button:hover {
    transform: translateY(-3px);
}

.control-button.active {
    background-color: #103663;
}


/* Estilos de la cámara y controles */
.camaraycontroles {
    height: calc(100vh - 70px);
    max-height: 95vh;
    padding: 5px;
    overflow: hidden;
    background-color: var(--background-color);
}

/* Ajustes dinámicos según cantidad de participantes */
.video-grid {
    display: grid;
    width: 100%;
    height: 100%;
    padding: 20px;
    gap: 15px;
    align-items: center;
    justify-items: center;
    overflow: hidden;
}

.video-grid[data-participants="1"] {
    grid-template-columns: 1fr;
}

.video-grid[data-participants="1"] .video-container {
    max-width: 60%;
    margin: auto;
}

.video-grid[data-participants="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.video-grid[data-participants="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.video-grid[data-participants="4"] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.video-grid[data-participants="5"],
.video-grid[data-participants="6"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.video-grid[data-participants="7"],
.video-grid[data-participants="8"],
.video-grid[data-participants="9"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.video-grid[data-participants="10"],
.video-grid[data-participants="11"],
.video-grid[data-participants="12"] {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.video-grid[data-participants="13"],
.video-grid[data-participants="14"],
.video-grid[data-participants="15"] {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

/* Esrilos cuando hay una presentacion */
.video-grid.has-large-container {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: 1fr;
    gap: 25px;
    height: 100%;
    align-items: start;
}

/* Estilos de video */
.video-container {
    position: relative;
    width: auto;
    height: fit-content;
    max-height: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0px 0px 5px 0px #4c4c4c;
    aspect-ratio: 16/9;
}

.video-container.large {
    display: flex;
    grid-column: 1;
    grid-row: 1;
    transition: all 0.3s ease;
    border: 3px solid var(--rd-accent);
    box-shadow: 0px 0px 20px 6px rgba(28, 44, 217, 0.477);
    z-index: 2;
    width: fit-content;
    height: 100%;
    aspect-ratio: 16/9;
    align-self: center;
    justify-self: center;
}

.video-container.large video {
    height: 100%;
    width: 100%;
    object-fit: contain;
    aspect-ratio: 16/9;
}

.video-container.large .video-label {
    visibility: hidden;
}

.video-grid.has-large-container .small-container {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 100%;
    overflow-y: auto;
    padding: 5px;
}

.small-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 100%;
    overflow-y: auto;
    padding: 5px;
}

.video-container.small {
    display: flex;
    transition: all 0.3s ease;
    width: fit-content;
    object-fit: cover;
    max-height: 15vh;
    justify-content: center;
}

.video-container.small video {
    width: fit-content;
    height: 100%;
    height: 13vh;
    max-height: 15vh;
    aspect-ratio: 16/9;
}

video {
    width: 100%;
    min-width: 80%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.2);
}

.video-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    color: white;
    z-index: 2;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}





@media only screen and (max-width: 900px) {
    body {
        display: flex;
        flex-direction: column;
        max-height: 100dvh;
        max-width: 100dvw;
        overflow-y: auto;
    }

    .join-container {
        width: 80dvw;
        height: 50%;
        padding: 6dvw;
    }

    .join-container .logoRD {
        width: 60%;
        height: auto;
    }

    .video-grid[data-participants="1"] {
        grid-template-columns: 1fr;
    }

    .video-grid[data-participants="1"] .video-container {
        max-width: 95%;
        margin: auto;
    }

    .video-grid[data-participants="2"],
    .video-grid[data-participants="3"] {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .video-grid[data-participants="4"] {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }

    .video-grid[data-participants="5"],
    .video-grid[data-participants="6"] {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }

    .video-grid[data-participants="7"],
    .video-grid[data-participants="8"] {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }

    .video-grid[data-participants="9"] {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }

    .video-grid[data-participants="10"],
    .video-grid[data-participants="11"],
    .video-grid[data-participants="12"] {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }

    .video-grid[data-participants="13"],
    .video-grid[data-participants="14"],
    .video-grid[data-participants="15"] {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(5, 1fr);
    }

    /* Aplicar estilo para 4 participantes en adelante */
    .video-grid[data-participants]:not([data-participants="1"]):not([data-participants="2"]):not([data-participants="3"]) .video-container,
    .video-grid[data-participants]:not([data-participants="1"]):not([data-participants="2"]):not([data-participants="3"]) video {
        height: 100%;
        object-fit: cover;
        aspect-ratio: 4 / 3;
    }

    .video-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 20px;
        width: 100%;
        max-height: 80dvh;
        padding: 15px;
        align-items: center;
        justify-items: center;
        overflow: auto;
        flex-wrap: nowrap;
    }

    .video-grid.has-large-container {
        display: grid;
        grid-template-columns: auto auto;
        grid-template-rows: auto;
        gap: 20px;
    }

    .video-container {
        position: relative;
        width: auto;
        max-width: 99%;
        height: auto;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0px 2px 20px 0px #4c4c4c;
        aspect-ratio: 16/9;
    }

    .video-container.large {
        display: flex;
        height: auto !important;
        width: 82dvw;
        grid-column: 1 / -1;
        grid-row: 1;
        transition: all 0.3s ease;
        border: 3px solid var(--rd-accent);
        box-shadow: 0px 0px 20px 6px rgba(28, 44, 217, 0.477);
        z-index: 2;
        aspect-ratio: 16/9 !important;
    }

    .video-container.large video {
        height: auto !important;
        width: 100%;
        object-fit: contain !important;
        aspect-ratio: 16/9 !important;
    }

    .video-container.large .video-label {
        visibility: hidden;
    }

    .video-container.small {
        display: flex;
        grid-row: 2;
        width: 100%;
        display: grid;
        transition: all 0.3s ease;
        width: fit-content;
        margin: 0 auto;
        object-fit: cover;
        max-height: 15dvh;
        flex-wrap: wrap;
        justify-content: center;
    }

    .video-container.small video {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }

    video {
        object-fit: cover;
        min-width: 70%;
    }

    .controls-container {
        position: sticky;
        bottom: 2dvh;
        margin-top: -5px;
        z-index: 10;
        display: flex;
        height: 10dvh;
        justify-content: center;
        align-items: end;
        flex-wrap: nowrap;
    }

    #copy-room-id {
        font-size: clamp(0.9rem, 2vw, 1.25rem);
        padding: 8px 12px;
        max-width: 30dvw;
        width: 45vw;
        height: max-content;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .timer {
        max-width: 30dvw;
        padding: 1px;
        font-family: monospace;
        text-align: left;
        font-size: 0.9rem;
        color: white;
    }
}