:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --secondary: #3f37c9;
    --accent: #4895ef;
    --danger: #f72585;
    --success: #4cc9f0;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --light-gray: #e9ecef;
    --border-radius: 12px;
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: #f5f7fb;
    color: var(--dark);
    line-height: 1.2;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    margin-bottom: 20px;
}

/* Initially hide header action buttons that should only appear after joining */
.app-header .header-actions.initially-hidden {
    display: none !important;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background-color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo a {
    text-decoration: none;
    color: var(--primary) !important;
}

.header-actions {
    display: flex;
    gap: 15px;
}

/* Main Layout */
.app-layout {
    display: flex;
    gap: 20px;
}

/* Scrollable Containers */
.scrollable {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--light-gray) var(--light);
}

.scrollable::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.scrollable::-webkit-scrollbar-track {
    background: var(--light);
    border-radius: 3px;
}

.scrollable::-webkit-scrollbar-thumb {
    background-color: var(--light-gray);
    border-radius: 3px;
}

/* Members Sidebar */
.sidebar {
    width: 300px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.members-count {
    font-size: 14px;
    color: var(--gray);
}

.search-bar {
    position: relative;
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border: 1px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(72, 149, 239, 0.2);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.members-list {
    flex: 1;
    min-height: 200px;
    max-height: 60vh;
    padding-right: 5px;
}

/* Member Items */
.member-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--light-gray);
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--primary);
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 600;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
}

.member-you {
    font-size: 12px;
    background-color: var(--light-gray);
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}

.member-status {
    font-size: 13px;
    color: var(--gray);
    display: flex;
    align-items: center;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-online {
    background-color: var(--success);
}

.status-speaking {
    background-color: var(--accent);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title {
    font-size: 18px;
    font-weight: 600;
}

.chat-actions {
    display: flex;
    gap: 10px;
}

/* Call Controls */
.combined-call-controls {
    background-color: #e6f0ff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--light-gray);
}

.call-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.call-status {
    width: 10px;
    height: 10px;
    background-color: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.call-controls {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center; /* Ensure icon and text are centered in button */
    gap: 6px;
    transition: var(--transition);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    font-size: 16px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--light-gray);
    color: var(--dark);
}

.btn-outline:hover {
    background-color: var(--light);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #e5177b;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    min-height: 18rem;
    max-height: 60vh;
    padding: 20px;
    padding-right: 5px;
}

.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 400px;
    padding: 20px;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--primary);
}

.welcome-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.welcome-text {
    color: var(--gray);
    margin-bottom: 20px;
}

/* Message Styles */
.message {
    display: flex;
    margin-bottom: 16px;
    max-width: 98%;
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--light-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    margin-top: 4px;
}

.message.received .message-avatar {
    margin-right: 12px;
}

.message.sent .message-avatar {
    margin-left: 12px;
    background-color: var(--accent);
    color: white;
}

.message-content {
    display: flex;
    flex-direction: column;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.message.received .message-bubble {
    background-color: #BBDEFB;
    border: 1px solid var(--light-gray);
    border-bottom-left-radius: 4px;
}

.message.sent .message-bubble {
    background-color: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-info {
    font-size: 12px;
    color: var(--gray);
    margin: 4px 8px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
}

.file-attachment {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.message.received .file-attachment {
    background-color: var(--light);
}

.file-attachment:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.file-icon {
    margin-right: 8px;
    font-size: 18px;
}

.audio-message {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    cursor: pointer;
}

.message.received .audio-message {
    background-color: var(--light);
}

.audio-icon {
    margin-right: 8px;
    font-size: 18px;
}

.audio-duration {
    font-size: 13px;
}

/* Chat Input */
.chat-input {
    padding: 16px;
    border-top: 1px solid var(--light-gray);
    background-color: white;
}

.message-input-container {
    display: flex;
    align-items: center;
    background-color: var(--light);
    border-radius: 24px;
    padding: 8px 16px;
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-size: 15px;
    resize: none;
    max-height: 120px;
}

.message-input:focus {
    outline: none;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray);
    transition: var(--transition);
}

.action-btn:hover {
    background-color: var(--light-gray);
    color: var(--dark);
}

.send-btn {
    background-color: var(--primary);
    color: white;
}

.send-btn:hover {
    background-color: var(--primary-dark);
}

/* Members Drawer (Mobile) */
.members-drawer {
    position: fixed;
    top: -100vh;
    left: 0;
    right: 0;
    height: 100vh;
    background: white;
    z-index: 90;
    padding: 80px 20px 20px;
    transition: transform 0.3s ease;
    overflow-y: auto;
    display: none;
}

.members-drawer.open {
    transform: translateY(100vh);
}

.drawer-handle {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background-color: var(--light-gray);
    border-radius: 2px;
    cursor: pointer;
}

.close-drawer {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray);
}

.show-members-btn {
    display: none;
}

/* Responsive Design */
@media (max-width: 992px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        margin-bottom: 20px;
    }

    .members-list {
        max-height: 300px;
    }
}

