/* ==========================================================================
   Design System - AXIA ERP (Atualizado para SPA)
   ========================================================================== */

:root {
    /* Paleta de Cores Primárias (Baseadas no Logo) */
    --primary-blue: #0A2640; 
    --primary-teal: #228E95;
    --primary-blue-light: #1A3C5E;
    
    /* Cores de Fundo e Texto */
    --bg-app: #F5F7FA;
    --bg-surface: #FFFFFF;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-tertiary: #94A3B8;
    --border-color: #E2E8F0;
    
    /* Cores Semânticas (Status) */
    --success: #10B981;
    --success-bg: #D1FAE5;
    --danger: #EF4444;
    --danger-bg: #FEE2E2;
    --warning: #F59E0B;
    --warning-bg: #FEF3C7;
    --info: #3B82F6;
    --info-bg: #DBEAFE;
    
    /* Sombras & Arredondamentos */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --radius-md: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Layout Principal (SPA)
   ========================================================================== */
.dashboard-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.logo-container {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.logo {
    max-width: 140px;
    height: auto;
}

.nav-group {
    margin-bottom: 20px;
}

.nav-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    font-weight: 600;
    padding: 0 24px;
    margin-bottom: 8px;
}

.main-menu ul {
    list-style: none;
}

.main-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
}

.main-menu li a i {
    font-size: 20px;
}

.main-menu li a:hover {
    background-color: var(--bg-app);
    color: var(--primary-blue);
}

.main-menu li.active a {
    background-color: #F0F9FA;
    color: var(--primary-teal);
    border-right-color: var(--primary-teal);
    font-weight: 600;
}

/* ==========================================================================
   Área Principal & Topbar (Ajustado para SPA)
   ========================================================================== */
.main-content {
    padding: 24px 32px 32px 32px;
    overflow-x: hidden;
    flex: 1;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    background-color: var(--bg-app);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    width: 400px;
    transition: border-color 0.2s;
}

.search-bar:focus-within {
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 2px rgba(34, 142, 149, 0.1);
}

.search-bar i {
    color: var(--text-tertiary);
    font-size: 18px;
    margin-right: 10px;
}

.search-bar input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 14px;
    outline: none;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.action-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.action-btn:hover { color: var(--primary-blue); }

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    height: 16px;
    min-width: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Alterado para que apenas a seta seja clicável */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 24px;
    border-left: 1px solid var(--border-color);
}

.dropdown-trigger-icon {
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.dropdown-trigger-icon:hover {
    background-color: var(--border-color);
    color: var(--primary-blue);
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-blue);
}

.user-role {
    font-size: 12px;
    color: var(--text-tertiary);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: contain;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 2px;
}

/* ==========================================================================
   NOVO: Menus Suspensos (Dropdowns Topbar)
   ========================================================================== */
.dropdown-container {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 12px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 320px;
    z-index: 100;
    animation: modalSlideIn 0.2s ease;
}

.dropdown-menu.show {
    display: block;
}

.profile-menu {
    width: 200px;
}

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-header h4 {
    font-size: 14px;
    color: var(--primary-blue);
    font-weight: 600;
}

.dropdown-content {
    max-height: 320px;
    overflow-y: auto;
}

.dropdown-item {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: var(--bg-app);
}

.dropdown-item i {
    font-size: 20px;
    color: var(--text-secondary);
}

.dropdown-item p {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.dropdown-item span {
    font-size: 11px;
    color: var(--text-tertiary);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

.dropdown-footer {
    padding: 12px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-app);
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

.dropdown-footer a {
    color: var(--primary-teal);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.dropdown-footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Cabeçalho da Página
   ========================================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    color: var(--primary-blue);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.page-actions {
    display: flex;
    gap: 12px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-blue);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-blue-light);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-app);
}

/* ==========================================================================
   KPI Cards
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    background-color: var(--bg-surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.kpi-header h3 {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.kpi-icon {
    font-size: 24px;
    padding: 8px;
    border-radius: var(--radius-md);
    background-color: var(--bg-app);
}

.text-blue { color: var(--primary-blue); }
.text-teal { color: var(--primary-teal); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 12px;
}

.kpi-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

.trend.positive { background-color: var(--success-bg); color: var(--success); }
.trend.negative { background-color: var(--danger-bg); color: var(--danger); }
.trend-label { color: var(--text-tertiary); }

/* ==========================================================================
   Gráficos e Estrutura Inferior
   ========================================================================== */
.charts-grid {
    margin-bottom: 24px;
}

.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 16px;
    color: var(--primary-blue);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
}

.chart-placeholder {
    padding: 40px 24px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 250px;
}

/* Simulando Gráfico de Barras para UI Design */
.placeholder-bars {
    display: flex;
    gap: 20px;
    height: 100%;
    align-items: flex-end;
}
.bar {
    width: 40px;
    background-color: var(--primary-teal);
    border-radius: 4px 4px 0 0;
    opacity: 0.8;
}
.h-60 { height: 60%; }
.h-80 { height: 80%; }
.h-40 { height: 40%; background-color: var(--primary-blue); }
.h-100 { height: 100%; }
.h-70 { height: 70%; }

