/* =========================================================
   GLOBAL
   ========================================================= */

* {
    box-sizing: border-box;
}

:root {
    --maroon: #800000;
    --dark-maroon: #510400;
    --light-maroon: #a64b4b;
    --maroon-light-bg: #f8eeee;
    --maroon-border: #d9aaaa;
    --page-background: #f5f2f2;
    --card-background: #ffffff;
    --text-primary: #2f2f2f;
    --text-secondary: #666666;
    --text-muted: #777777;
    --border-color: #d7d7d7;
    --success: #267326;
    --error: #b00020;
    --shadow: 0 6px 24px rgba(81, 4, 0, 0.12);
    --small-shadow: 0 2px 8px rgba(81, 4, 0, 0.08);
}

body {
    margin: 0;
    padding: 24px;
    font-family: Arial, sans-serif;
    background: var(--page-background);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}


/* =========================================================
   MAIN CONTAINER
   ========================================================= */

.container {
    width: 100%;
    max-width: 760px;
    background: var(--card-background);
    padding: 32px;
    border-radius: 14px;
    box-shadow: var(--shadow);
}


/* =========================================================
   HEADINGS
   ========================================================= */

h1 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 25px;
    color: var(--dark-maroon);
}

h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--dark-maroon);
}

h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--dark-maroon);
}

h4 {
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--maroon);
}


/* =========================================================
   TEXT
   ========================================================= */

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 14px;
    line-height: 1.5;
}


/* =========================================================
   FORMS
   ========================================================= */

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-primary);
}

input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    color: var(--text-primary);
    background: #ffffff;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

input::placeholder {
    color: #999999;
}

input:focus {
    outline: none;
    border-color: var(--maroon);
    box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.10);
}


/* =========================================================
   BUTTONS
   ========================================================= */

button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background: var(--maroon);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.1s ease,
        box-shadow 0.2s ease;
}

button:hover {
    background: var(--dark-maroon);
    box-shadow: 0 3px 8px rgba(81, 4, 0, 0.18);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    background: #aaa;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}


/* =========================================================
   PRIMARY LOGIN BUTTON
   ========================================================= */

#loginForm button[type="submit"] {
    background: var(--dark-maroon);
}

#loginForm button[type="submit"]:hover {
    background: #3d0300;
}


/* =========================================================
   CREATE ACCOUNT BUTTON
   ========================================================= */

/*
   The registration screen's main action uses a lighter
   maroon to distinguish it from the Login action.
*/

#registerForm button[type="submit"] {
    background: var(--light-maroon);
}

#registerForm button[type="submit"]:hover {
    background: var(--maroon);
}


/* =========================================================
   SECONDARY BUTTON
   ========================================================= */

.secondary-button {
    margin-top: 10px;
    background: #6f5553;
}

.secondary-button:hover {
    background: #563e3c;
}


/* =========================================================
   LINK BUTTONS
   ========================================================= */

.link-button {
    background: none;
    color: var(--maroon);
    padding: 8px 0;
    margin-top: 8px;
    box-shadow: none;
}

.link-button:hover {
    background: none;
    color: var(--dark-maroon);
    box-shadow: none;
    text-decoration: underline;
}


/* =========================================================
   MESSAGES
   ========================================================= */

.message {
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    min-height: 20px;
    line-height: 1.4;
}

.success {
    color: var(--success);
}

.error {
    color: var(--error);
}


/* =========================================================
   HIDDEN
   ========================================================= */

.hidden {
    display: none !important;
}


/* =========================================================
   OTP
   ========================================================= */

.otp-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.otp-input {
    text-align: center;
    letter-spacing: 8px;
    font-size: 22px;
    font-weight: bold;
    color: var(--dark-maroon);
}

.resend-section {
    text-align: center;
    margin-top: 15px;
}

.resend-section p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.resend-button {
    width: auto;
    margin-top: 5px;
}


/* =========================================================
   APPLICATION HEADER
   ========================================================= */

.app-header {
    margin-bottom: 25px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--maroon-border);
}

.app-header h2 {
    margin-bottom: 15px;
}


/* =========================================================
   LOGGED-IN USER
   ========================================================= */

.user-info {
    text-align: center;
    margin-bottom: 5px;
    padding: 12px;
    background: var(--maroon-light-bg);
    border: 1px solid var(--maroon-border);
    border-radius: 8px;
}

.user-info p {
    margin: 5px 0;
    color: var(--text-secondary);
}

#loggedInUserName {
    color: var(--dark-maroon);
    font-weight: bold;
    font-size: 16px;
}


/* =========================================================
   APPLICATION SECTIONS
   ========================================================= */