@media (max-width: 768px) {
    .container {
       /* padding: 10px;*/
    }

    .chat-header, .combined-call-controls {
        padding: 12px 15px;
    }

    .chat-messages {
        padding: 15px;
        max-height: 45vh;
    }

    .message {
        max-width: 100%;
    }

    #invite-link-section label{
        font-size: 0.80rem !important;
    }

    #invite-link-input{
        font-size: 0.80rem !important;
        padding: 6px 10px !important;
    }

    .btn-sm {
        padding: 4px 8px;
        font-size: 0.80rem;
    }

    .sidebar {
        display: none;
    }

    .members-drawer {
        display: block;
    }

    .show-members-btn {
        border: none;
        font-size: 1.30rem;
        display: block;
        background: none;
    }

    .members-drawer .members-list {
        max-height: calc(100vh - 160px);
    }
}

@media (max-width: 576px) {
    .header-actions {
        gap: 8px;
    }

    .call-controls {
        gap: 6px;
    }

    .message {
        max-width: 100%;
    }

    .message-bubble {
        padding: 10px 14px;
    }

    .chat-input {
        padding: 12px;
    }

    .message-input-container {
        padding: 6px 12px;
    }

    .action-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

/* --- NEW STYLES --- */

/* Join Section */
.join-section {
    background-color: white;
    padding: 25px 30px; /* Increased padding a bit */
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 25px; /* Increased margin */
    max-width: 480px; /* Adjusted max-width */
    margin-left: auto;
    margin-right: auto;
}

.join-section h2 {
    text-align: center;
    margin-bottom: 25px; /* Increased margin */
    color: var(--primary);
    font-size: 24px; /* Slightly larger title */
}

.join-section .form-group {
    margin-bottom: 18px; /* Increased margin */
}

.join-section .form-group label {
    display: block;
    font-weight: 600; /* Slightly bolder label */
    margin-bottom: 8px; /* Increased space below label */
    color: var(--dark);
    font-size: 15px;
}

.join-section .form-group input[type="text"] {
    width: 100%;
    padding: 12px 15px; /* Adjusted padding */
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    font-size: 15px;
    transition: var(--transition);
}

.join-section .form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(72, 149, 239, 0.3); /* Adjusted shadow */
}

.join-section .btn-join {
    width: 100%;
    padding: 12px; /* Increased padding for better click target */
    font-size: 16px;
    margin-top: 15px; 
    font-weight: 600;
}

/* Option Section (Class = Option) */
.Option { 
    margin-top: 25px; /* Increased margin */
    padding-top: 20px; /* Increased padding */
    border-top: 1px solid var(--light-gray);
}

.Option h4 {
    font-size: 17px; /* Slightly larger heading */
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 15px; /* Increased margin */
}

.Option .checkbox-option {
    display: flex;
    align-items: center;
    padding: 8px 0; /* Add some padding for better spacing */
}

.Option .checkbox-option input[type="checkbox"] {
    margin-right: 12px; /* Increased space */
    width: 18px; 
    height: 18px; 
    accent-color: var(--primary); 
    cursor: pointer;
    vertical-align: middle; /* Align checkbox better with text */
}

.Option .checkbox-option label {
    font-weight: 500; /* Slightly bolder label */
    color: var(--gray);
    cursor: pointer;
    font-size: 15px;
    flex-grow: 1; /* Allow label to take available space */
}

/* --- NEW STYLES (for client.js integration) --- */

.hidden {
    display: none !important;
}

/* Join Section - minor adjustments if needed based on new input IDs, but existing styles should mostly cover it */
.join-section #user-name-input,
.join-section #room-id-input {
    /* Existing .join-section .form-group input[type="text"] styles should apply */
}

/* Call Chat Section - general container */
#call-chat-section {
    /* This is mostly a logical container, specific contents are styled below or already styled */
}

/* Invite Link Section */
#invite-link-section {
    padding: 10px 8px; /* Adjusted padding */
    background-color: #f0f4f8;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
    gap: 8px; /* Adjusted gap */
    margin-bottom: 20px; /* Space below */
    border-radius: var(--border-radius) var(--border-radius) 0 0; /* Rounded top corners if it's the first visible item in call section */
}

#invite-link-section label {
    font-weight: 600; /* Bolder label */
    color: var(--dark);
    font-size: 15px; /* Consistent font size */
    flex-shrink: 0; /* Prevent label from shrinking */
}

#invite-link-input {
    flex-grow: 1;
    padding: 10px 12px; /* Adjusted padding */
    border: 1px solid var(--light-gray);
    border-radius: 8px; /* Consistent border-radius */
    background-color: var(--light);
    font-size: 14px;
    color: var(--gray);
}

#copy-invite-link-button {
    flex-shrink: 0;
    /* Uses existing .btn .btn-outline .btn-sm styles */
}

/* Participant List (if client.js adds simple <li>) */
#participant-list li, #participant-list-mobile li {
    padding: 10px 12px;
    border-bottom: 1px solid var(--light-gray);
    font-size: 14px;
    color: var(--dark);
}
#participant-list li:last-child, #participant-list-mobile li:last-child {
    border-bottom: none;
}
.member-item-placeholder {
    color: var(--gray);
    font-style: italic;
    text-align: center;
}