/* ==========================================================================
   Alertas e Timeline
   ========================================================================== */
.bottom-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
}

.alerts-list { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.alert-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid;
}

.alert-icon {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-content strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.alert-content p {
    font-size: 13px;
    color: var(--text-secondary);
}

.alert-item.danger {
    background-color: var(--danger-bg);
    border-left-color: var(--danger);
    color: #991B1B;
}
.alert-item.danger p { color: #991B1B; }

.alert-item.warning {
    background-color: var(--warning-bg);
    border-left-color: var(--warning);
    color: #92400E;
}
.alert-item.warning p { color: #92400E; }

.alert-item.info {
    background-color: var(--info-bg);
    border-left-color: var(--info);
    color: #1E40AF;
}
.alert-item.info p { color: #1E40AF; }

/* Timeline */
.activity-timeline {
    padding: 24px;
    position: relative;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 31px;
    top: 30px;
    bottom: 30px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.timeline-item:last-child { margin-bottom: 0; }

.timeline-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--border-color);
    border: 3px solid var(--bg-surface);
    margin-top: 4px;
}

.bg-teal { background-color: var(--primary-teal); }
.bg-blue { background-color: var(--primary-blue); }
.bg-warning { background-color: var(--warning); }

.timeline-content p {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.timeline-content .time {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ==========================================================================
   Tabelas & Badges (CRM / Data)
   ========================================================================== */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, 
.data-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table th {
    background-color: var(--bg-app);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background-color: var(--bg-app);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges de Status */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-active { background-color: var(--success-bg); color: var(--success); }
.status-inactive { background-color: var(--danger-bg); color: var(--danger); }
.status-lead { background-color: var(--info-bg); color: var(--info); }

/* Botões de Ação na Tabela */
.action-icons {
    display: flex;
    gap: 8px;
}

.action-icons button {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-icons button:hover {
    color: var(--primary-blue);
    border-color: var(--primary-blue);
    background-color: var(--bg-app);
}

/* ==========================================================================
   Modais e Funil Kanban
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background-color: rgba(10, 38, 64, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 95%;
    max-width: 1280px;
    max-height: 90vh; 
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.kanban-modal-content {
    height: 85vh;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 {
    color: var(--primary-blue);
    font-size: 20px;
}

.modal-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.close-modal:hover { color: var(--danger); }

/* Grid / Área do Kanban */
.kanban-board {
    display: flex;
    gap: 24px;
    padding: 24px;
    overflow-x: auto;
    flex: 1;
    background-color: var(--bg-app);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.kanban-column {
    background-color: #E2E8F0;
    border-radius: var(--radius-md);
    min-width: 320px;
    width: 320px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    padding: 16px;
    background-color: var(--bg-surface);
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-column-header h3 {
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-count {
    background-color: var(--border-color);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.kanban-cards {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    overflow-y: auto;
    min-height: 150px;
}

/* Cards do Kanban */
.kanban-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.kanban-card:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-teal);
}

.kanban-card h4 {
    font-size: 14px;
    color: var(--primary-blue);
    margin-bottom: 8px;
}

.kanban-card p {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 12px;
}

.card-tag {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 12px;
}

.tag-new { background-color: var(--info-bg); color: var(--info); }
.tag-hot { background-color: var(--danger-bg); color: var(--danger); }
.tag-waiting { background-color: var(--warning-bg); color: #B45309; }
.tag-won { background-color: var(--success-bg); color: var(--success); }

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px dashed var(--border-color);
    padding-top: 12px;
}

.card-actions button {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 18px;
    transition: color 0.2s;
}

.card-actions button:hover {
    color: var(--danger);
}

/* ==========================================================================
   Formulários e Modal de Cadastro
   ========================================================================== */
.modal-body {
    padding: 24px;
    overflow-y: auto; 
    max-height: calc(90vh - 85px); 
}

.section-title {
    margin: 20px 0 16px 0;
    color: var(--primary-blue);
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.section-title:first-child {
    margin-top: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--bg-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(34, 142, 149, 0.15);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 24px;
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   Estados de Erro (Error State)
   ========================================================================== */
.error-state-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 180px);
    padding: 24px;
    width: 100%;
}

.error-content {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    padding: 48px 40px;
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: modalSlideIn 0.3s ease;
}

.error-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--warning-bg);
    color: var(--warning);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin-bottom: 24px;
}

.error-content h1 {
    font-size: 24px;
    color: var(--primary-blue);
    margin-bottom: 12px;
}

.error-content p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 32px;
}

.error-actions {
    display: flex;
    gap: 16px;
    width: 100%;
    justify-content: center;
}

.error-actions .btn {
    flex: 1; 
    max-width: 200px;
}

/* ==========================================================================
   Modais Menores (Confirmações)
   ========================================================================== */
.confirm-modal-content {
    max-width: 420px;
    padding: 0;
}