/* Sistema de Análise de Crédito - CSS Completo */
/* Paleta: Verde (#10B981), Branco (#FFFFFF), Cinza (#6B7280, #F3F4F6) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #10B981;
    --primary-dark: #059669;
    --primary-light: #34D399;
    --secondary-color: #6B7280;
    --bg-light: #F3F4F6;
    --bg-white: #FFFFFF;
    --text-dark: #1F2937;
    --text-gray: #6B7280;
    --border-color: #E5E7EB;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* =========================================
   LOGIN PAGE
   ========================================= */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-box {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: var(--primary-color);
    font-size: 28px;
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-gray);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-size: 14px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.login-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 12px;
    color: var(--text-gray);
}

/* =========================================
   HEADER
   ========================================= */
header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    height: 65px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    padding: 0 32px; /* Espaçamento interno nas laterais */
}

/* Conteúdo do Header espalhado */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    /* Removemos o max-width para alinhar com o menu */
    margin: 0; 
}

/* Container Principal - AGORA OCUPA 100% DA TELA */
.container {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    width: 100%;       /* Ocupa tudo */
    max-width: 100%;   /* Remove limite de 1400px */
    margin: 0;         /* Remove a centralização automática */
    min-height: calc(100vh - 65px);
    position: relative;
}

/* Sidebar Fixa na Esquerda (Colada na borda) */
.sidebar {
    width: 260px;       /* Largura fixa */
    min-width: 260px;   /* Não deixa diminuir */
    background: linear-gradient(180deg, #FFFFFF 0%, #F9FAFB 100%);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    
    /* Sticky */
    position: -webkit-sticky;
    position: sticky;
    top: 65px;
    height: calc(100vh - 65px);
    overflow-y: auto;
    z-index: 50;
}

/* Conteúdo Principal na Direita */
.main-content {
    flex: 1; /* Cresce para ocupar o resto da tela */
    padding: 32px;
    width: calc(100% - 260px); /* Prevenção de quebra de layout */
    overflow-x: hidden; /* Evita rolagem horizontal indesejada */
}

/* 3. ESTILOS DO MENU
   ========================================================================== */
.sidebar-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav li { width: 100%; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    color: var(--text-gray);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
}

.sidebar-nav svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
    stroke-width: 2px;
}

.sidebar-nav a:hover {
    background: #ECFDF5;
    color: var(--primary-dark);
    transform: translateX(5px);
}

.sidebar-nav a:hover svg { transform: scale(1.1); }

.sidebar-nav a.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
    font-weight: 600;
}

.sidebar-nav a.active svg { stroke: white; }

/* 4. ELEMENTOS UI GERAIS
   ========================================================================== */
.header-logo { font-size: 20px; font-weight: 700; color: var(--primary-color); }
.header-user { display: flex; align-items: center; gap: 16px; }
.user-name { font-weight: 600; font-size: 14px; }
.user-type { font-size: 12px; color: var(--text-gray); }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.page-header h1 { font-size: 28px; font-weight: 700; }

/* =========================================
   MAIN CONTENT
   ========================================= */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 32px;
    color: var(--text-dark);
    font-weight: 700;
}

/* =========================================
   CARDS
   ========================================= */
.card {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.card-body {
    padding: 24px;
}

/* =========================================
   STATS GRID
   ========================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.stat-icon.bg-blue { background: #3B82F6; }
.stat-icon.bg-yellow { background: #F59E0B; }
.stat-icon.bg-green { background: var(--primary-color); }
.stat-icon.bg-red { background: #EF4444; }

.stat-content h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.stat-content p {
    font-size: 14px;
    color: var(--text-gray);
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4B5563;
}

.btn-success {
    background: var(--primary-color);
    color: white;
}

.btn-success:hover {
    background: var(--primary-dark);
}

.btn-warning {
    background: #F59E0B;
    color: white;
}

.btn-warning:hover {
    background: #D97706;
}

.btn-danger {
    background: #EF4444;
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* =========================================
   FORMS
   ========================================= */
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-size: 14px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.col-md-2 { flex: 0 0 16.666%; }
.col-md-3 { flex: 0 0 25%; }
.col-md-6 { flex: 0 0 50%; }

.form-text {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-gray);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* =========================================
   TABLES
   ========================================= */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--bg-light);
}