.app-section {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #e2d8d8;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: var(--small-shadow);
}

.app-section > h3 {
    border-left: 4px solid var(--maroon);
    padding-left: 10px;
}


/* =========================================================
   SECTION HEADER
   ========================================================= */

.section-header {
    margin-bottom: 10px;
}


/* =========================================================
   SEARCH RESULT
   ========================================================= */

.search-result {
    margin-top: 18px;
    padding: 16px;
    background: var(--maroon-light-bg);
    border: 1px solid var(--maroon-border);
    border-radius: 8px;
}

.search-result h4 {
    margin-bottom: 12px;
}

.search-result p {
    margin: 8px 0;
    font-size: 14px;
}

.search-result strong {
    color: var(--dark-maroon);
}


/* =========================================================
   CONVERSATION INFO
   ========================================================= */

.conversation-info {
    padding: 10px 12px;
    margin-top: 10px;
    background: #faf6f6;
    border-left: 4px solid var(--maroon);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 14px;
}


/* =========================================================
   CHAT
   ========================================================= */

.chat-messages {
    width: 100%;
    min-height: 220px;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 15px;
    margin-bottom: 15px;
    padding: 14px;
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}


/* =========================================================
   CHAT MESSAGE BASE
   ========================================================= */

.chat-message {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 6px;
}

.chat-message:last-child {
    margin-bottom: 0;
}

.chat-message-text {
    margin-bottom: 5px;
    word-wrap: break-word;
}


/* =========================================================
   RECEIVED MESSAGE
   ========================================================= */

.chat-message.received {
    background: #eeeeee;
    border-left: 3px solid #999999;
}

.chat-message.received .chat-message-text {
    color: var(--text-primary);
}

.chat-message.received .chat-message-time {
    color: var(--text-muted);
}


/* =========================================================
   SENT MESSAGE
   ========================================================= */

.chat-message.sent {
    background: var(--maroon);
    border-left: 3px solid var(--dark-maroon);
}

.chat-message.sent .chat-message-text {
    color: #ffffff;
}

.chat-message.sent .chat-message-time {
    color: #ead6d6;
}


/* =========================================================
   CHAT TIME
   ========================================================= */

.chat-message-time {
    font-size: 11px;
    text-align: right;
}


/* =========================================================
   CHAT FORM
   ========================================================= */

#chatMessageForm {
    margin-top: 10px;
}


/* =========================================================
   VIDEO CALL
   ========================================================= */

.call-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.call-actions button {
    flex: 1 1 180px;
    width: auto;
    margin: 0;
}

.call-media {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.video-panel {
    min-width: 0;
    padding: 12px;
    background: #faf6f6;
    border: 1px solid var(--maroon-border);
    border-radius: 8px;
}

.video-panel h4 {
    margin-bottom: 10px;
    text-align: center;
}

video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #1b1b1b;
    border-radius: 6px;
    border: 1px solid #cfcfcf;
}


/* =========================================================
   DYNAMIC CAMERA / MICROPHONE CONTROLS
   ========================================================= */

.call-media-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.call-media-controls button {
    flex: 1;
    width: auto;
    margin: 0;
}


/* =========================================================
   ACCOUNT ACTIONS
   ========================================================= */

.account-actions {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.account-actions button {
    flex: 1;
    margin: 0;
}

.account-actions .secondary-button {
    margin-top: 0;
}


/* =========================================================
   APP MESSAGE
   ========================================================= */

#appMessage {
    margin-top: 20px;
}


/* =========================================================
   SCROLLBAR
   ========================================================= */

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1eeee;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #b88d8d;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--maroon);
}


/* =========================================================
   RESPONSIVE DESIGN
   ========================================================= */

@media (max-width: 700px) {

    body {
        padding: 12px;
        align-items: flex-start;
    }

    .container {
        max-width: 100%;
        margin-top: 12px;
        padding: 22px 18px;
        border-radius: 10px;
    }

    .call-media {
        grid-template-columns: 1fr;
    }

    .account-actions {
        flex-direction: column;
    }

    .account-actions .secondary-button {
        margin-top: 0;
    }
}


@media (max-width: 480px) {

    body {
        padding: 8px;
    }

    .container {
        padding: 20px 15px;
        box-shadow: 0 3px 14px rgba(81, 4, 0, 0.10);
    }

    .app-section {
        padding: 15px;
    }

    .call-actions {
        flex-direction: column;
    }

    .call-actions button {
        flex: none;
        width: 100%;
    }

    .call-media-controls {
        flex-direction: column;
    }

    .call-media-controls button {
        width: 100%;
    }

    .otp-input {
        letter-spacing: 6px;
    }
}