/* =========================
   RESET
========================= */

* {
    box-sizing: border-box;
}


html,
body {
    margin: 0;
    padding: 0;

    width: 100%;
    min-height: 100%;
}


body {
    min-height: 100vh;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    background:
        radial-gradient(
            circle at top,
            #172554 0%,
            #0f172a 42%,
            #020617 100%
        );

    color: #ffffff;
}


button,
input {
    font: inherit;
}


button {
    cursor: pointer;
}


/* =========================
   BASE
========================= */

.container {
    width: 100%;
    min-height: 100vh;
}


.hidden {
    display: none !important;
}


/* =========================
   TELA DE ENTRADA
========================= */

#join-screen {
    width: 100%;
    max-width: 430px;

    min-height: 100vh;

    display: flex;

    flex-direction: column;

    justify-content: center;

    margin: 0 auto;

    padding: 34px;

    background:
        rgba(
            15,
            23,
            42,
            0.94
        );

    border:
        1px solid
        rgba(
            148,
            163,
            184,
            0.14
        );

    border-radius: 20px;

    box-shadow:
        0 28px 80px
        rgba(
            0,
            0,
            0,
            0.4
        );
}


.card {
    align-self: center;
}


/* =========================
   MARCA
========================= */

.brand {
    display: flex;

    align-items: center;

    gap: 14px;

    margin-bottom: 30px;
}


.brand-logo {
    width: 54px;
    height: 54px;

    flex: 0 0 auto;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 15px;

    background:
        linear-gradient(
            135deg,
            #2563eb,
            #4f46e5
        );

    color: #ffffff;

    font-size: 18px;
    font-weight: 700;

    box-shadow:
        0 10px 28px
        rgba(
            37,
            99,
            235,
            0.35
        );
}


.brand h1 {
    margin: 0;

    font-size: 32px;

    line-height: 1.1;
}


.subtitle {
    margin: 5px 0 0;

    color: #94a3b8;

    font-size: 14px;
}


/* =========================
   PRÉ-ENTRADA
========================= */

.prejoin-preview {
    margin-bottom: 4px;
}


.prejoin-media {
    position: relative;

    width: 100%;
    aspect-ratio: 16 / 9;

    overflow: hidden;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid #334155;
    border-radius: 14px;

    background:
        linear-gradient(
            145deg,
            #1e293b,
            #0f172a
        );
}


.prejoin-media video {
    width: 100%;
    height: 100%;

    object-fit: cover;

    transform: scaleX(-1);
}


.prejoin-placeholder {
    width: 78px;
    height: 78px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background:
        linear-gradient(
            135deg,
            #2563eb,
            #4f46e5
        );

    color: #ffffff;

    font-size: 24px;
    font-weight: 700;

    box-shadow:
        0 12px 35px
        rgba(
            37,
            99,
            235,
            0.28
        );
}


.prejoin-controls {
    display: grid;

    grid-template-columns:
        repeat(
            2,
            minmax(0, 1fr)
        );

    gap: 8px;

    margin-top: 10px;
}


.prejoin-control-button {
    min-height: 42px;

    padding: 8px 10px;

    border: 1px solid #334155;
    border-radius: 10px;

    background: #1e293b;
    color: #ffffff;

    font-size: 13px;
    font-weight: 600;
}


.prejoin-control-button:hover:not(:disabled) {
    background: #334155;
}


.prejoin-control-button.media-off {
    background: #450a0a;
    border-color: #991b1b;
    color: #fecaca;
}


.prejoin-control-button:disabled {
    cursor: not-allowed;
    opacity: 0.72;
}


.prejoin-message {
    min-height: 20px;

    margin: 8px 0 0;

    color: #fbbf24;

    font-size: 13px;
    line-height: 1.4;
}


/* =========================
   FORMULÁRIO
========================= */

label {
    display: block;

    margin-top: 18px;

    margin-bottom: 7px;

    color: #cbd5e1;

    font-size: 14px;

    font-weight: 500;
}


input {
    width: 100%;

    padding: 14px 15px;

    border:
        1px solid
        #334155;

    border-radius: 10px;

    outline: none;

    background: #020617;

    color: #ffffff;

    font-size: 16px;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}


input::placeholder {
    color: #64748b;
}


input:hover {
    border-color: #475569;
}


input:focus {
    border-color: #3b82f6;

    box-shadow:
        0 0 0 3px
        rgba(
            59,
            130,
            246,
            0.15
        );

    background: #030b1b;
}


/* =========================
   SALA / GERADOR
========================= */

.room-input-group {
    display: flex;

    align-items: stretch;

    gap: 8px;
}


.room-input-group input {
    flex: 1;

    min-width: 0;
}


.generate-room-button {
    flex: 0 0 auto;

    min-width: 92px;

    padding: 0 14px;

    border:
        1px solid
        #334155;

    border-radius: 10px;

    background: #1e293b;

    color: #ffffff;

    font-size: 13px;

    font-weight: 600;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.1s ease;
}


.generate-room-button:hover {
    background: #334155;

    border-color: #475569;
}


.generate-room-button:active {
    transform: scale(0.98);
}


