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

:root {
    --primary-color: #1a1a2e;
    --secondary-color: #16213e;
    --accent-color: #e94560;
    --success-color: #4caf50;
    --error-color: #f44336;
    --warning-color: #ff9800;
    --text-color: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #2d2d44;
    --bg-dark: #0f0f1e;
    --bg-light: #2a2a3e;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--primary-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: #d63651;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-light);
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background-color: rgba(244, 67, 54, 0.1);
    color: #ff6b6b;
    border-left: 4px solid #f44336;
}

.alert-success {
    background-color: rgba(76, 175, 80, 0.1);
    color: #66bb6a;
    border-left: 4px solid #4caf50;
}

/* ===== AUTH PAGE ===== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--primary-color) 100%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.auth-box {
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--accent-color);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input {
    padding: 12px;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 14px;
    transition: border-color 0.3s ease;
}

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

.auth-hint {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== CHAT PAGE ===== */
.chat-page {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

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

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background-color: var(--secondary-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

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

.sidebar-header h2 {
    font-size: 20px;
    color: var(--accent-color);
}

.btn-new-chat {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-new-chat:hover {
    transform: scale(1.1);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversation-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    margin-bottom: 8px;
    background-color: var(--bg-light);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background-color: var(--primary-color);
    color: var(--text-color);
}

.conversation-item.active {
    background-color: var(--accent-color);
    color: white;
    border-left-color: #ff6b9d;
}

.conv-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-date {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-size: 13px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== CHAT MAIN ===== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--primary-color);
    overflow: hidden;
}

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

.chat-header h3 {
    font-size: 18px;
    color: var(--text-color);
}

.btn-delete-chat {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.btn-delete-chat:hover {
    opacity: 1;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.empty-chat p {
    font-size: 18px;
    margin-bottom: 8px;
}

.empty-chat small {
    font-size: 13px;
}

.message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 70%;
    animation: slideIn 0.3s ease;
}

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

.message-user {
    align-self: flex-end;
}

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

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.message-user .message-content {
    background-color: var(--accent-color);
    color: white;
}

.message-assistant .message-content {
    background-color: var(--bg-light);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 0 4px;
}

.message-user .message-time {
    text-align: right;
}

.message-assistant .message-time {
    text-align: left;
}

/* ===== TYPING STATUS CONTAINER ===== */
.typing-status-container {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--secondary-color);
    min-height: 0;
    transition: all 0.3s ease;
}

.typing-status-container.hidden {
    display: none;
}

.typing-status-container.visible {
    display: block;
}

/* ===== TYPING STATUS COM AVATAR ===== */
.typing-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: #ffffff;
    font-size: 13px;
    width: fit-content;
    animation: slideIn 0.3s ease;
    margin-bottom: 0;
}

.typing-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 3px solid #ffffff; /* Borda Branca Solicitada */
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    background: #000;
}

.typing-content {
    display: flex;
    align-items: center;
    gap: 6px;
}

.typing-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ccc; /* Pontos cinza claro */
    animation: blink 1.4s infinite both;
}

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

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

@keyframes blink {
    0% {
        opacity: 0.2;
    }
    20% {
        opacity: 1;
    }
    100% {
        opacity: 0.2;
    }
}

.message-input-form {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--secondary-color);
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group textarea {
    flex: 1;
    padding: 12px;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    max-height: 120px;
    transition: border-color 0.3s ease;
}

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

.input-group button {
    align-self: flex-end;
    padding: 12px 24px;
}

.empty-chat-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.empty-chat-main h2 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--text-color);
}

/* ===== ADMIN PAGE ===== */
.admin-page {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background-color: var(--secondary-color);
    border-right: 1px solid var(--border-color);
    padding: 20px;
}

.admin-main {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-nav a {
    padding: 12px 16px;
    background-color: var(--bg-light);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.admin-nav a:hover,
.admin-nav a.active {
    background-color: var(--accent-color);
    color: white;
    border-left-color: #ff6b9d;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.admin-header {
    margin-bottom: 30px;
}

.admin-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.admin-header p {
    color: var(--text-secondary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.data-table thead {
    background-color: var(--bg-light);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background-color: var(--bg-light);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background-color: #d32f2f;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #45a049;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .conversations-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 10px;
    }
    
    .conversation-item {
        flex-shrink: 0;
        min-width: 150px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .auth-box {
        padding: 30px 20px;
    }
    
    .admin-page {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .admin-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .admin-nav a {
        flex: 1;
        min-width: 150px;
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 100%;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group button {
        align-self: stretch;
    }
    
    .auth-box {
        padding: 20px;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

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

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

/* ===== NOVAS MELHORIAS: FUNDO E RESPONSIVIDADE ===== */

/* Fundo com Imagem no Chat */
.chat-main {
    background: linear-gradient(135deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.8) 100%), 
                url('/chat-background.jpg') center/cover !important;
    background-attachment: fixed !important;
    position: relative;
}

.chat-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 1;
}

/* Garantir que o conteúdo fique acima do overlay */
.chat-header, .messages-container, .typing-status-container, .message-input-form {
    z-index: 10;
    position: relative;
}

/* Ajuste de transparência para os containers */
.chat-header, .message-input-form, .typing-status-container {
    background-color: rgba(20, 20, 35, 0.9) !important;
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 70px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 10px 15px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-header {
        padding: 0;
        border-bottom: none;
    }

    .sidebar-header h2 {
        font-size: 18px;
    }

    .conversations-list {
        display: none; /* Esconde lista de conversas em mobile para ganhar espaço */
    }

    .sidebar-footer {
        padding: 0;
        border-top: none;
        flex-direction: row;
    }

    .sidebar-footer .btn {
        padding: 8px 15px;
        font-size: 12px;
    }

    .message {
        max-width: 85%;
    }

    .message-input-form {
        padding: 10px;
    }

    .input-group {
        display: flex;
        gap: 8px;
        align-items: flex-end;
    }

    #messageInput {
        flex: 1;
        min-height: 40px;
        max-height: 100px;
    }

    .btn-primary {
        padding: 10px 15px;
        height: 40px;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .sidebar-header h2 {
        font-size: 16px;
    }

    .message {
        max-width: 90%;
    }

    .message-content {
        padding: 10px;
        font-size: 13px;
    }

    .btn-primary {
        min-width: 70px;
        font-size: 12px;
    }
}
