/* Simple, functional CSS that works */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    margin: 0;
    padding: 0;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 60px; /* Reduced padding for smaller header */
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem; /* Reduced padding */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
    height: 60px; /* Smaller fixed height */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    padding: 0;
}

.logo {
    font-size: 1.3rem; /* Slightly smaller */
    font-weight: bold;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 0.4rem; /* Smaller gap */
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    line-height: 1;
}

.logo:hover {
    color: #764ba2;
}

.menu-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.logo.active .menu-arrow {
    transform: rotate(180deg);
}

.logo-container {
    position: relative;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 280px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 0 0 15px 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.dropdown-menu.active {
    max-height: 400px;
    opacity: 1;
}

.menu-content {
    padding: 1rem;
}

.menu-section {
    margin-bottom: 1rem;
}

.menu-section:last-child {
    margin-bottom: 0;
}

.menu-section h3 {
    color: #667eea;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    padding-bottom: 0.3rem;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.3rem;
}

.menu-item:hover {
    background: rgba(102, 126, 234, 0.1);
}

.menu-item i {
    color: #667eea;
    width: 16px;
    text-align: center;
}

.menu-item span {
    color: #333;
}

.menu-select {
    flex: 1;
    max-width: 140px;
    padding: 0.4rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: white;
    color: #333;
    font-size: 0.85rem;
}

.menu-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.room-code-menu {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    user-select: all;
    font-size: 0.9rem;
}

.room-code-menu:hover {
    background: rgba(102, 126, 234, 0.2);
}

/* Improved Toggle Switch */
.toggle-switch {
    position: relative;
    display: flex;
    align-items: center;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 60px;
    height: 28px;
    background: #ccc;
    border-radius: 14px;
    transition: background 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-text {
    font-size: 0.7rem;
    font-weight: bold;
    color: #666;
    position: absolute;
    transition: opacity 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: #667eea;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(32px);
}

.toggle-switch input:checked + .toggle-slider .toggle-text {
    color: white;
}

.toggle-switch input:checked + .toggle-slider .toggle-text::after {
    content: 'ON';
}

.toggle-switch input:not(:checked) + .toggle-slider .toggle-text::after {
    content: 'OFF';
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title {
    display: flex;
    align-items: center;
}

.header-title h1 {
    font-size: 1.4rem;
    font-weight: bold;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.3rem; /* Smaller gap */
    font-size: 0.8rem; /* Smaller font */
    color: #666;
    height: 100%;
}

.status-indicator {
    display: flex;
    align-items: center;
    height: 100%;
}

.status-indicator i {
    font-size: 0.6rem; /* Smaller icon */
    transition: color 0.3s ease;
}

.status-indicator.connected i {
    color: #28a745;
    animation: pulse 2s infinite;
}

.status-indicator.disconnected i {
    color: #dc3545;
    animation: blink 1s infinite;
}

.status-indicator.connecting i {
    color: #ffc107;
    animation: spin 1s linear infinite;
}

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

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.status-text {
    font-size: 0.8rem;
    font-weight: 500;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.room-info-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.room-label {
    color: #666;
    font-weight: 500;
}

.room-code {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: all;
}

.room-code:hover {
    background: rgba(102, 126, 234, 0.2);
}

.btn-icon {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: none;
    padding: 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.btn-icon:hover {
    background: #667eea;
    color: white;
}

.btn-icon.btn-danger {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
}

.btn-icon.btn-danger:hover {
    background: #ff6b6b;
    color: white;
}

.btn-text {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 500;
    height: 32px;
}

.btn-text:hover {
    background: #667eea;
    color: white;
}

.btn-text.btn-danger {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
}

.btn-text.btn-danger:hover {
    background: #ff6b6b;
    color: white;
}

.room-code-large {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.room-code-large:hover {
    background: rgba(102, 126, 234, 0.2);
}

/* Main content */
.main-content {
    flex: 1;
    padding: 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex child to shrink */
    height: calc(100vh - 80px); /* Account for fixed header */
}

/* Room section */
.room-section {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.room-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.room-card h2 {
    margin-bottom: 2rem;
    color: #333;
}

.room-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

.divider span {
    padding: 0 1rem;
    color: #666;
    font-size: 0.9rem;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-create {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(86, 171, 47, 0.3);
}

.btn-secondary {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 2px solid #667eea;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.3);
}

/* Chat section */
.chat-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Important for proper scrolling */
    height: 100%; /* Use full available height */
}

.chat-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
    min-height: 0; /* Important for scrolling */
}

.chat-input-section {
    padding: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    flex-shrink: 0; /* Prevent input section from shrinking */
}

.chat-input-section .input-group {
    display: flex;
    gap: 0.5rem;
}

.chat-input-section input {
    flex: 1;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.chat-input-section input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
}

.message.sending {
    opacity: 0.7;
    background: rgba(102, 126, 234, 0.1);
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.ai {
    align-self: flex-start;
    background: rgba(102, 126, 234, 0.1);
    color: #333;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.system-message {
    align-self: center;
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
    border: 1px solid rgba(108, 117, 125, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    margin: 0.5rem 0;
    max-width: 60%;
}

.message-bubble {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.sender-name {
    color: #667eea;
    font-size: 0.9rem;
    font-weight: 600;
}

.message-time {
    color: #888;
    font-size: 0.7rem;
    font-weight: normal;
}

.message-content {
    line-height: 1.4;
    color: #333;
}

.message-content a {
    color: #667eea;
    text-decoration: underline;
}

.user-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.user-message .sender-name,
.user-message .message-time {
    color: rgba(255, 255, 255, 0.9);
}

.user-message .message-content {
    color: white;
}

.assistant-message {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

/* System message styles for prompt visibility changes */
.system-message {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 8px auto;
    max-width: 70%;
    text-align: center;
    font-size: 0.85rem;
    color: #856404;
}

.system-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.system-content i {
    color: #ffc107;
}

/* Hidden notification styles */
.hidden-notification {
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-left: 4px solid #ff9800;
    color: #e65100;
    font-style: italic;
}

/* Visibility change notification styles */
.visibility-change {
    background: rgba(16, 163, 127, 0.1);
    border: 1px solid rgba(16, 163, 127, 0.3);
    animation: pulse 2s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Hidden from group message styles */
.hidden-from-group {
    background: linear-gradient(135deg, #9c27b0 0%, #673ab7 100%);
    color: white;
    border: 2px solid #7b1fa2;
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.3);
}

.hidden-from-group .sender-name,
.hidden-from-group .message-content {
    color: white;
}

.hidden-indicator {
    font-size: 0.75rem;
    font-weight: normal;
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hidden-indicator i {
    font-size: 0.7rem;
    opacity: 0.8;
}

.sending {
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.4; }
}

/* Mobile message styling */
@media (max-width: 768px) {
    .message-bubble {
        max-width: 95%;
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    
    .message-header {
        margin-bottom: 0.2rem;
    }
    
    .sender-name {
        font-size: 0.8rem;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .header {
        padding: 0.4rem 0.75rem;
        position: fixed; /* Keep fixed positioning on mobile */
        height: 55px; /* Smaller on mobile */
    }
    
    .app-container {
        padding-top: 55px; /* Match mobile header height */
    }
    
    .logo {
        font-size: 1.1rem;
    }
    
    .connection-status {
        font-size: 0.75rem;
    }
    
    .dropdown-menu {
        min-width: 260px;
        border-radius: 0 0 12px 12px;
        left: -10px;
    }
    
    .menu-content {
        padding: 0.8rem;
    }
    
    .menu-section {
        margin-bottom: 0.8rem;
    }
    
    .menu-section h3 {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }
    
    .menu-item {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    .menu-select {
        max-width: 120px;
        font-size: 0.8rem;
        padding: 0.3rem;
    }
    
    .toggle-slider {
        width: 50px;
        height: 24px;
    }
    
    .toggle-slider::before {
        width: 20px;
        height: 20px;
    }
    
    .toggle-switch input:checked + .toggle-slider::before {
        transform: translateX(26px);
    }
    
    .room-info-compact {
        gap: 0.4rem;
        font-size: 0.8rem;
    }
    
    .room-code {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }
    
    .btn-icon {
        min-width: 28px;
        height: 28px;
        padding: 0.3rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .room-card {
        padding: 2rem 1.5rem;
        margin: 0 0.5rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group input {
        margin-bottom: 0.5rem;
    }
    
    .btn-primary,
    .btn-create {
        width: 100%;
        justify-content: center;
    }
    
    .message {
        max-width: 95%;
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .chat-input-section {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.3rem 0.5rem;
        height: 50px; /* Even smaller on very small screens */
    }
    
    .app-container {
        padding-top: 50px; /* Match very small header height */
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .connection-status {
        font-size: 0.7rem;
    }
    
    .room-info-compact {
        gap: 0.3rem;
        font-size: 0.75rem;
    }
    
    .room-code {
        padding: 0.2rem 0.3rem;
        font-size: 0.75rem;
    }
    
    .btn-icon {
        min-width: 24px;
        height: 24px;
        padding: 0.2rem;
    }
    
    .btn-icon i {
        font-size: 0.8rem;
    }
    
    .btn-text {
        height: 24px;
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .notification-toast {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        transform: translateY(-100px);
    }
    
    .notification-toast.show {
        transform: translateY(0);
    }
}