/* =========================
   BOTÃO ENTRAR
========================= */

.join-button {
    width: 100%;

    margin-top: 24px;

    padding: 14px 18px;

    border: 0;

    border-radius: 10px;

    background:
        linear-gradient(
            135deg,
            #2563eb,
            #4f46e5
        );

    color: #ffffff;

    font-size: 16px;

    font-weight: 600;

    box-shadow:
        0 10px 25px
        rgba(
            37,
            99,
            235,
            0.22
        );

    transition:
        transform 0.15s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease;
}


.join-button:hover {
    transform:
        translateY(-1px);

    box-shadow:
        0 14px 30px
        rgba(
            37,
            99,
            235,
            0.3
        );
}


.join-button:active {
    transform:
        translateY(0);
}


.join-button:disabled {
    opacity: 0.55;

    cursor: wait;
}


/* =========================
   ERRO
========================= */

.error {
    min-height: 20px;

    margin: 16px 0 0;

    color: #fca5a5;

    font-size: 14px;

    line-height: 1.4;
}


/* =========================
   TELA DA CHAMADA
========================= */

.call-screen {
    width: 100%;

    min-height: 100vh;

    display: flex;

    flex-direction: column;

    background: #020617;
}


/* =========================
   CABEÇALHO
========================= */

.call-header {
    min-height: 66px;

    flex: 0 0 auto;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 16px;

    padding: 12px 20px;

    background:
        rgba(
            15,
            23,
            42,
            0.96
        );

    border-bottom:
        1px solid
        #1e293b;
}


.call-brand {
    min-width: 0;

    display: flex;

    flex-direction: column;

    gap: 3px;
}


.call-brand strong {
    font-size: 19px;
}


.call-brand span {
    max-width: 55vw;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    color: #94a3b8;

    font-size: 13px;
}


.online-status {
    display: flex;
    align-items: center;

    gap: 7px;

    color: #cbd5e1;

    font-size: 13px;

    white-space: nowrap;
}

.status-separator {
    color: #64748b;
}

#participant-count {
    color: #94a3b8;
}


.online-dot {
    width: 9px;

    height: 9px;

    flex: 0 0 auto;

    border-radius: 50%;

    background: #22c55e;

    box-shadow:
        0 0 10px
        rgba(
            34,
            197,
            94,
            0.7
        );
}


/* =========================
   PARTICIPANTES
========================= */

.participants {
    flex: 1;

    width: 100%;

    display: grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(
                300px,
                1fr
            )
        );

    align-content: center;

    gap: 14px;

    padding: 16px;

    overflow: auto;
}


/* =========================
   CARD PARTICIPANTE
========================= */

.participant {
    position: relative;

    width: 100%;

    min-height: 280px;

    aspect-ratio: 16 / 9;

    overflow: hidden;

    border:
        1px solid
        #1e293b;

    border-radius: 16px;

    background:
        linear-gradient(
            145deg,
            #1e293b,
            #0f172a
        );

    box-shadow:
        0 14px 38px
        rgba(
            0,
            0,
            0,
            0.28
        );
}


/* =========================
   ÁREA DE MÍDIA
========================= */

.participant-media {
    position: absolute;

    inset: 0;

    display: flex;

    align-items: center;

    justify-content: center;

    overflow: hidden;

    background:
        linear-gradient(
            145deg,
            #1e293b,
            #0f172a
        );
}


/* =========================
   VÍDEO
========================= */

.participant video,
.participant-media video {
    position: absolute;

    inset: 0;

    width: 100%;

    height: 100%;

    display: block;

    object-fit: cover;

    background: #000000;
}


.participant audio {
    display: none;
}


/* =========================
   AVATAR
========================= */

.participant-placeholder {
    position: relative;

    z-index: 1;

    width: 82px;

    height: 82px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 50%;

    background:
        linear-gradient(
            135deg,
            #2563eb,
            #4f46e5
        );

    color: #ffffff;

    font-size: 25px;

    font-weight: 700;

    box-shadow:
        0 12px 35px
        rgba(
            37,
            99,
            235,
            0.28
        );
}


/* =========================
   NOME PARTICIPANTE
========================= */

.participant-name {
    position: absolute;

    left: 12px;

    bottom: 12px;

    z-index: 5;

    max-width:
        calc(
            100% - 24px
        );

    padding: 7px 11px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    border-radius: 8px;

    background:
        rgba(
            2,
            6,
            23,
            0.72
        );

    color: #ffffff;

    font-size: 13px;

    font-weight: 600;

    backdrop-filter:
        blur(6px);

    -webkit-backdrop-filter:
        blur(6px);
}


/* =========================
   CONTROLES
========================= */

.controls {
    position: sticky;

    bottom: 0;

    z-index: 20;

    flex: 0 0 auto;

    width: 100%;

    display: grid;

    grid-template-columns:
        repeat(
            5,
            140px
        );

    align-items: stretch;

    justify-content: center;

    gap: 10px;

    padding: 14px 18px;

    background:
        rgba(
            15,
            23,
            42,
            0.98
        );

    border-top:
        1px solid
        #1e293b;

    box-shadow:
        0 -8px 30px
        rgba(
            0,
            0,
            0,
            0.2
        );
}


