/* Chat Section Styles - Angepasst an Xnprofil Design */
.chat-section {
    padding: 40px 0;
    background: transparent;
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.chat-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 30% 20%, rgba(255, 165, 0, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 165, 0, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.chat-container {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(45, 45, 45, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 165, 0, 0.3);
    overflow: hidden;
    height: calc(100vh - 180px);
    min-height: 600px;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    /* Verhindere dass Container gezogen/verschoben werden kann */
    position: relative;
    box-sizing: border-box;
}

.chat-header {
    background: linear-gradient(135deg, rgba(255, 165, 0, 0.2) 0%, rgba(255, 140, 0, 0.1) 100%);
    backdrop-filter: blur(10px);
    color: #ffffff;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 165, 0, 0.3);
    flex-shrink: 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #ffa500;
    text-shadow: 0 0 10px rgba(255, 165, 0, 0.5);
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#online-users {
    background: rgba(255, 165, 0, 0.2);
    padding: 5px 8px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    color: #ffa500;
    border: 1px solid rgba(255, 165, 0, 0.3);
    backdrop-filter: blur(10px);
}

.chat-messages {
    flex: 1;
    padding: 6px 8px;
    overflow-y: auto;
    background: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
}

.chat-message {
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.3s ease-out;
}

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

.user-message {
    max-width: 70%;
}

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

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

.system-message {
    align-self: center;
    max-width: 90%;
}

.message-header {
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    margin-bottom: 1px;
    padding: 0 1px;
}

.username-wrapper {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.username {
    font-weight: 700;
    color: #ffd700;
    font-size: 11px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 12px rgba(255, 215, 0, 0.6);
    display: inline-block;
    letter-spacing: 0.2px;
}

.message-time {
    font-size: 10px;
    color: #cccccc;
    opacity: 0.8;
}

.message-content {
    background: rgba(60, 60, 60, 0.9);
    backdrop-filter: blur(10px);
    padding: 5px 10px;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.own-message .message-content {
    background: linear-gradient(135deg, rgba(255, 165, 0, 0.3) 0%, rgba(255, 140, 0, 0.2) 100%);
    border: 1px solid rgba(255, 165, 0, 0.4);
    color: #ffffff;
}

/* Pinke Rahmen für weibliche Profile (Sie sucht ihn/sie) */
.own-message.gender-female .message-content {
    background: linear-gradient(135deg, rgba(255, 192, 203, 0.3) 0%, rgba(255, 105, 180, 0.2) 100%);
    border: 2px solid rgba(255, 105, 180, 0.6);
    box-shadow: 0 4px 12px rgba(255, 105, 180, 0.3);
}

.other-message.gender-female .message-content {
    border: 2px solid rgba(255, 105, 180, 0.4);
    box-shadow: 0 4px 12px rgba(255, 105, 180, 0.2);
}

/* Blaue Rahmen für männliche Profile (Er sucht sie/ihn) */
.own-message.gender-male .message-content {
    background: linear-gradient(135deg, rgba(173, 216, 230, 0.3) 0%, rgba(100, 149, 237, 0.2) 100%);
    border: 2px solid rgba(100, 149, 237, 0.6);
    box-shadow: 0 4px 12px rgba(100, 149, 237, 0.3);
}

.other-message.gender-male .message-content {
    border: 2px solid rgba(100, 149, 237, 0.4);
    box-shadow: 0 4px 12px rgba(100, 149, 237, 0.2);
}

.system-message .message-content {
    background: rgba(40, 40, 40, 0.9);
    color: #cccccc;
    text-align: center;
    font-style: italic;
    border: 1px solid rgba(255, 165, 0, 0.2);
}

.message-text {
    word-wrap: break-word;
    line-height: 1.3;
    color: #ffffff;
}

.user-meta {
    font-size: 10px;
    color: #cccccc;
    opacity: 0.8;
    margin-left: 3px;
}

.user-level-badge {
    font-size: 0.65em !important;
    padding: 1px 4px !important;
    margin-left: 3px !important;
}

.chat-input-container {
    padding: 6px 10px;
    background: rgba(45, 45, 45, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 165, 0, 0.3);
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid rgba(255, 165, 0, 0.3);
    border-radius: 18px;
    font-size: 14px;
    outline: none;
    background: rgba(30, 30, 30, 0.9);
    color: #ffffff;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    min-height: 38px;
}

#chat-input::placeholder {
    color: #cccccc;
}

#chat-input:focus {
    border-color: #ffa500;
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.3);
    background: rgba(40, 40, 40, 0.9);
}

#chat-input:disabled {
    background: rgba(20, 20, 20, 0.9);
    color: #666666;
    cursor: not-allowed;
    border-color: rgba(255, 165, 0, 0.1);
}

#send-btn {
    background: linear-gradient(135deg, #ffa500 0%, #ff8c00 100%);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 165, 0, 0.3);
    border: 1px solid rgba(255, 165, 0, 0.5);
    flex-shrink: 0;
}

