:root {
    --background-dark: #1e1f22;
    --background-main: #313338;
    --background-panel: #2b2d31;
    --background-input: #1e1f22;
    --background-hover: #35373c;
    --background-floating: #111214;

    --border-color: #3f4147;

    --text-primary: #f2f3f5;
    --text-secondary: #b5bac1;
    --text-muted: #949ba4;

    --brand-primary: #5865f2;
    --brand-primary-hover: #4752c4;

    --green: #23a559;
    --green-hover: #1a8f4c;

    --red: #da373c;
    --red-hover: #a1282c;

    --shadow:
        0 8px 24px rgba(0, 0, 0, 0.28);

    --small-shadow:
        0 3px 10px rgba(0, 0, 0, 0.25);

    --radius-small: 5px;
    --radius-medium: 8px;
    --radius-large: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    color: var(--text-primary);
    background: var(--background-main);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
}

.app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Top navigation */

.topbar {
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 10px 18px;
    background: var(--background-dark);
    border-bottom: 1px solid rgba(0, 0, 0, 0.35);
    box-shadow: var(--small-shadow);
}

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}

.brand-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: white;
    background: var(--brand-primary);
    border-radius: 50%;
}

.brand-text {
    min-width: 0;
}

.brand-text h1 {
    margin: 0;
    overflow: hidden;
    font-size: 16px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-text span {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 13px;
    color: var(--text-secondary);
    background: transparent;
    border-radius: var(--radius-small);
    cursor: pointer;
    transition:
        color 150ms ease,
        background 150ms ease,
        transform 100ms ease;
    gap: 7px;
}

.icon-button:hover {
    color: var(--text-primary);
    background: var(--background-hover);
}

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

.button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    font-size: 14px;
    font-weight: 800;
}

.button-label {
    font-size: 13px;
    font-weight: 600;
}

/* Main layout */

.workspace {
    display: flex;
    flex: 1;
    min-height: 0;
}

.connection-panel {
    display: flex;
    flex: 0 0 280px;
    flex-direction: column;
    justify-content: space-between;
    min-width: 240px;
    max-width: 340px;
    background: var(--background-panel);
    border-right: 1px solid rgba(0, 0, 0, 0.25);
}

.panel-section {
    overflow-y: auto;
    padding: 20px 16px;
}

.section-heading {
    margin-bottom: 18px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.form-group input {
    width: 100%;
    height: 42px;
    padding: 0 11px;
    color: var(--text-primary);
    background: var(--background-input);
    border: 1px solid transparent;
    border-radius: var(--radius-small);
    outline: none;
    transition:
        border-color 150ms ease,
        box-shadow 150ms ease;
}

.form-group input::placeholder {
    color: #70747b;
}

.form-group input:hover {
    border-color: #44474e;
}

.form-group input:focus {
    border-color: var(--brand-primary);
    box-shadow:
        0 0 0 2px rgba(88, 101, 242, 0.2);
}

.connection-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 20px;
    gap: 8px;
}

.action-button {
    min-height: 40px;
    padding: 0 14px;
    color: white;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition:
        background 150ms ease,
        opacity 150ms ease,
        transform 100ms ease;
}

.action-button:active:not(:disabled) {
    transform: translateY(1px);
}

.action-button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.primary-button {
    grid-column: 1 / -1;
    background: var(--brand-primary);
}

.primary-button:hover:not(:disabled) {
    background: var(--brand-primary-hover);
}

.secondary-button {
    background: #4e5058;
}

.secondary-button:hover:not(:disabled) {
    background: #686b74;
}

.danger-button {
    background: var(--red);
}

.danger-button:hover:not(:disabled) {
    background: var(--red-hover);
}

/* Sidebar connection status */

.connection-status {
    display: flex;
    align-items: center;
    min-height: 62px;
    padding: 12px 16px;
    background: #232428;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    gap: 10px;
}

.status-indicator {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    background: var(--text-muted);
    border-radius: 50%;
    box-shadow:
        0 0 0 3px rgba(148, 155, 164, 0.12);
}

.status-indicator.connected {
    background: var(--green);
    box-shadow:
        0 0 0 3px rgba(35, 165, 89, 0.16);
}

.status-indicator.connecting {
    background: #f0b232;
    box-shadow:
        0 0 0 3px rgba(240, 178, 50, 0.16);
}

.status-indicator.error {
    background: var(--red);
    box-shadow:
        0 0 0 3px rgba(218, 55, 60, 0.16);
}

.status-content {
    min-width: 0;
}

.status-label {
    display: block;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.status-bar {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main participant area */

.main-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--background-main);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 66px;
    padding: 10px 22px;
    background: rgba(49, 51, 56, 0.94);
    border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.channel-label {
    display: block;
    margin-bottom: 2px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.content-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.room-state {
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    color: var(--text-secondary);
    background: var(--background-panel);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    gap: 7px;
}

.room-state-dot {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
}

.participant-grid {
    display: grid;
    flex: 1;
    grid-template-columns:
        repeat(auto-fill, minmax(220px, 1fr));
    align-content: start;
    overflow-y: auto;
    padding: 20px;
    gap: 16px;
}

/*
    These styles should also apply to participant elements created
    dynamically by index.js. Adjust the selector if your JavaScript
    uses a different class name.
*/

.participant,
.participant-card {
    position: relative;
    min-height: 170px;
    overflow: hidden;
    background: #25262a;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-large);
    box-shadow:
        0 3px 10px rgba(0, 0, 0, 0.15);
    transition:
        border-color 150ms ease,
        transform 150ms ease,
        box-shadow 150ms ease;
}

.participant:hover,
.participant-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--small-shadow);
    transform: translateY(-1px);
}