/* =========================
   BOTÃO CONTROLE
========================= */

.control-button {
    width: 140px;

    min-width: 0;

    height: 46px;

    margin: 0;

    padding: 0 10px;

    display: flex;

    align-items: center;

    justify-content: center;

    border:
        1px solid
        #334155;

    border-radius: 12px;

    background: #1e293b;

    color: #ffffff;

    font-size: 13px;

    font-weight: 600;

    line-height: 1.15;

    text-align: center;

    white-space: normal;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.1s ease,
        box-shadow 0.2s ease;
}


.control-button:hover {
    background: #334155;

    border-color: #475569;

    box-shadow:
        0 5px 15px
        rgba(
            0,
            0,
            0,
            0.2
        );
}


.control-button:active {
    transform:
        scale(0.97);
}


/* =========================
   MÍDIA DESLIGADA
========================= */

.control-button.media-off {
    background: #450a0a;

    border-color: #991b1b;

    color: #fecaca;
}


.control-button.media-off:hover {
    background: #7f1d1d;
}


/* =========================
   COPIAR CONVITE
========================= */

.control-button.invite {
    background: #0f766e;

    border-color: #0f766e;
}


.control-button.invite:hover {
    background: #115e59;

    border-color: #115e59;
}


/* =========================
   COMPARTILHAR
========================= */

.control-button.share {
    background: #4f46e5;

    border-color: #4f46e5;
}


.control-button.share:hover {
    background: #4338ca;

    border-color: #4338ca;
}


/* =========================
   SAIR
========================= */

.control-button.leave {
    background: #dc2626;

    border-color: #dc2626;
}


.control-button.leave:hover {
    background: #b91c1c;

    border-color: #b91c1c;
}


/* =========================
   LINK COPIADO
========================= */

.copy-message {
    position: fixed;

    left: 50%;

    bottom: 88px;

    transform:
        translateX(-50%);

    z-index: 100;

    padding: 10px 16px;

    border-radius: 9px;

    background: #ffffff;

    color: #0f172a;

    font-size: 14px;

    font-weight: 600;

    box-shadow:
        0 12px 35px
        rgba(
            0,
            0,
            0,
            0.35
        );
}


/* =========================
   TABLET
========================= */

@media (max-width: 900px) {

    .participants {
        grid-template-columns:
            repeat(
                auto-fit,
                minmax(
                    250px,
                    1fr
                )
            );
    }


    .participant {
        min-height: 240px;
    }
}


/* =========================
   CONTROLES TABLET
========================= */

@media (max-width: 850px) {

    .controls {
        grid-template-columns:
            repeat(
                3,
                minmax(
                    120px,
                    160px
                )
            );

        padding: 12px;
    }


    .control-button {
        width: 100%;

        height: 46px;
    }
}


/* =========================
   CELULAR
========================= */

@media (max-width: 700px) {

    #join-screen {
        max-width:
            calc(
                100% - 28px
            );

        min-height: auto;

        margin-top: 30px;

        margin-bottom: 30px;

        padding: 26px 22px;
    }


    .brand h1 {
        font-size: 28px;
    }


    .call-header {
        min-height: 60px;

        padding: 10px 14px;
    }


    .participants {
        grid-template-columns:
            1fr;

        align-content: start;

        padding: 10px;
    }


    .participant {
        min-height: 220px;

        border-radius: 12px;
    }
}


/* =========================
   CONTROLES CELULAR
========================= */

@media (max-width: 600px) {

    .controls {
        grid-template-columns:
            repeat(
                2,
                minmax(
                    0,
                    1fr
                )
            );

        gap: 8px;

        padding: 10px;
    }


    .control-button {
        width: 100%;

        height: 44px;

        padding: 0 7px;

        font-size: 12px;

        border-radius: 10px;
    }


    /*
     * O botão Sair ocupa
     * a largura inteira.
     */

    .control-button.leave {
        grid-column:
            1 / -1;
    }


    .copy-message {
        bottom: 156px;
    }
}


/* =========================
   CELULAR PEQUENO
========================= */

@media (max-width: 430px) {

    .brand-logo {
        width: 48px;

        height: 48px;
    }


    .brand h1 {
        font-size: 25px;
    }


    .online-status > span:nth-child(2),
    .online-status > span:nth-child(3) {
        display: none;
    }


    .call-brand span {
        max-width: 70vw;
    }


    .participant {
        min-height: 200px;
    }


    .room-input-group {
        flex-direction: column;
    }


    .generate-room-button {
        min-height: 43px;
    }


    .prejoin-controls {
        grid-template-columns: 1fr;
    }
}


/* =========================
   TELAS MUITO PEQUENAS
========================= */

@media (max-width: 360px) {

    #join-screen {
        max-width:
            calc(
                100% - 16px
            );

        padding: 22px 16px;
    }


    .controls {
        padding: 8px;

        gap: 7px;
    }


    .control-button {
        padding: 0 5px;

        font-size: 11px;
    }


    .participants {
        padding: 8px;
    }
}
