* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #ff0000;
    --dark-red: #cc0000;
    --light-red: #ff3333;
    --black: #0a0a0a;
    --dark-gray: #1a1a1a;
    --medium-gray: #2a2a2a;
    --light-gray: #3a3a3a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #333333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--black) 0%, var(--dark-gray) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* Auth Screen - permite scroll */
#auth-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Chat Screen - sem scroll */
#chat-screen {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
}

.auth-container {
    background: var(--dark-gray);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 8px 32px rgba(255, 0, 0, 0.1);
    margin: 20px auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-icon {
    font-size: 48px;
}

.logo h1 {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-red), var(--light-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    margin-bottom: 24px;
    font-size: 24px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--medium-gray);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s;
}

.input-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-red);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.input-group small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.input-group code {
    background: var(--medium-gray);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary-red);
    font-size: 11px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-red), var(--dark-red));
    color: white;
    margin-top: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 20, 60, 0.3);
}

.auth-switch {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary-red);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Chat Screen */
#chat-screen {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}

.chat-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--dark-gray);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--medium-gray);
    border-radius: 6px;
    margin: 12px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pulse 2s infinite;
}

.api-status.online .status-dot {
    background: #00ff00;
}

.api-status.offline .status-dot {
    background: var(--primary-red);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.logo-small {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 18px;
}

.logo-small .logo-icon {
    font-size: 24px;
}

.btn-new-chat {
    width: 100%;
    padding: 12px;
    background: var(--primary-red);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-new-chat:hover {
    background: var(--light-red);
}

.btn-new-chat span {
    font-size: 20px;
    margin-right: 4px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.chat-history-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--medium-gray);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid transparent;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background: var(--light-gray);
    border-color: var(--primary-red);
}

.chat-history-item.active {
    background: var(--light-gray);
    border-color: var(--primary-red);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.contact-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.contact-section h4 {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contact-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-contact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--medium-gray);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.3s;
    cursor: pointer;
}

.btn-contact:hover {
    background: var(--light-gray);
    border-color: var(--primary-red);
    transform: translateX(4px);
}

.btn-contact svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-contact.whatsapp:hover {
    border-color: #25D366;
}

.btn-contact.discord:hover {
    border-color: #5865F2;
}

.btn-contact.email:hover {
    border-color: var(--primary-red);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px;
    background: var(--medium-gray);
    border-radius: 8px;
}

.user-info span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-red), var(--dark-red));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.btn-logout {
    width: 100%;
    padding: 10px;
    background: var(--medium-gray);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: var(--light-gray);
    color: var(--text-primary);
}

.btn-admin {
    width: 100%;
    padding: 10px;
    background: var(--primary-red);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 12px;
    font-weight: 600;
}

.btn-admin:hover {
    background: var(--light-red);
    transform: translateY(-2px);
}

/* Main Chat */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--black);
    overflow: hidden;
}

.chat-header-mobile {
    display: none;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--dark-gray);
    border-bottom: 1px solid var(--border-color);
}

.btn-menu-mobile {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s;
}

.btn-menu-mobile:hover {
    background: var(--medium-gray);
}

.logo-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
}

.logo-mobile .logo-icon {
    font-size: 24px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.welcome-message {
    text-align: center;
    margin-top: 20vh;
}

.welcome-message h2 {
    font-size: 32px;
    margin-bottom: 12px;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 18px;
}

.message {
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary-red), var(--dark-red));
}

.message.assistant .message-avatar {
    background: var(--medium-gray);
}

.message-content {
    flex: 1;
    max-width: 800px;
}

.message-role {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.message.user .message-role {
    color: var(--primary-red);
}

.message-text {
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.assistant .message-text {
    color: var(--text-secondary);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-red);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Chat Input */
.chat-input-container {
    padding: 24px 32px;
    border-top: 1px solid var(--border-color);
    background: var(--dark-gray);
}

.chat-input-form {
    display: flex;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
}

#message-input {
    flex: 1;
    padding: 14px 18px;
    background: var(--medium-gray);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    transition: all 0.3s;
    -webkit-appearance: none;
    appearance: none;
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.btn-send {
    width: 48px;
    height: 48px;
    background: var(--primary-red);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover:not(:disabled) {
    background: var(--light-red);
    transform: translateY(-2px);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--dark-gray);
}

::-webkit-scrollbar-thumb {
    background: var(--medium-gray);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--light-gray);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .chat-header-mobile {
        display: flex;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        left: -300px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-header {
        padding: 16px;
    }
    
    .btn-new-chat {
        padding: 10px;
        font-size: 14px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message {
        margin-bottom: 20px;
        gap: 12px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .message-text {
        font-size: 14px;
    }
    
    .chat-input-container {
        padding: 12px;
    }
    
    .chat-input-form {
        gap: 8px;
    }
    
    #message-input {
        padding: 12px 14px;
        font-size: 16px; /* Evita zoom no iOS */
        border-radius: 10px;
    }
    
    .btn-send {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }
    
    .welcome-message {
        margin-top: 15vh;
        padding: 0 20px;
    }
    
    .welcome-message h2 {
        font-size: 24px;
    }
    
    .welcome-message p {
        font-size: 16px;
    }
    
    .contact-buttons {
        gap: 6px;
    }
    
    .btn-contact {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .btn-contact svg {
        width: 14px;
        height: 14px;
    }
    
    .user-info {
        padding: 6px;
    }
    
    .user-info span {
        font-size: 13px;
    }
    
    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 20px;
        margin: 10px;
    }
    
    .auth-header {
        margin-bottom: 24px;
    }
    
    .logo h1 {
        font-size: 28px;
    }
    
    .logo-icon {
        font-size: 36px;
    }
    
    .input-group {
        margin-bottom: 16px;
    }
    
    .input-group input {
        font-size: 16px; /* Evita zoom no iOS */
        padding: 10px 14px;
    }
    
    .btn-primary {
        padding: 10px 20px;
    }
    
    .auth-switch {
        font-size: 13px;
    }
    
    #auth-screen {
        padding: 10px;
    }
    
    .sidebar {
        width: 260px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .message {
        gap: 10px;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

@media (max-height: 600px) {
    .welcome-message {
        margin-top: 5vh;
    }
    
    .welcome-message h2 {
        font-size: 20px;
    }
    
    .welcome-message p {
        font-size: 14px;
    }
}
