/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #e63946;
    --primary-hover: #d62839;
    --secondary: #4a5568;
    --background: #f5f7fa;
    --surface: #ffffff;
    --surface-hover: #f0f4f8;
    --border: #e2e8f0;
    --text: #2d3748;
    --text-muted: #718096;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --accent: #667eea;
    --gradient-start: #e63946;
    --gradient-end: #3b82f6;
    
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
}

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1a202c 0%, #2d3748 100%);
    border-right: none;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-img {
    max-width: 180px;
    height: auto;
}

.sidebar-logo {
    font-size: 1.5rem;
}

.sidebar-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.nav-link.active {
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    color: #ffffff;
    border-radius: 0 25px 25px 0;
    margin-right: 1rem;
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-icon {
    font-size: 1.1rem;
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 0.75rem 1.5rem;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
}

.topbar-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.topbar-actions {
    margin-left: auto;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.connection-status.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.connection-status.disconnected .status-dot {
    background: var(--danger);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2,
.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(90deg, var(--primary-hover), #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--surface-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    transition: border-color 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-actions {
    margin-top: 1.5rem;
}

/* ===== TABLES ===== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.table tbody tr:hover {
    background: var(--surface-hover);
}

.table-responsive {
    overflow-x: auto;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background: var(--surface-hover);
    color: var(--text);
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-secondary {
    background: var(--surface-hover);
    color: var(--text-muted);
}

.badge-outline {
    background: transparent;
    border: 1px solid var(--border);
}

/* ===== ALERTS ===== */
.alert {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-icon {
    font-size: 1.25rem;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-lg {
    max-width: 640px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s ease;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--text-muted);
}

.full-height {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===== CHAT LAYOUT ===== */
.chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1rem;
    height: calc(100vh - var(--topbar-height) - 3rem);
}

.chat-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.chat-list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.search-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
}

.chat-list-items {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}

.chat-item:hover {
    background: var(--surface-hover);
}

.chat-item.active {
    background: var(--primary);
    color: white;
}

.chat-item.active .chat-name,
.chat-item.active .chat-preview,
.chat-item.active .chat-time {
    color: white;
}

.chat-item.active .chat-avatar {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 500;
    margin-bottom: 0.125rem;
}

.chat-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-meta {
    text-align: right;
}

.chat-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-badge {
    display: inline-block;
    min-width: 20px;
    padding: 0.125rem 0.375rem;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-align: center;
    margin-top: 0.25rem;
}

.chat-messages {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.chat-messages-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.chat-header-info .chat-header-name {
    font-weight: 600;
    color: var(--text);
}

.chat-header-info .chat-header-phone {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.message {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
}

.message.sent {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.sent .message-time,
.message.sent .message-status,
.message.sent .message-content {
    color: white;
}

.message.sent .btn-delete-msg {
    color: rgba(255, 255, 255, 0.7);
}

.message.sent .btn-delete-msg:hover {
    color: white;
}

.message.received {
    background: var(--surface-hover);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.received .message-time {
    color: var(--text-muted);
}

/* Estilos para mídia em mensagens enviadas */
.message.sent .btn-media {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message.sent .btn-media:hover {
    background: rgba(255, 255, 255, 0.3);
}

.message.sent .doc-nome,
.message.sent .doc-icon {
    color: white;
}

.message.sent .media-container.documento {
    background: rgba(255, 255, 255, 0.1);
}

/* Estilos para mídia em mensagens recebidas */
.message.received .message-content,
.message.received .doc-nome,
.message.received .doc-icon {
    color: var(--text);
}

.message.received .btn-media {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text);
}

.message.received .btn-media:hover {
    background: rgba(0, 0, 0, 0.2);
}

.message-time {
    font-size: 0.625rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}

/* ===== DATABASE LAYOUT ===== */
.db-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1rem;
    height: calc(100vh - var(--topbar-height) - 6rem);
}

.db-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.db-sidebar h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.table-list {
    list-style: none;
}

.table-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: background 0.15s ease;
}

.table-list li a:hover {
    background: var(--surface-hover);
}

.table-list li a.active {
    background: var(--primary);
    color: white;
}

.table-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.db-content {
    overflow: hidden;
}

/* ===== PROGRESS LOG ===== */
.progress-log {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1rem;
    font-family: monospace;
    font-size: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.log-item {
    padding: 0.25rem 0;
}

.log-item.success {
    color: var(--success);
}

.log-item.error {
    color: var(--danger);
}

.log-item.warning {
    color: var(--warning);
}

.log-num {
    color: var(--text-muted);
    margin-right: 0.75rem;
}

/* ===== UTILITIES ===== */
.text-muted {
    color: var(--text-muted);
}

.text-danger {
    color: var(--danger);
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.full-width {
    grid-column: 1 / -1;
}

/* ===== DEPARTMENT SPECIFIC ===== */
.dept-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dept-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.dept-meta {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dept-meta code {
    background: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

/* ===== CLIENT INFO ===== */
.client-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.client-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

/* ===== TEMPLATE CARD ===== */
.template-preview {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.template-vars {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.template-vars code {
    background: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* ===== RESPOSTA ITEM ===== */
.respostas-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.resposta-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.resposta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.resposta-header h4 {
    font-size: 1rem;
    font-weight: 600;
}

.resposta-body {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.resposta-condition,
.resposta-action {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.resposta-footer {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .chat-layout {
        grid-template-columns: 1fr;
    }
    
    .chat-messages {
        display: none;
    }
    
    .chat-layout.chat-open .chat-list {
        display: none;
    }
    
    .chat-layout.chat-open .chat-messages {
        display: flex;
    }
    
    .db-layout {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .page-header-content {
        flex-direction: column;
    }
}
/* ===== STATUS INDICATOR ===== */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
}

.status-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== CLOCK ===== */
.clock-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: 1rem;
}

.clock-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.clock-time {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: monospace;
}

/* ===== SWITCH TOGGLE ===== */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.rotinas-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-menu {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
}

.btn-menu:hover {
    background: var(--surface-hover);
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-refresh:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
/* Estilos para mensagens de conversa */
.message-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.message-status {
    font-size: 12px;
    color: #999;
}

.message-status.read {
    color: #53bdeb;
}

.btn-delete-msg {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 2px 4px;
}

.message:hover .btn-delete-msg {
    opacity: 0.6;
}

.btn-delete-msg:hover {
    opacity: 1 !important;
}
/* Estilos para mídia nas mensagens */
.media-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 300px;
}

.media-container.audio {
    flex-direction: row;
    align-items: center;
}

.media-container.documento {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    background: rgba(0,0,0,0.05);
    padding: 10px;
    border-radius: 8px;
    gap: 10px;
}

.media-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.media-image:hover {
    transform: scale(1.02);
}

.media-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
}

.media-audio {
    width: 200px;
    height: 40px;
}

.media-sticker {
    max-width: 150px;
    max-height: 150px;
}

.media-actions {
    display: flex;
    gap: 8px;
}

.btn-media {
    background: rgba(0,0,0,0.1);
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.btn-media:hover {
    background: rgba(0,0,0,0.2);
}

.media-caption {
    font-size: 13px;
    margin-top: 5px;
}

.doc-icon {
    font-size: 32px;
}

.doc-nome {
    flex: 1;
    word-break: break-all;
    font-size: 13px;
}

.media-container.localizacao {
    cursor: pointer;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    overflow: hidden;
}

.loc-preview {
    display: flex;
    flex-direction: column;
}

.loc-map {
    width: 100%;
    border-radius: 8px 8px 0 0;
}

.loc-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.loc-info small {
    color: #666;
    font-size: 11px;
}

/* Modal de mídia */
.media-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.media-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.media-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 8px;
}

.media-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 35px;
    cursor: pointer;
}

.media-modal-close:hover {
    color: #ccc;
}
/* Abas de filtro de conversas */
.chat-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.chat-tab {
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    background: transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-tab:hover {
    background: var(--surface-hover);
}

.chat-tab.active {
    background: var(--primary);
    color: white;
}

.tab-badge {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    color: var(--text);
}

.chat-tab.active .tab-badge {
    background: rgba(255,255,255,0.3);
    color: white;
}

.header-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.chat-header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

.btn-warning {
    background: #f0ad4e;
    color: #333;
}

.btn-warning:hover {
    background: #ec971f;
}

.btn-success {
    background: #5cb85c;
    color: white;
}

.btn-success:hover {
    background: #449d44;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.chat-avatar.archived {
    opacity: 0.6;
    background: #999;
}

.chat-status.archived {
    font-size: 12px;
}
/* Botão para carregar mensagens antigas */
.load-older-messages {
    text-align: center;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background: #f5f5f5;
    position: sticky;
    top: 0;
    z-index: 10;
}

.load-older-messages button {
    background: #6c757d;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    font-size: 13px;
}

.load-older-messages button:hover {
    background: #5a6268;
}
/* Botão para carregar mensagens antigas */
.load-older-messages {
    text-align: center;
    padding: 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.load-older-messages button {
    background: linear-gradient(90deg, var(--secondary), #5a6268);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.load-older-messages button:hover:not(:disabled) {
    background: linear-gradient(90deg, #5a6268, var(--secondary));
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.load-older-messages button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}
/* Estilos para seleção múltipla de conversas */
.chat-item {
    display: flex;
    align-items: center;
}

.chat-item .conversa-checkbox {
    flex-shrink: 0;
    accent-color: #007bff;
}

.chat-item-content {
    display: flex;
    flex: 1;
    align-items: center;
    min-width: 0;
}

.selecao-multipla-bar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.selecao-multipla-bar .btn {
    white-space: nowrap;
}

/* Destaque visual quando selecionado */
.chat-item:has(.conversa-checkbox:checked) {
    background-color: #e3f2fd;
}