/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

.logo i {
    font-size: 1.8rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: #10b981;
}

.status-dot.offline {
    background: #ef4444;
}

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

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

/* Join Section */
.join-section {
    width: 100%;
    max-width: 500px;
}

.join-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-header {
    text-align: center;
    margin-bottom: 2rem;
}

.card-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.card-header p {
    color: #6b7280;
    font-size: 1rem;
}

.join-form {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #fff;
}

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

.room-input-container {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.room-input-container input,
.username-input-container input {
    flex: 1;
}

.username-input-container {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.generate-room-btn,
.generate-username-btn {
    padding: 0.75rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.generate-room-btn:hover,
.generate-username-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

.form-hint {
    display: block;
    margin-top: 0.5rem;
    color: #6b7280;
    font-size: 0.85rem;
}

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

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

.features-info {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
}

.features-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
}

.features-info ul {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.features-info li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    font-size: 0.9rem;
}

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

/* Chat Section */
.chat-section {
    width: 100%;
    max-width: 1000px;
    height: calc(100vh - 120px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.room-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
}

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

.user-count {
    font-size: 0.9rem;
    opacity: 0.9;
}

.share-room-btn,
.leave-room-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.share-room-btn:hover,
.leave-room-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.share-room-btn {
    background: rgba(16, 185, 129, 0.3);
}

.share-room-btn:hover {
    background: rgba(16, 185, 129, 0.4);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f9fafb;
}

.welcome-message {
    text-align: center;
    color: #6b7280;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.welcome-message i {
    font-size: 3rem;
    color: #667eea;
    opacity: 0.5;
}

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

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

.message.other {
    background: white;
    color: #333;
    margin-right: auto;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

.message-sender {
    font-weight: 600;
}

.message-time {
    font-size: 0.75rem;
}

.message-content {
    line-height: 1.5;
}

.file-message {
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    max-width: 70%;
}

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

.file-icon {
    width: 40px;
    height: 40px;
    background: #667eea;
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.file-details h4 {
    margin: 0;
    font-size: 0.9rem;
    color: #374151;
}

.file-details p {
    margin: 0;
    font-size: 0.8rem;
    color: #6b7280;
}

.file-download {
    background: #10b981;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    transition: all 0.3s ease;
}

.file-download:hover {
    background: #059669;
}

.typing-indicator {
    padding: 0.5rem 1rem;
    color: #6b7280;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(102, 126, 234, 0.05);
    margin: 0 1rem;
    border-radius: 8px;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background: #667eea;
    border-radius: 50%;
    animation: typingDots 1.5s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDots {
    0%, 60%, 100% { transform: scale(1); opacity: 0.5; }
    30% { transform: scale(1.2); opacity: 1; }
}

.message-input-container {
    border-top: 1px solid #e5e7eb;
    padding: 1rem;
    background: white;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

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

.file-upload-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

.file-upload-btn:hover {
    background: #5a67d8;
}

.message-input-wrapper {
    flex: 1;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.4;
    transition: all 0.3s ease;
}

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

.send-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: #5a67d8;
    transform: translateY(-1px);
}

.send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

/* Upload Progress */
.upload-progress {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    min-width: 250px;
    z-index: 1000;
}

.progress-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.progress-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
}

/* Notifications */
.notifications-container {
    position: fixed;
    top: 100px;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notification {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-left: 4px solid #667eea;
    max-width: 300px;
    animation: slideInRight 0.3s ease;
}

.notification.success {
    border-left-color: #10b981;
}

.notification.error {
    border-left-color: #ef4444;
}

.notification.warning {
    border-left-color: #f59e0b;
}

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

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* QR Code Modal */
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.qr-modal-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideInModal 0.3s ease;
}

.qr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.qr-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #1f2937;
    margin: 0;
    font-size: 1.3rem;
}

.close-qr-btn {
    background: #f3f4f6;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.3s ease;
}

.close-qr-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.qr-body {
    text-align: center;
}

.qr-code-container {
    background: #f9fafb;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.qr-info {
    text-align: left;
}

.qr-info p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #374151;
}

.qr-info strong {
    color: #1f2937;
}

.qr-info span {
    font-family: 'Monaco', 'Consolas', monospace;
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.copy-url-btn {
    width: 100%;
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.copy-url-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInModal {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem 0;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .logo i {
        font-size: 1.5rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .join-card {
        padding: 1.5rem;
        border-radius: 16px;
    }
    
    .card-header h2 {
        font-size: 1.5rem;
    }
    
    .features-info ul {
        grid-template-columns: 1fr;
    }
    
    .chat-section {
        height: calc(100vh - 100px);
        border-radius: 16px;
        margin: 0;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .room-info {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .room-details {
        align-self: stretch;
        justify-content: space-between;
    }
    
    .message {
        max-width: 85%;
    }
    
    .message-input-container {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .input-actions {
        justify-content: center;
    }
    
    .file-upload-btn {
        justify-content: center;
        padding: 0.75rem 1.5rem;
    }
    
    .notifications-container {
        left: 1rem;
        right: 1rem;
        top: 80px;
    }
    
    .notification {
        max-width: none;
    }
    
    .upload-progress {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .join-card {
        padding: 1rem;
    }
    
    .room-input-container {
        flex-direction: column;
    }
    
    .generate-room-btn {
        align-self: center;
        min-width: 120px;
    }
    
    .chat-header {
        padding: 0.75rem;
    }
    
    .room-title {
        font-size: 1rem;
    }
    
    .message {
        max-width: 90%;
        padding: 0.75rem;
    }
    
    .message-input-container {
        padding: 0.75rem;
    }
    
    #messageInput {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    }
    
    .join-card, .chat-section {
        background: rgba(31, 41, 55, 0.95);
        color: #f9fafb;
    }
    
    .card-header h2 {
        color: #f9fafb;
    }
    
    .form-group label {
        color: #d1d5db;
    }
    
    .form-group input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .form-group input:focus {
        border-color: #667eea;
    }
    
    .messages-container {
        background: #111827;
    }
    
    .message.other {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .message-input-container {
        background: #1f2937;
        border-color: #374151;
    }
    
    #messageInput {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .notification {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .upload-progress {
        background: #1f2937;
        color: #f9fafb;
    }
}
