* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #121212;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* ========================================= */
/* TELA DE LOGIN                             */
/* ========================================= */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    background-color: #121212;
}

.login-box {
    background-color: #1e1e1e;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #333;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    width: 90%;
    max-width: 400px;
}

.login-box h2 {
    color: #4fa3f7;
    margin-bottom: 10px;
}

.login-box p {
    color: #aaa;
    margin-bottom: 25px;
    font-size: 14px;
}

.password-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
}

.password-wrapper input {
    width: 100%;
    padding: 12px;
    padding-right: 45px;
    font-size: 16px;
    margin-bottom: 0;
}

#togglePasswordBtn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #aaa;
    font-size: 18px;
    padding: 0;
    cursor: pointer;
    width: auto;
}

#togglePasswordBtn:hover {
    background: none;
    color: #fff;
}

.login-box button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

#loginError {
    color: #f44336;
    margin-top: 15px;
    margin-bottom: 0;
    font-size: 13px;
    font-weight: bold;
}

/* ========================================= */
/* APP PRINCIPAL                             */
/* ========================================= */
#app-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 15px;
    width: 100%;
    background-color: #1e1e1e;
    border-bottom: 1px solid #333;
}

h1 {
    margin-bottom: 10px;
    font-size: 24px;
    color: #4fa3f7;
}

#room-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

input, button {
    padding: 8px 12px;
    border-radius: 5px;
    border: none;
    font-size: 14px;
}

input {
    width: 200px;
    background-color: #2c2c2c;
    color: white;
    border: 1px solid #444;
}

input:focus {
    outline: none;
    border-color: #4fa3f7;
}

.room-input-group {
    display: flex;
    align-items: center;
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-radius: 5px;
    overflow: hidden;
}

.room-input-group input {
    border: none;
    border-radius: 0;
    margin: 0;
    background: transparent;
    width: 160px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 1px;
}

.room-input-group input:focus {
    outline: none;
}

.room-input-group:focus-within {
    border-color: #4fa3f7;
}

.icon-btn {
    background: transparent;
    color: #ccc;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 16px;
    border-radius: 0;
    border-left: 1px solid #444;
}

.icon-btn:hover {
    background-color: #444;
    color: #fff;
}

button {
    background-color: #4fa3f7;
    color: #121212;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #3b8ce0;
}

button.danger {
    background-color: #f44336;
    color: white;
}

button.danger:hover {
    background-color: #d32f2f;
}

#currentRoom {
    font-size: 13px;
    color: #aaa;
    margin-top: 5px;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    flex-grow: 1;
    padding: 15px;
}

/* ========================================= */
/* GRID DE VÍDEOS (Lado a Lado + Chat)       */
/* ========================================= */
#video-grid {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 15px;
    margin-bottom: 20px;
    align-items: stretch;
}

.video-wrapper {
    flex: 1;
    position: relative;
    background-color: #000;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16/9;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 1px solid #333;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover; 
}

.video-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.6);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    z-index: 2;
}

#background-options {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 6px 10px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #ccc;
    z-index: 2;
}

#bgSelect {
    background: #333;
    color: white;
    border: 1px solid #555;
    font-size: 12px;
    padding: 3px;
    border-radius: 3px;
    cursor: pointer;
}

/* ========================================= */
/* CONTROLES E CHAT                          */
/* ========================================= */
#action-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

#chat-panel {
    width: 320px;
    flex-shrink: 0; /* Impede que o chat seja esmagado pelos vídeos */
    background-color: #1e1e1e;
    display: flex;
    flex-direction: column;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background-color: #121212;
    border-bottom: 1px solid #333;
    border-radius: 10px 10px 0 0;
}

#chat-header h3 {
    font-size: 16px;
    color: #4fa3f7;
    margin: 0;
}

#closeChatBtn {
    background: transparent;
    color: white;
    padding: 5px 10px;
    font-size: 16px;
}

#closeChatBtn:hover {
    background: #f44336;
}

#chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg.local {
    align-self: flex-end;
    background-color: #4fa3f7;
    color: #121212;
    border-bottom-right-radius: 2px;
}

.chat-msg.remote {
    align-self: flex-start;
    background-color: #333;
    color: white;
    border: 1px solid #555;
    border-bottom-left-radius: 2px;
}

#chat-input-area {
    display: flex;
    padding: 12px;
    background-color: #121212;
    border-top: 1px solid #333;
    border-radius: 0 0 10px 10px;
    gap: 8px;
}

#chatInput {
    flex-grow: 1;
    width: auto;
}

#sendMsgBtn {
    padding: 8px 15px;
}

#attachBtn {
    padding: 8px 10px;
    background-color: #333;
    color: white;
    border-radius: 5px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#attachBtn:hover {
    background-color: #555;
}

.chat-msg.system {
    align-self: center;
    background-color: transparent;
    color: #888;
    font-size: 11px;
    font-style: italic;
    border: none;
    padding: 2px;
    margin: 5px 0;
}

.chat-msg a {
    text-decoration: none;
}

.chat-msg a:hover {
    text-decoration: underline !important;
}

footer {
    width: 100%;
    text-align: center;
    padding: 15px;
    font-size: 12px;
    color: #666;
    background-color: #121212;
    margin-top: auto;
    border-top: 1px solid #222;
}

/* ========================================= */
/* OTIMIZAÇÕES PARA CELULAR                  */
/* ========================================= */
@media (max-width: 768px) {
    /* Vídeos Empilhados */
    #video-grid {
        flex-direction: column;
    }
    
    .video-wrapper {
        width: 100%;
        border-radius: 8px;
    }

    /* Ajuste do Header e Controles */
    #room-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .room-input-group {
        width: 100%;
    }

    .room-input-group input {
        width: 100%;
        flex-grow: 1;
    }

    /* Botões Otimizados (Grid) */
    #action-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    #action-controls button {
        width: 100%;
        padding: 12px;
    }

    #hangupBtn {
        grid-column: span 2;
    }

    .desktop-only {
        display: none !important;
    }

    /* O Chat no celular se posiciona perfeitamente ABAIXO dos vídeos */
    #chat-panel {
        width: 100%;
        height: 450px;
        margin-top: 10px;
    }
}