* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --bg-gradient-1: #1e293b;
    --bg-gradient-2: #334155;
    --bg-gradient-3: #475569;
    --text-light: #f1f5f9;
    --text-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Partículas de fundo animadas */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
    animation: float 30s ease-in-out infinite;
    pointer-events: none;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

.screen {
    display: none;
    width: 100%;
    height: 100vh;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
}

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

/* Telas de Autenticação - Glass Morphism */
.auth-container {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 50px 40px;
    border-radius: 30px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    text-align: center;
    min-width: 400px;
    animation: slideUp 0.6s ease;
}

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

.auth-container h1 {
    background: linear-gradient(135deg, #fff 0%, #e0e7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    font-size: 2.5em;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.3);
}

.auth-container p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 35px;
    font-size: 1.1em;
    font-weight: 300;
}

.auth-container form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-container input {
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    font-size: 16px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.auth-container input:focus {
    outline: none;
    background: rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.auth-container input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.auth-container button {
    padding: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
    position: relative;
    overflow: hidden;
}

.auth-container button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.auth-container button:hover::before {
    left: 100%;
}

.auth-container button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.5);
}

.auth-container button:active {
    transform: translateY(-1px);
}

.error {
    color: #fee;
    background: rgba(239, 68, 68, 0.9);
    font-size: 14px;
    padding: 12px;
    border-radius: 10px;
    animation: shake 0.5s;
    font-weight: 600;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error.hidden {
    display: none;
}

/* Chat Container - Modern Design */
.chat-container {
    width: 100%;
    max-width: 1000px;
    height: 92vh;
    margin: 4vh auto;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 25px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: headerPulse 10s ease-in-out infinite;
}

@keyframes headerPulse {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-30px, -30px); }
}

.chat-header h2 {
    font-size: 1.6em;
    font-weight: 700;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-name-display {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.messages-container {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
    position: relative;
}

/* Padrão de fundo sutil */
.messages-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(102, 126, 234, 0.02) 35px, rgba(102, 126, 234, 0.02) 70px);
    pointer-events: none;
}

.message {
    margin-bottom: 20px;
    animation: slideInLeft 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.message-author {
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 15px;
}

.message-time {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

.message-text {
    background: white;
    padding: 15px 20px;
    border-radius: 18px;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.06),
        0 0 0 1px rgba(0, 0, 0, 0.02);
    word-wrap: break-word;
    line-height: 1.6;
    color: #1e293b;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.message:hover .message-text {
    transform: translateX(5px);
    border-left-color: #667eea;
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.15),
        0 0 0 1px rgba(102, 126, 234, 0.1);
}

.system-message {
    text-align: center;
    color: #64748b;
    font-size: 13px;
    font-style: italic;
    margin: 15px 0;
    padding: 8px 16px;
    background: rgba(100, 116, 139, 0.1);
    border-radius: 20px;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
    position: relative;
    font-weight: 500;
    animation: fadeIn 0.5s ease;
}

.message-form {
    padding: 25px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
}

.message-form input {
    flex: 1;
    padding: 16px 24px;
    border: 2px solid #e2e8f0;
    border-radius: 30px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #f8fafc;
    font-weight: 500;
}

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

.message-form button {
    padding: 16px 35px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    font-size: 15px;
    position: relative;
    overflow: hidden;
}

.message-form button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.message-form button:hover::before {
    width: 300px;
    height: 300px;
}

.message-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.message-form button:active {
    transform: translateY(0);
}

/* Scrollbar personalizada moderna */
.messages-container::-webkit-scrollbar {
    width: 10px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    border: 2px solid #f1f5f9;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #764ba2 0%, #667eea 100%);
}

/* Responsivo */
@media (max-width: 768px) {
    .auth-container {
        min-width: 90%;
        padding: 40px 25px;
        border-radius: 25px;
    }
    
    .auth-container h1 {
        font-size: 2em;
    }
    
    .chat-container {
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .chat-header h2 {
        font-size: 1.3em;
    }

    .chat-header {
        padding: 20px;
    }

    #user-name-display {
        font-size: 12px;
        padding: 8px 15px;
    }

    .message-form {
        padding: 15px;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}