.table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-gray);
    letter-spacing: 0.5px;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table tbody tr {
    transition: background 0.2s ease;
}

.table tbody tr:hover {
    background: var(--bg-light);
}

.text-center {
    text-align: center;
}

/* =========================================
   BADGES & ALERTS
   ========================================= */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info { background: #DBEAFE; color: #1E40AF; }

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #6EE7B7;
}

.alert-error, .alert-danger {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

/* =========================================
   DOCUMENTS & INFO
   ========================================= */
.documents-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.document-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
    transition: background 0.2s ease;
}

.document-item:hover {
    background: #E5E7EB;
}

.doc-icon {
    font-size: 24px;
}

.doc-name {
    flex: 1;
    font-size: 14px;
    color: var(--text-dark);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.info-item {
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
}

.info-item strong {
    display: block;
    font-size: 12px;
    color: var(--text-gray);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =========================================
   CHAT & ANEXOS (ATUALIZADO)
   ========================================= */
.chat-card {
    height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

.chat-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.chat-info {
    font-size: 13px;
    color: var(--text-gray);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-light);
}

.chat-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-gray);
}

.chat-message {
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.chat-message-time {
    font-size: 11px;
    color: var(--text-gray);
}

.chat-message-content {
    background: var(--bg-white);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 70%;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message-own .chat-message-content {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
}

.chat-message-own .chat-message-header {
    justify-content: flex-end;
}

/* Área de Input do Chat + Botão Anexo */
.chat-input-container {
    padding: 20px 24px;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
}

.chat-input-container form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}

.chat-input-group {
    display: flex;
    gap: 12px;
    width: 100%;
}

.chat-input-group textarea {
    flex: 1;
    resize: none;
}

/* Botão Clipe (Anexar) */
.btn-attach {
    background: #e9ecef;
    border: 1px solid #ced4da;
    color: #495057;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 2px;
}

.btn-attach:hover {
    background: #dde2e6;
    color: #000;
}

/* Barra de Preview de Arquivo */
.file-preview-bar {
    display: none;
    background-color: #e2e6ea;
    padding: 8px 15px;
    border-radius: 5px;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #333;
    border-left: 4px solid #007bff;
}

/* Anexos nas Mensagens */
.msg-attachment {
    margin-top: 8px;
    background: rgba(0,0,0,0.1);
    padding: 8px;
    border-radius: 5px;
}

.msg-img-preview {
    max-width: 100%;
    max-height: 250px;
    border-radius: 4px;
    cursor: pointer;
    display: block;
}

.msg-file-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit; /* Herda cor do pai (branco se for msg propria) */
    font-weight: 500;
}

.chat-message-other .msg-file-link {
    color: #0056b3;
}

.msg-file-link:hover {
    text-decoration: underline;
}

.icon-file {
    margin-right: 8px;
    font-size: 1.2em;
}

/* Alerta de Chat Bloqueado */
.chat-status-alert {
    display: none;
    margin-top: 15px;
    padding: 15px;
    border: 1px solid transparent;
    border-radius: 8px;
    text-align: center;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* =========================================
   QUICK ACTIONS & UTILS
   ========================================= */
.quick-actions {
    display: grid;
    gap: 12px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-light);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    transition: all 0.3s ease;
}

.quick-action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateX(4px);
}

.row {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.col-md-6 {
    flex: 1;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.text-muted { color: var(--text-gray); }

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    /* Sidebar Mobile */
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        padding: 15px;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-nav {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
    }
    
    .sidebar-nav a {
        flex-direction: column;
        gap: 5px;
        padding: 10px;
        font-size: 11px;
        text-align: center;
        border-radius: 8px;
    }
    
    .sidebar-nav a:hover {
        transform: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .row {
        flex-direction: column;
    }
    
    .form-row {
        flex-direction: column;
    }
}