/* 
 * Custom Premium Design Tokens & Overrides - Chat na Nuvem (Tema Preferencialmente Claro)
 */

:root {
    --bg-color: #f2f2f7;
    --text-color: #1c1c1e;
    --text-muted: #8e8e93;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --border-color: #e5e5ea;
    --primary-color: #007aff; /* Azul Cobalto do Mockup */
    --primary-gradient: linear-gradient(135deg, #007aff 0%, #00a0ff 100%);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.05);
    --font-family: 'Outfit', sans-serif;
    --sidebar-width: 260px;
    --active-nav-bg: rgba(0, 122, 255, 0.08);
    --active-nav-color: #007aff;
    --chat-inbound-bg: #f2f2f7;
    --chat-inbound-text: #1c1c1e;
    --chat-outbound-bg: #007aff;
    --chat-outbound-text: #ffffff;
}

.dark-mode {
    --bg-color: #1c1c1e;
    --text-color: #f2f2f7;
    --text-muted: #8e8e93;
    --sidebar-bg: #1c1c1e;
    --card-bg: #2c2c2e;
    --border-color: #3a3a3c;
    --primary-color: #0a84ff;
    --primary-gradient: linear-gradient(135deg, #0a84ff 0%, #30d158 100%); /* Mantém coerência */
    --primary-gradient: linear-gradient(135deg, #0a84ff 0%, #64d2ff 100%);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --active-nav-bg: rgba(10, 132, 255, 0.15);
    --active-nav-color: #64d2ff;
    --chat-inbound-bg: #2c2c2e;
    --chat-inbound-text: #f2f2f7;
    --chat-outbound-bg: #0a84ff;
    --chat-outbound-text: #ffffff;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* Glassmorphism/Premium containers */
.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.bg-gradient-primary {
    background: var(--primary-gradient) !important;
}

/* Custom Navigation */
.navbar-custom {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: 70px;
    z-index: 99;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease, border-color 0.25s ease;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding-top: 0px; /* Ajustado para começar do topo com a marca */
    z-index: 100;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.sidebar .nav-link {
    color: var(--text-muted);
    padding: 12px 20px;
    border-radius: 12px;
    margin: 4px 16px;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.sidebar .nav-link:hover, .sidebar .nav-link.active {
    background: var(--active-nav-bg);
    color: var(--active-nav-color);
}

.main-content {
    margin-left: var(--sidebar-width);
    padding-top: 96px;
    padding-right: 28px;
    padding-left: 28px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Chat Layout - Three Columns */
.chat-container {
    height: calc(100vh - 126px);
    display: flex;
    overflow: hidden;
    gap: 20px;
}

.chat-col-1 {
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-col-2 {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-col-3 {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Conversations List */
.conversation-list {
    overflow-y: auto;
    flex: 1;
}

.conversation-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
    margin: 6px 12px;
}

.conversation-item:hover {
    background: rgba(0, 122, 255, 0.04);
}

.dark-mode .conversation-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.conversation-item.active {
    background: var(--active-nav-bg);
    border-left: 4px solid var(--primary-color);
    color: var(--active-nav-color);
}

/* Messages area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--border-color);
}

.dark-mode .messages-area {
    background: rgba(0, 0, 0, 0.2);
}

.message-bubble {
    max-width: 70%;
    margin-bottom: 16px;
    padding: 12px 18px;
    border-radius: 16px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.message-inbound {
    background-color: var(--chat-inbound-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    color: var(--chat-inbound-text);
}

.message-outbound {
    background: var(--primary-gradient);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    color: var(--chat-outbound-text);
}

.message-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
}

.message-outbound .message-meta {
    color: rgba(255, 255, 255, 0.7);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}
.dark-mode ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

/* Interactive elements */
.btn-premium {
    background: var(--primary-gradient);
    border: none;
    color: white !important;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-premium:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(0, 122, 255, 0.25);
}

.btn-premium:active {
    transform: translateY(0);
}

/* Forms override */
.form-control, .form-select {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 10px;
    padding: 10px 14px;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--card-bg);
    color: var(--text-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* Simulator Phone mock */
.simulator-phone {
    max-width: 380px;
    height: 680px;
    border: 12px solid #1e293b;
    border-radius: 36px;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.dark-mode .simulator-phone {
    border-color: #334155;
}

.phone-header {
    background: #1e293b;
    padding: 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Tables style */
.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(0, 122, 255, 0.02);
    --bs-table-striped-bg: rgba(0, 0, 0, 0.005);
    color: var(--text-color);
    border-color: var(--border-color);
}

.dark-mode .table {
    --bs-table-hover-bg: rgba(255, 255, 255, 0.02);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.005);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
}

/* Cards KPI styling */
.card-kpi {
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Dark mode toggle switch button */
.theme-switch-btn {
    cursor: pointer;
    background: none;
    border: none;
    padding: 8px;
    color: var(--text-muted);
    font-size: 1.25rem;
    transition: color 0.2s ease;
}

.theme-switch-btn:hover {
    color: var(--primary-color);
}

/* ==========================================================================
   COLLAPSIBLE SIDEBAR & PRIMARY THEME FOR SUPER ADMIN
   ========================================================================== */

/* Transições suaves */
.sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease, border-color 0.25s ease !important;
}

.main-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Estado Recolhido */
.sidebar.collapsed {
    width: 80px !important;
}

.sidebar.collapsed .nav-text {
    display: none !important;
}

.sidebar.collapsed .nav-link {
    text-align: center;
    padding: 12px 0;
    margin: 4px 12px;
}

.sidebar.collapsed .nav-link i {
    font-size: 1.25rem;
    margin-right: 0 !important;
}

.main-content.expanded {
    margin-left: 80px !important;
}

.sidebar.collapsed ~ .navbar-custom {
    left: 80px !important;
    width: calc(100% - 80px) !important;
}

/* Tema da Sidebar Primária (Super Admin) */
.sidebar-primary {
    background: var(--primary-color) !important;
    border-right: none !important;
}

.sidebar-primary .nav-link,
.sidebar-primary .nav-link i {
    color: rgba(255, 255, 255, 0.8) !important;
}

.sidebar-primary .nav-link:hover,
.sidebar-primary .nav-link:hover i {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

.sidebar-primary .nav-link.active,
.sidebar-primary .nav-link.active i {
    background-color: rgba(255, 255, 255, 0.18) !important; /* Translúcido mais claro premium */
    color: #ffffff !important;
    border-left: none !important;
    border-radius: 12px !important;
    box-shadow: none !important;
}

/* Header Navbar Collapsible Toggle Button */
.sidebar-toggle-btn {
    cursor: pointer;
    background: none;
    border: none;
    padding: 8px;
    color: var(--text-color);
    font-size: 1.1rem;
    transition: color 0.2s ease;
}

.sidebar-toggle-btn:hover {
    color: var(--primary-color);
}

/* Sidebar Brand Area */
.sidebar-brand {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-primary .sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

.sidebar-primary .sidebar-brand .navbar-brand {
    color: #ffffff !important;
}

/* Brand Area in Collapsed state */
.sidebar.collapsed .sidebar-brand {
    justify-content: center !important;
    padding: 0 !important;
}

.sidebar.collapsed .sidebar-brand .nav-text {
    display: none !important;
}

.sidebar.collapsed .sidebar-brand .navbar-brand {
    margin-right: 0 !important;
    font-size: 1.2rem;
}

/* Garante padding adequado na lista interna da sidebar sem o cabeçalho global antigo */
.sidebar .nav {
    padding-top: 16px;
}

/* ==========================================================================
   DARK MODE OVERRIDES & CONTRAST FIXES
   ========================================================================== */

/* Ajuste da sidebar primária (Super Admin) no Modo Escuro */
.dark-mode .sidebar-primary {
    background: #111827 !important; /* Slate cinza escuro premium */
    border-right: 1px solid var(--border-color) !important;
}

.dark-mode .sidebar-primary .sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: var(--text-color) !important;
}

.dark-mode .sidebar-primary .sidebar-brand .navbar-brand {
    color: var(--text-color) !important;
}

.dark-mode .sidebar-primary .nav-link {
    color: rgba(255, 255, 255, 0.6) !important;
}

.dark-mode .sidebar-primary .nav-link i {
    color: rgba(255, 255, 255, 0.6) !important;
}

.dark-mode .sidebar-primary .nav-link:hover,
.dark-mode .sidebar-primary .nav-link:hover i {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}

.dark-mode .sidebar-primary .nav-link.active,
.dark-mode .sidebar-primary .nav-link.active i {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--primary-color) !important;
}

/* Correções de Contraste para Botões e inputs no Modo Escuro */
.dark-mode .btn-light {
    background-color: #2c2c2e !important;
    border-color: #3a3a3c !important;
    color: #f2f2f7 !important;
}

.dark-mode .btn-light:hover {
    background-color: #3a3a3c !important;
    color: #ffffff !important;
}

.dark-mode .table {
    color: var(--text-color) !important;
}

.dark-mode .table th {
    color: var(--text-muted) !important;
}

.dark-mode select.form-select option {
    background-color: #2c2c2e !important;
    color: #f2f2f7 !important;
}

.dark-mode input.form-control::placeholder {
    color: rgba(255, 255, 255, 0.3) !important;
}