/* Mute Button Muted State */
#mute-button.muted {
    background-color: var(--light-gray); /* Example: different background when muted */
    color: var(--danger); /* Example: red icon/text when muted */
}
#mute-button.muted .btn-icon {
    /* Custom icon style for muted state if needed */
}


/* Recording Indicator and Stop Button */
#recording-indicator {
    display: flex; /* Will be made visible by JS by removing .hidden */
    align-items: center;
    color: var(--danger);
    margin-left: 10px;
    font-size: 13px;
    font-weight: 500;
}
#recording-indicator .record-dot {
    width: 9px; /* Slightly larger dot */
    height: 9px;
    background-color: var(--danger);
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 1.2s infinite; /* Use existing pulse or a dedicated one */
}
#stop-recording-button {
    margin-left: 10px;
    padding: 4px 10px; /* Adjusted padding for better fit */
    font-size: 12px;
    line-height: 1; /* Ensure text fits */
    /* Uses .btn .btn-danger .btn-sm (or could be custom) */
}

/* Action buttons in chat input - ensure they are buttons */
.input-actions .action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0; /* Remove default button padding if icons are precise */
    /* Existing .action-btn styles for size, color, hover should apply */
}

/* Current Room ID display */
#current-room-id-container {
    font-size: 13px; /* Smaller font for room ID */
    color: var(--gray);
    margin-left: 8px;
    font-weight: normal;
}
#current-room-id {
    font-weight: 500; /* Slightly bolder for the ID itself */
    color: var(--primary);
}

/* Adjust chat welcome message to ensure it's centered if it's the only child */
#chat-box:has(.welcome-message:only-child) {
    display: flex; /* If only welcome message, center it */
    align-items: center;
    justify-content: center;
}

/* --- Add/Verify these in style.css --- */

/* Ensure message structure is correct for sent/received avatars */
.message.sent {
    flex-direction: row-reverse; /* This moves the avatar to the right */
}
.message.sent .message-avatar {
    margin-left: 12px; /* Spacing for sent avatar */
    margin-right: 0;
}
.message.received .message-avatar {
    margin-right: 12px; /* Spacing for received avatar */
    margin-left: 0;
}

/* Custom Audio Message Styling (to match the image for sent messages) */
.message.sent .message-bubble .audio-message {
    background-color: var(--primary); /* Blue background from your image */
    color: white;
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 18px; /* Match bubble radius */
    min-width: 100px; /* Ensure it has some width */
    cursor: default; /* It's not interactive in the image, just displays info */
}

.message.received .message-bubble .audio-message { /* Style for received audio if different */
    background-color: var(--light); /* Example: lighter background for received */
    color: var(--dark);
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 18px;
    min-width: 100px;
    cursor: pointer; /* If received ones are playable via custom button */
}


.audio-message .audio-icon {
    font-size: 18px; /* Adjust as per your image */
    margin-right: 10px;
}

.audio-message .audio-duration-display {
    font-size: 13px; /* Adjust as per your image */
    font-weight: 500;
}

.audio-message .audio-play-button {
    cursor: pointer;
    font-size: 18px; /* Adjust icon size */
    margin-right: 8px;
    /* Add more styling for the play button if it's more than just an emoji */
}

/* Style for the chat room title to make it look like "Design Team Room" */
#chat-room-title {
    font-size: 18px;
    font-weight: 600;
    /* The span for current-room-id was removed for direct title update */
}

#members-online-count {
    font-size: 14px;
    color: var(--gray);
}

#call-status-text {
    font-size: small;
}

/* Ensure the welcome message is hidden properly */
#chat-welcome-message.hidden {
    display: none !important;
}

/* --- New Notification Box Styles --- */
.room-notification-global {
    position: fixed; /* Fixed position relative to the viewport */
    bottom: 20px;    /* Position at the bottom */
    left: 50%;       /* Center horizontally */
    transform: translateX(-50%); /* Fine-tune centering */
    z-index: 1000;   /* Ensure it's above most other content */
    display: flex;   /* Use flex for potentially multiple notifications later */
    flex-direction: column;
    align-items: center; /* Center notification items if they are narrower */
    gap: 10px;
}

.notification-item {
    padding: 12px 20px;
    border-radius: 8px;
    color: #333; /* Darker text for better readability */
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    opacity: 0; /* Start hidden for animation */
    transform: translateY(20px); /* Start off-screen for animation */
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    min-width: 250px; /* Minimum width */
    text-align: center;
}

.notification-item.show {
    opacity: 1;
    transform: translateY(0);
}

.notification-item.join {
    background-color: #e0f2fe; /* Soft blue (e.g., light sky blue) */
    border-left: 4px solid #3b82f6; /* Blue accent border */
    color: #0c4a6e; /* Darker blue text */
}

.notification-item.leave {
    background-color: #fef9c3; /* Soft yellow (e.g., pale yellow) */
    border-left: 4px solid #facc15; /* Yellow accent border */
    color: #713f12; /* Darker yellow/brown text */
}

.notification-item strong { /* Style for the username part */
    font-weight: 700;
}
