/* Base styles for the entire application */
:root {
    --color-bg-dark: #2c2f33;
    --color-bg-panel: rgba(35, 39, 42, 0.2);
    --color-primary-blue: #7289da;
    --color-primary-blue-hover: #677bc4;
    --color-primary-blue-active: #5b6eae;
    --color-white: #ffffff;
    --color-border-pip: #4f545c;
    --color-bg-pip: #111;
    --color-bg-video-area: #1e1e1e;
    --color-bg-video: #000000;
    --shadow-base: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-pip: 0 5px 15px rgba(0, 0, 0, 0.5);
    --padding-panel-desktop: 12px 25px;
    --padding-panel-tablet: 10px 15px;
    --padding-panel-mobile: 8px 10px;
    --margin-buttons-desktop: 12px;
    --margin-buttons-mobile: 5px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-bg-dark);
    color: var(--color-white);
    /* Use dvh (dynamic viewport height) to account for dynamic browser UI on mobile,
       preventing content from being cut off by navigation bars. */
    height: 100dvh;
    overflow: hidden;
}

.app-container {
    height: 100%;
    position: relative;
}

/* Top panel with title and buttons */
.top-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--color-bg-panel);
    color: var(--color-white);
    padding: var(--padding-panel-desktop);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-base);
    z-index: 100;
}

.panel-title {
    margin: 0;
    font-size: 1.6em;
    font-weight: 500;
}

/* Styles for the buttons in the top panel */
.panel-buttons button {
    margin-left: var(--margin-buttons-desktop);
    padding: 8px 18px;
    background-color: var(--color-primary-blue);
    color: var(--color-white);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.panel-buttons button:hover {
    background-color: var(--color-primary-blue-hover);
}

.panel-buttons button:active {
    background-color: var(--color-primary-blue-active);
    transform: translateY(1px);
}

.panel-buttons button .button-icon {
    width: 2em;
    height: 2em;
    margin-right: 0.5em;
}

.panel-buttons button span {
    line-height: 1;
}

/* Main content area, stretching to the full dynamic viewport height */
.main-content-area {
    height: 100dvh;
}

/* Container for the main video stream */
.video-area {
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--color-bg-video-area);
    overflow: hidden;
    box-sizing: border-box;
}

.remote-video-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.remote-video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: var(--color-bg-video);
}

/* Local video container (picture-in-picture) */
.local-video-pip-container {
    position: absolute;
    /* Position the video at the bottom right of the screen on all devices */
    top: auto;
    right: 25px;
    bottom: 25px;
    width: 22%;
    /* Set the maximum width to 25% of the viewport */
    max-width: 25%;
    min-width: 60px;
    border: 1px solid var(--color-border-pip);
    border-radius: 8px;
    box-shadow: var(--shadow-pip);
    overflow: hidden;
    z-index: 10;
    background-color: var(--color-bg-pip);
}

.local-video-pip-container h2 {
    position: absolute;
    top: 8px;
    left: 8px;
    margin: 0;
    padding: 2px 5px;
    color: var(--color-white);
    font-size: 0.9em;
    font-weight: 500;
    z-index: 15;
    text-shadow:
        0px 0px 3px rgba(0, 0, 0, 0.7),
        0px 0px 5px rgba(0, 0, 0, 0.5);
}

.local-video-pip-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#localVideo {
    transform: scaleX(-1);
}

/* Responsive styles for tablets and smaller screens (up to 768px) */
@media (max-width: 768px) {
    .top-panel {
        padding: var(--padding-panel-tablet);
        /* Ensure top panel elements remain in a row */
        align-items: center;
        justify-content: space-between;
    }

    .panel-title {
        font-size: 1.4em;
    }

    .panel-buttons {
        margin-top: 0;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .panel-buttons button {
        margin: var(--margin-buttons-mobile);
        padding: 6px 12px;
        font-size: 0.85em;
    }

    .local-video-pip-container {
        /* Adjust the size and position for mobile devices */
        top: auto;
        right: 15px;
        bottom: 15px;
        width: 25%;
        max-width: 25%;
        min-width: unset;
    }

    .local-video-pip-container h2 {
        font-size: 0.8em;
    }
}

/* Responsive styles for extra small devices (up to 480px) */
@media (max-width: 480px) {
    .top-panel {
        padding: var(--padding-panel-mobile);
    }

    .panel-buttons button {
        padding: 5px 10px;
        font-size: 0.8em;
        margin: 4px;
    }

    .local-video-pip-container {
        right: 10px;
        bottom: 10px;
        width: 25%;
        max-width: 25%;
    }
}