.participant video,
.participant-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.empty-room-message {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    min-height: 360px;
    padding: 30px;
    color: var(--text-muted);
    text-align: center;
}

.empty-room-icon {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin-bottom: 18px;
    font-size: 32px;
    background: var(--background-panel);
    border-radius: 50%;
}

.empty-room-message h3 {
    margin: 0 0 8px;
    color: var(--text-primary);
    font-size: 18px;
}

.empty-room-message p {
    max-width: 380px;
    margin: 0;
    line-height: 1.5;
}

/* Floating tool windows */

.tool-frame-wrap,
.shared-media-wrap {
    position: fixed;
    z-index: 1000;
    display: none;
    flex-direction: column;
    width: min(620px, calc(100vw - 30px));
    height: min(620px, calc(100vh - 90px));
    min-width: 320px;
    min-height: 240px;
    overflow: hidden;
    background: var(--background-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow);
    resize: both;
}

#musicFrameWrap {
    top: 90px;
    left: 310px;
}

#giphyFrameWrap {
    top: 110px;
    left: 350px;
}

#chatFrameWrap {
    top: 130px;
    right: 30px;
    width: min(480px, calc(100vw - 30px));
}

.tool-frame-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 0 8px 0 14px;
    background: var(--background-dark);
    border-bottom: 1px solid rgba(0, 0, 0, 0.35);
    cursor: move;
    user-select: none;
}

.tool-frame-title {
    display: flex;
    align-items: center;
    min-width: 0;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    gap: 8px;
}

.tool-frame-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 800;
}

.window-close-button {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
    background: transparent;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    transition:
        color 150ms ease,
        background 150ms ease;
}

.window-close-button:hover {
    color: white;
    background: var(--red);
}

.tool-frame {
    display: block;
    flex: 1;
    width: 100%;
    min-height: 0;
    background: var(--background-main);
    border: 0;
}

/* Shared media */

.shared-media-wrap {
    top: 100px;
    left: 50%;
    width: min(760px, calc(100vw - 30px));
    height: auto;
    max-height: calc(100vh - 130px);
    transform: translateX(-50%);
    resize: both;
}

.shared-media-body {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
    padding: 14px;
    background: #17181b;
}

#sharedMediaThumb,
#sharedMediaVideo {
    display: none;
    max-width: 100%;
    max-height: calc(100vh - 220px);
    object-fit: contain;
    border-radius: var(--radius-medium);
}

#sharedMediaAudio {
    display: none;
    width: min(540px, 100%);
}

.shared-media-error {
    color: #ff7b80;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
}

.shared-gif {
    position: fixed;
    z-index: 1100;
    right: 20px;
    bottom: 20px;
    display: none;
    max-width: min(420px, calc(100vw - 40px));
    max-height: min(420px, calc(100vh - 100px));
    object-fit: contain;
    background: var(--background-floating);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow);
}

/* Scrollbars */

* {
    scrollbar-width: thin;
    scrollbar-color: #1a1b1e transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #1a1b1e;
    border: 3px solid transparent;
    border-radius: 10px;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #111214;
    border: 3px solid transparent;
    background-clip: padding-box;
}

/* Smaller screens */

@media (max-width: 760px) {
    body {
        overflow: auto;
    }

    .app-shell {
        min-height: 100%;
        height: auto;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .topbar-tools {
        width: 100%;
    }

    .icon-button {
        flex: 1;
    }

    .workspace {
        flex-direction: column;
    }

    .connection-panel {
        flex: none;
        width: 100%;
        max-width: none;
        border-right: 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    }

    .connection-status {
        display: none;
    }

    .main-content {
        min-height: 500px;
    }

    .participant-grid {
        grid-template-columns: 1fr;
    }

    .tool-frame-wrap,
    .shared-media-wrap {
        top: 75px !important;
        right: auto !important;
        left: 10px !important;
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 95px) !important;
        max-height: none;
        transform: none;
        resize: none;
    }
}
#screenShareFrameWrap {
}

.screen-share-wrap {
    min-width: 420px;
    min-height: 300px;
}

.screen-share-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.screen-share-stop-button {
    min-height: 30px;
    padding: 0 10px;
    color: white;
    background: var(--red);
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.screen-share-stop-button:hover {
    background: var(--red-hover);
}

.screen-share-body {
    position: relative;
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #111214;
}

.screen-share-video-container {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.screen-share-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.screen-share-audio {
    display: none;
}

.screen-share-empty {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 30px;
    color: var(--text-muted);
    text-align: center;
}

.screen-share-empty-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    background: var(--background-panel);
    border-radius: 50%;
    font-size: 30px;
}

.screen-share-empty h3 {
    margin: 0 0 8px;
    color: var(--text-primary);
}

.screen-share-empty p {
    max-width: 380px;
    margin: 0;
    line-height: 1.5;
}

#screenShareBtn.active {
    color: white;
    background: var(--red);
}
.room-auth-modal {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: grid;
    place-items: center;
}

.room-auth-modal[hidden] {
    display: none;
}

.room-auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.room-auth-dialog {
    position: relative;
    z-index: 1;
    width: min(420px, calc(100vw - 32px));
    background: #161b22;
    border: 1px solid #38404a;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.room-auth-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #38404a;
}

.room-auth-header h2 {
    margin: 0;
    font-size: 18px;
}

.room-auth-content {
    padding: 18px;
}

.room-auth-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid #38404a;
}

.room-auth-error {
    margin-top: 12px;
    color: #ff7272;
}
