/* Reset und Basis Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #00a884;
    --primary-dark: #008f74;
    --secondary-color: #53bdeb;
    --background-dark: #111b21;
    --background-light: #ffffff;
    --surface-dark: #202c33;
    --surface-light: #f0f2f5;
    --text-dark: #e9edef;
    --text-light: #3b4a54;
    --text-muted: #8696a0;
    --border-color: #2a3942;
    --success-color: #25d366;
    --error-color: #ea4335;
    --warning-color: #fbbc05;
}

[data-theme="light"] {
    --background: var(--background-light);
    --surface: var(--surface-light);
    --text: var(--text-light);
    --text-muted: var(--text-muted);
    --border-color: #e0e0e0;
}

[data-theme="dark"] {
    --background: var(--background-dark);
    --surface: var(--surface-dark);
    --text: var(--text-dark);
    --text-muted: #8696a0;
    --border-color: var(--border-color);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text);
    transition: all 0.3s ease;
    overflow: hidden;
}

/* Auth Styles */
.auth-body {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.logo-section {
    margin-bottom: 40px;
}

.logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.logo i {
    font-size: 36px;
    color: white;
}

.logo-section h1 {
    color: var(--text-light);
    font-size: 28px;
    margin-bottom: 8px;
}

.logo-section p {
    color: var(--text-muted);
    font-size: 16px;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    color: var(--text-light);
    margin-bottom: 30px;
    font-size: 24px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 2;
}

.input-group input {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
}

.input-group input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 168, 132, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.auth-switch {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e0e0e0;
}

.auth-switch p {
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.message {
    padding: 16px;
    border-radius: 12px;
    margin-top: 20px;
    text-align: center;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.hidden {
    display: none !important;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-logo {
    font-size: 64px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-10px);}
    60% {transform: translateY(-5px);}
}

.loading-content h2 {
    margin-bottom: 20px;
    font-size: 28px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

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

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    background: var(--background);
}

/* Seitenleiste */
.sidebar {
    width: 400px;
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 16px;
}

.user-status {
    font-size: 13px;
    color: var(--text-muted);
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--border-color);
    color: var(--text);
}

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: none;
    z-index: 1000;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.dropdown-menu a:hover {
    background: var(--border-color);
}

.dropdown-menu .logout-btn {
    color: var(--error-color);
}

/* Suche */
.search-container {
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-clear {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

/* Chat Liste */
.chat-list {
    flex: 1;
    overflow-y: auto;
    background: var(--surface);
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.chat-item:hover {
    background: var(--background);
}

.chat-item.active {
    background: var(--border-color);
}

.chat-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), #2d8cff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
}

.chat-details {
    flex: 1;
    min-width: 0;
}

.chat-details h3 {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-details p {
    color: var(--text-muted);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

/* Hauptbereich */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
}

.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
}

.welcome-content {
    text-align: center;
    max-width: 500px;
    padding: 40px;
}

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

.welcome-content h1 {
    font-size: 32px;
    margin-bottom: 16px;
    color: var(--text);
}

.welcome-content p {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* Chat Bereich */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
}

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

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

.chat-details h3 {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 4px;
}

.chat-details span {
    color: var(--text-muted);
    font-size: 14px;
}

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

/* Nachrichten Container */
.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.03"><path fill="%23000" d="M30,30 L70,70 M70,30 L30,70"/></svg>');
    background-size: 100px 100px;
}

.message {
    max-width: 70%;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
    animation: messageSlide 0.3s ease-out;
}

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

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

.message.received {
    background: var(--surface);
    color: var(--text);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message-sender {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--secondary-color);
}

.message-text {
    line-height: 1.4;
    margin-bottom: 4px;
}

.message-time {
    font-size: 11px;
    opacity: 0.8;
    text-align: right;
}

/* Nachrichten Eingabe */
.message-input-container {
    padding: 20px;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

#messageInput {
    flex: 1;
    padding: 16px 20px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
}

#messageInput:focus {
    border-color: var(--primary-color);
}

.send-btn {
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border-radius: 16px;
    z-index: 1001;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.close-btn:hover {
    background: var(--border-color);
}

.modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.user-list {
    margin-top: 16px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 12px;
    transition: background 0.2s ease;
}

.user-item:hover {
    background: var(--border-color);
}

.profile-avatar {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}

.avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
}

.edit-avatar-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border: 3px solid var(--surface);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-group {
    margin-bottom: 20px;
}

.info-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-muted);
}

.info-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
}

.info-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
    }
    
    .app-container {
        flex-direction: column;
    }
    
    .modal {
        width: 95%;
        max-height: 90vh;
    }
}