#send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 165, 0, 0.5);
    background: linear-gradient(135deg, #ff8c00 0%, #ff7f00 100%);
}

#send-btn:active {
    transform: scale(0.95);
}

#send-btn:disabled {
    background: rgba(60, 60, 60, 0.9);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    border-color: rgba(255, 165, 0, 0.1);
}

/* Chat Error Styles */
.chat-error {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(244, 67, 54, 0.95);
    backdrop-filter: blur(20px);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    z-index: 1000;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
    border: 1px solid rgba(244, 67, 54, 0.5);
    animation: errorSlideIn 0.3s ease-out;
}

@keyframes errorSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Chat Notification Styles */
.chat-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    z-index: 1001;
    font-size: 14px;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideIn 0.3s ease-out;
}

.chat-notification.success {
    background: rgba(76, 175, 80, 0.95);
    color: white;
    border-color: rgba(76, 175, 80, 0.5);
}

.chat-notification.warning {
    background: rgba(255, 152, 0, 0.95);
    color: white;
    border-color: rgba(255, 152, 0, 0.5);
}

.chat-notification.error {
    background: rgba(244, 67, 54, 0.95);
    color: white;
    border-color: rgba(244, 67, 54, 0.5);
}

.chat-notification.info {
    background: rgba(33, 150, 243, 0.95);
    color: white;
    border-color: rgba(33, 150, 243, 0.5);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-section {
        padding: 0 !important;
    }
    
    .chat-container {
        height: auto !important;
        max-height: 90vh !important;
        min-height: 700px !important;
        margin: 0 !important;
        border-radius: 15px 15px 0 0;
        /* Verhindere dass Container gezogen/verschoben werden kann */
        position: relative !important;
        touch-action: pan-y !important;
        overflow: hidden !important;
        /* Stelle sicher dass Container nicht über Viewport hinausgeht */
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100vw !important;
        /* Verhindere horizontales Scrollen */
        left: 0 !important;
        right: 0 !important;
    }
    
    .chat-header {
        padding: 8px 10px;
        flex-shrink: 0;
    }
    
    .chat-header h3 {
        font-size: 18px;
    }
    
    #online-users {
        font-size: 14px;
        padding: 6px 10px;
    }
    
    .chat-messages {
        padding: 6px 8px;
        gap: 3px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .user-message {
        max-width: 85%;
    }
    
    .username {
        font-size: 14px !important;
    }
    
    .message-time {
        font-size: 12px !important;
    }
    
    .message-content {
        padding: 6px 10px !important;
        font-size: 14px;
    }
    
    .message-text {
        font-size: 14px;
        line-height: 1.3;
    }
    
    .chat-input-container {
        padding: 6px 8px;
        gap: 6px;
        flex-shrink: 0;
    }
    
    #chat-input {
        font-size: 16px; /* Verhindert Zoom auf iOS */
        min-height: 40px;
        padding: 8px 12px;
    }
    
    #send-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(255, 165, 0, 0.3);
    }
}

@media (max-width: 480px) {
    .chat-section {
        padding: 0 !important;
    }
    
    .chat-container {
        height: auto !important;
        max-height: 85vh !important;
        min-height: 650px !important;
        margin: 0 !important;
        border-radius: 12px 12px 0 0;
        /* Verhindere dass Container gezogen/verschoben werden kann */
        position: relative !important;
        touch-action: pan-y !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100vw !important;
        /* Verhindere horizontales Scrollen */
        left: 0 !important;
        right: 0 !important;
    }
    
    .chat-header {
        padding: 6px 8px;
        flex-shrink: 0;
    }
    
    .chat-header h3 {
        font-size: 16px;
    }
    
    #online-users {
        font-size: 13px;
        padding: 5px 8px;
    }
    
    .chat-messages {
        padding: 5px 6px;
        gap: 2px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .username {
        font-size: 13px !important;
    }
    
    .message-time {
        font-size: 11px !important;
    }
    
    .message-content {
        padding: 5px 9px !important;
        border-radius: 12px;
        font-size: 13px;
    }
    
    .message-text {
        font-size: 13px;
        line-height: 1.3;
    }
    
    .chat-input-container {
        padding: 5px 6px;
        gap: 5px;
        flex-shrink: 0;
    }
    
    #chat-input {
        padding: 7px 10px;
        font-size: 16px;
        min-height: 36px;
    }
    
    #send-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(30, 30, 30, 0.8);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 165, 0, 0.5);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 165, 0, 0.7);
}

/* Loading Animation */
.chat-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #cccccc;
}

.chat-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 165, 0, 0.3);
    border-top: 2px solid #ffa500;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #cccccc;
    text-align: center;
}

.chat-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
    color: #ffa500;
}

.chat-empty p {
    margin: 0;
    font-size: 16px;
}