/* === OncoProd - CSS v3.1 === */
:root {
    --primary: #3C5C76;
    --primary-dark: #2E4A5F;
    --secondary: #AF9773;
    --accent: #E6CCA9;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --navbar-height: 60px;
    --transition-speed: 0.3s;
    --border-color: #e5e7eb;
    --light-bg: #f8f9fa;
    --dark-text: #1f2937;
    --muted-text: #6b7280;
    /* Status / Semáforo */
    --status-verde: #22c55e;
    --status-verde-bg: #dcfce7;
    --status-verde-text: #16a34a;
    --status-amarelo: #eab308;
    --status-amarelo-bg: #fef9c3;
    --status-amarelo-text: #ca8a04;
    --status-laranja: #f97316;
    --status-laranja-bg: #ffedd5;
    --status-laranja-text: #ea580c;
    --status-vermelho: #ef4444;
    --status-vermelho-bg: #fee2e2;
    --status-vermelho-text: #dc2626;
}

* { box-sizing: border-box; }

/* === 2026-05-06: GLOBAL LOADING OVERLAY ===
   Animacao "tela carregando" — mostrar sempre que houver carregamento pesado.
   Uso: window.OncoLoading.show('Carregando dados...') / window.OncoLoading.hide() */
.onco-loading-overlay {
    position: fixed; inset: 0;
    background: rgba(248, 249, 250, 0.92);
    backdrop-filter: blur(2px);
    z-index: 11000;
    display: none;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 1rem;
    animation: oncoLoadingFadeIn 0.18s ease;
}
.onco-loading-overlay.show { display: flex; }
.onco-loading-spinner {
    width: 64px; height: 64px;
    border: 4px solid #E6CCA9;
    border-top-color: #3C5C76;
    border-radius: 50%;
    animation: oncoLoadingSpin 0.8s linear infinite;
}
.onco-loading-text {
    color: #3C5C76; font-weight: 600; font-size: 0.95rem;
    text-align: center; max-width: 360px;
}
.onco-loading-subtext {
    color: #6b7280; font-size: 0.78rem; text-align: center;
}
@keyframes oncoLoadingSpin {
    to { transform: rotate(360deg); }
}
@keyframes oncoLoadingFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* === Filter applied badges bar — reusavel em todas as telas === */
.filter-active-bar {
    display: flex; flex-wrap: wrap; gap: 0.35rem;
    align-items: center;
    font-size: 0.72rem;
    margin-top: 0.5rem;
}
.filter-active-bar .filter-badge {
    background: #e0f2fe; color: #075985;
    border: 1px solid #bae6fd;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    display: inline-flex; align-items: center; gap: 0.25rem;
    font-weight: 500;
}
.filter-active-bar .filter-badge .filter-label { opacity: 0.8; font-weight: 400; }
.filter-active-bar .filter-clear-btn {
    background: #fee2e2; color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem; font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}
.filter-active-bar .filter-clear-btn:hover {
    background: #fecaca; color: #991b1b;
}

html, body {
    overflow-x: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--light-bg);
    color: var(--dark-text);
    margin: 0;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: 70px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    overflow: hidden;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    min-width: 40px;
    flex-shrink: 0;
}

.sidebar-logo svg {
    width: 100%;
    height: 100%;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
    transition: opacity var(--transition-speed), width var(--transition-speed);
    overflow: hidden;
}

.sidebar.collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
}

.sidebar-brand-text span {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-brand-text small {
    color: rgba(255,255,255,0.6);
    font-size: 0.7rem;
}

.sidebar-toggle {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.2);
}

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

.nav-section {
    color: rgba(255,255,255,0.5);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1.25rem 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-speed), height var(--transition-speed), padding var(--transition-speed);
}

.sidebar.collapsed .nav-section {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.nav-item {
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.nav-link i {
    font-size: 1.2rem;
    width: 24px;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-speed);
}

.sidebar.collapsed .nav-link span {
    opacity: 0;
    width: 0;
}

/* Tooltip para sidebar colapsada */
.sidebar.collapsed .nav-link[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--dark-text);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    margin-left: 0.5rem;
    z-index: 1060;
}

/* === OVERLAY === */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* === MAIN CONTENT === */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-speed);
    overflow-x: hidden;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* === TOP NAVBAR - FIXO/STICKY === */
.top-navbar {
    height: var(--navbar-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1040;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: left var(--transition-speed);
}

/* Ajuste quando sidebar está colapsada */
.sidebar.collapsed ~ .main-content .top-navbar {
    left: var(--sidebar-collapsed);
}


.navbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-text);
    cursor: pointer;
    padding: 0.25rem;
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.breadcrumb-nav a {
    color: var(--muted-text);
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    color: var(--primary);
}

.breadcrumb-nav i {
    font-size: 0.7rem;
    color: var(--muted-text);
}

.breadcrumb-nav span {
    color: var(--dark-text);
    font-weight: 500;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Navbar User Button - SEM BORDAS */
.navbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    border: none !important;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s;
    outline: none !important;
    box-shadow: none !important;
}

.navbar-user-btn:hover,
.navbar-user-btn:focus,
.navbar-user-btn:active {
    background: var(--light-bg);
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.navbar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.navbar-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.navbar-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--dark-text);
    line-height: 1.2;
}

.navbar-user-role {
    font-size: 0.75rem;
    color: var(--muted-text);
    display: flex;
    align-items: center;
}

.navbar-user-chevron {
    color: var(--muted-text);
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.dropdown-header {
    padding: 0.75rem 1rem;
}

/* === PAGE CONTENT === */
.page-content {
    padding: 1.5rem;
    padding-top: calc(var(--navbar-height) + 1.5rem);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-subtitle {
    color: var(--muted-text);
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* === CARDS === */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--light-bg);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
}

/* === NAV TABS - CORRIGIDO === */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
}

.nav-tabs .nav-link {
    color: var(--dark-text) !important;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1.25rem;
    font-weight: 500;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.nav-tabs .nav-link:hover {
    color: var(--primary) !important;
    border-bottom-color: var(--primary);
    background: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary) !important;
    background: transparent;
    border-bottom: 2px solid var(--primary);
}

/* === STAT CARDS === */
.stat-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    height: 100%;
}

.stat-card-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-label {
    color: var(--muted-text);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark-text);
    line-height: 1.2;
    margin: 0.25rem 0;
}

.stat-change {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
}

.stat-change.positive { color: #10b981; }
.stat-change.negative { color: #ef4444; }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.primary { background: rgba(60,92,118,0.1); color: var(--primary); }
.stat-icon.success { background: rgba(16,185,129,0.1); color: #10b981; }
.stat-icon.warning { background: rgba(245,158,11,0.1); color: #f59e0b; }
.stat-icon.info { background: rgba(59,130,246,0.1); color: #3b82f6; }
.stat-icon.danger { background: rgba(239,68,68,0.1); color: #ef4444; }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }

/* === BUTTONS === */
.btn {
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
}

/* === FORMS === */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(60,92,118,0.1);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--dark-text);
}

.form-label.required::after {
    content: " *";
    color: #ef4444;
}

.form-text {
    font-size: 0.75rem;
    color: var(--muted-text);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* === MULTISELECT === */
.multiselect-container {
    position: relative;
}

.multiselect-search {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
}

.multiselect-search:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(60,92,118,0.1);
}

.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.multiselect-dropdown.show {
    display: block;
}

.multiselect-option {
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s;
}

.multiselect-option:hover {
    background: var(--light-bg);
}

.multiselect-option.selected {
    background: rgba(60,92,118,0.1);
}

.multiselect-option input[type="checkbox"] {
    margin: 0;
}

.multiselect-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.multiselect-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
}

.multiselect-tag-remove {
    cursor: pointer;
    color: var(--muted-text);
    font-size: 1rem;
    line-height: 1;
}

.multiselect-tag-remove:hover {
    color: #ef4444;
}

/* === SEARCH BOX === */
.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-text);
}

.search-box input {
    padding-left: 2.5rem;
}

/* === TABLES === */
.table {
    margin: 0;
}

.table thead th {
    background: var(--light-bg);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--muted-text);
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table-hover tbody tr:hover {
    background: rgba(60,92,118,0.02);
}

.table-actions {
    display: flex;
    gap: 0.375rem;
}

/* === BADGES === */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-deleted { background: #fecaca; color: #991b1b; }
.badge-light { background: var(--light-bg); color: var(--dark-text); }
.badge-info { background: #dbeafe; color: #1e40af; }

/* === ALERTS === */
.alert {
    border-radius: 10px;
    border: none;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted-text);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h5 {
    color: var(--dark-text);
    margin-bottom: 0.5rem;
}

/* === PAGINATION === */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: 6px;
    color: var(--dark-text);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
}

.page-link:hover {
    background: var(--light-bg);
    color: var(--primary);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* === USER AVATAR === */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* === VISÃO 360 === */
.v360-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.v360-metric {
    text-align: center;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 10px;
}

.v360-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.v360-metric-label {
    font-size: 0.75rem;
    color: var(--muted-text);
    text-transform: uppercase;
}

.client-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

.client-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(60,92,118,0.1);
}

.client-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.client-card-name {
    font-weight: 600;
    color: var(--dark-text);
}

.client-card-type {
    font-size: 0.7rem;
}

.client-card-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.8rem;
}

.client-card-stat {
    display: flex;
    flex-direction: column;
}

.client-card-stat-value {
    font-weight: 600;
    color: var(--primary);
}

.client-card-stat-label {
    font-size: 0.65rem;
    color: var(--muted-text);
}

.rfv-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.rfv-badge.gold { background: #fef3c7; color: #92400e; }
.rfv-badge.silver { background: #e5e7eb; color: #374151; }
.rfv-badge.bronze { background: #fed7aa; color: #9a3412; }
.rfv-badge.standard { background: #dbeafe; color: #1e40af; }

/* === UTILITIES === */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-primary { color: var(--primary) !important; }
.text-muted { color: var(--muted-text) !important; }
.min-w-0 { min-width: 0; }

/* === RESPONSIVE - MOBILE FIRST === */

/* === 2026-05-05: HD Laptop (1280-1599) — maioria dos usuarios em 1366x768 ===
   No tamanho HD, sidebar 260px deixa apenas ~1106px de conteudo. Apertamos
   o layout para o conteudo respirar: sidebar mais estreita (220px), padding
   menor, fontes/cards mais compactos. */
@media (min-width: 992px) and (max-width: 1599px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; }
    .top-navbar { left: 220px; }

    /* Page-content padding apertado (a classe `.page-content` traz o padding base) */
    .page-content { padding: 1rem 0.875rem; padding-top: calc(var(--navbar-height) + 1rem); }

    /* KPIs: stat-value e stat-label um pouco menores */
    .stat-value { font-size: 1.4rem; }
    .stat-label { font-size: 0.7rem; }
    .stat-card-enhanced { padding: 0.875rem; }
    .stat-card { padding: 0.875rem; }
    .stat-card-enhanced .stat-value { font-size: 1.4rem !important; }
    .stat-card-enhanced .stat-label { font-size: 0.7rem !important; }

    /* Card headers e bodies mais compactos */
    .card-header { padding: 0.625rem 0.875rem; font-size: 0.92rem; }
    .card-body { padding: 0.875rem; }

    /* Tabelas: reduzir padding/fonte */
    .table { font-size: 0.82rem; }
    .table th, .table td { padding: 0.45rem 0.5rem; }

    /* Forms / filtros */
    .form-control, .form-select { font-size: 0.85rem; }

    /* Page header mais compacto */
    .page-header h1 { font-size: 1.4rem; }
    .page-subtitle { font-size: 0.82rem; }

    /* Charts: nao deixar os charts aumentarem demais */
    .chart-card .chart-body canvas { max-height: 320px; }
}

/* === HD Laptop estrito (1280-1366) — apertar mais, comum em notebooks === */
@media (min-width: 992px) and (max-width: 1366px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; }
    .page-content { padding: 0.875rem 0.75rem; padding-top: calc(var(--navbar-height) + 0.875rem); }
    .top-navbar { left: 200px; padding: 0 1rem; }

    .stat-value { font-size: 1.25rem; }
    .stat-label { font-size: 0.65rem; }
    .stat-card-enhanced, .stat-card { padding: 0.75rem; }
    .stat-card-enhanced .stat-value { font-size: 1.25rem !important; }
    .stat-card-enhanced .stat-label { font-size: 0.65rem !important; }
    .stat-card-enhanced .stat-icon, .stat-card .stat-icon { font-size: 1.5rem; }
    .stat-card-enhanced .stat-icon-bg { width: 56px; height: 56px; }

    .card-header { padding: 0.5rem 0.75rem; font-size: 0.88rem; }
    .card-body { padding: 0.75rem; }

    /* Forms ainda mais compactos */
    .form-label { font-size: 0.75rem; margin-bottom: 0.2rem; }
    .form-control, .form-select { font-size: 0.82rem; padding: 0.3rem 0.55rem; }
    .btn-sm, .btn { font-size: 0.82rem; }

    /* Tabela mais densa */
    .table { font-size: 0.78rem; }
    .table th, .table td { padding: 0.4rem 0.45rem; }

    /* Sidebar nav links mais apertados */
    .sidebar .nav-link { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
    .sidebar .nav-link i { font-size: 1rem; }

    /* Remover badges/chips que ocupavam muito espaco horizontal */
    .badge { font-size: 0.65rem; }

    /* Page header */
    .page-header h1 { font-size: 1.25rem; }
    .page-header { margin-bottom: 0.875rem; }

    /* Charts: limite mais baixo de altura */
    .chart-card .chart-body canvas { max-height: 280px; }
}

/* Tablet (991px e abaixo) */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    /* Header fixo em mobile - ocupa toda largura */
    .top-navbar {
        left: 0 !important;
    }

    .mobile-toggle {
        display: flex;
    }

    .sidebar-toggle {
        display: none;
    }

    .navbar-user-info {
        display: none;
    }

    .navbar-user-chevron {
        display: none;
    }

    .navbar-user-btn {
        padding: 0.5rem;
    }

    /* Visao 360 - Reorganizar colunas */
    .col-lg-8, .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Mobile Medium (767px e abaixo) */
@media (max-width: 767px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .page-header h1 {
        font-size: 1.35rem;
    }

    .page-subtitle {
        font-size: 0.85rem;
    }

    .page-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .page-actions .btn {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .stat-value {
        font-size: 1.25rem !important;
    }

    .stat-label {
        font-size: 0.65rem !important;
    }

    .card-body {
        padding: 0.875rem;
    }

    .card-header {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
    }

    /* Tabelas responsivas */
    .table-responsive {
        margin: 0 -0.875rem;
        padding: 0 0.875rem;
    }

    .table {
        font-size: 0.8rem;
    }

    .table th, .table td {
        padding: 0.5rem 0.4rem;
        vertical-align: middle;
    }

    /* KPIs em grid 2x2 */
    .row.g-3 > .col-6 {
        padding: 0.375rem;
    }

    /* Stat cards mobile */
    .stat-card, .stat-card-enhanced {
        padding: 0.875rem;
    }

    .stat-card .stat-icon, .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* RFV badges */
    .rfv-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }

    /* Graficos */
    .chart-card .chart-body {
        padding: 0.75rem;
    }

    /* Welcome banner */
    .welcome-banner {
        padding: 1.25rem;
    }

    .welcome-banner h2 {
        font-size: 1.25rem;
    }
}

/* Mobile Small (575px e abaixo) */
@media (max-width: 575px) {
    .page-content {
        padding: 0.75rem;
    }

    .top-navbar {
        padding: 0 0.75rem;
        height: 50px;
    }

    .navbar-user-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    /* Cards full width */
    .card {
        border-radius: 12px;
        margin-bottom: 0.75rem;
    }

    .card-header {
        padding: 0.625rem 0.75rem;
        font-size: 0.85rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    /* Stat cards compactos */
    .stat-card-enhanced .stat-value,
    .stat-card .stat-value {
        font-size: 1.1rem !important;
    }

    .stat-card-enhanced .stat-label,
    .stat-card .stat-label {
        font-size: 0.6rem !important;
    }

    /* Botoes de acao */
    .btn-sm {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
    }

    /* Badge compact */
    .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }

    /* Pagination mobile */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .pagination .page-link {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Esconder colunas em mobile */
    .d-none-mobile {
        display: none !important;
    }

    /* Tabela compacta */
    .table th, .table td {
        padding: 0.4rem 0.3rem;
        font-size: 0.75rem;
    }

    /* Form controls */
    .form-control, .form-select {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    .form-label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
}

/* Mobile Extra Small (400px e abaixo) */
@media (max-width: 400px) {
    .page-content {
        padding: 0.5rem;
    }

    .page-header h1 {
        font-size: 1.15rem;
    }

    .stat-card-enhanced .stat-value,
    .stat-card .stat-value {
        font-size: 1rem !important;
    }

    /* Esconder icone do stat card */
    .stat-card .stat-icon,
    .stat-icon {
        display: none;
    }

    /* Ajustar grid de KPIs */
    .row.g-3 > .col-6.col-lg-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ========================================
   CHAT / AGENTE - RESPONSIVIDADE COMPLETA
   ======================================== */

/* Chat container mobile */
@media (max-width: 767px) {
    .card[style*="calc(100vh"] {
        height: calc(100vh - 160px) !important;
        min-height: 400px !important;
    }

    #chatMessages {
        padding: 0.75rem !important;
    }

    .chat-message {
        max-width: 92% !important;
    }

    .chat-message .message-content {
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
        line-height: 1.45;
    }

    /* Chat input area */
    .border-top.p-3 {
        padding: 0.75rem !important;
    }

    #chatForm {
        gap: 0.5rem;
    }

    #chatInput {
        font-size: 0.9rem;
        padding: 0.625rem 0.875rem;
    }

    #sendBtn {
        padding: 0.625rem 1rem;
    }

    /* Graficos do chat */
    .chat-chart-container {
        max-width: 100% !important;
        padding: 0.75rem;
    }

    .chat-chart-container canvas {
        max-height: 200px !important;
    }

    .chat-chart-container h6 {
        font-size: 0.85rem;
    }

    .chart-description {
        font-size: 0.75rem;
        padding: 0.4rem;
    }

    /* Botoes de sugestao no chat */
    .chat-welcome .btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
        margin: 0.2rem;
    }

    .chat-welcome .d-flex.flex-wrap {
        gap: 0.25rem !important;
    }

    /* Feedback buttons */
    .feedback-actions {
        flex-wrap: wrap;
        gap: 0.375rem;
    }

    .feedback-btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    /* Suggestion buttons no chat */
    .suggestion-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
        margin: 0.15rem;
    }

    /* Tabelas dentro do chat */
    .message-content table {
        font-size: 0.75rem;
        display: block;
        overflow-x: auto;
    }

    .message-content th, .message-content td {
        padding: 0.3rem 0.4rem;
        white-space: nowrap;
    }
}

@media (max-width: 575px) {
    .card[style*="calc(100vh"] {
        height: calc(100vh - 130px) !important;
        min-height: 350px !important;
    }

    .chat-message .message-content {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .chat-chart-container canvas {
        max-height: 180px !important;
    }

    /* Modal de grafico expandido */
    .chart-modal-body {
        height: 50vh !important;
        min-height: 300px !important;
    }
}

/* ========================================
   VISAO 360 - RESPONSIVIDADE
   ======================================== */

@media (max-width: 767px) {
    /* Stat cards da Visao 360 */
    .stat-card-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .stat-content {
        width: 100%;
    }

    /* RFV badges clicaveis */
    .rfv-clickable {
        font-size: 1.1rem !important;
        padding: 0.4rem 0.6rem !important;
    }

    /* Progress bar RFV */
    .progress {
        height: 18px !important;
    }

    /* Tabela de clientes */
    .visao360-table th:nth-child(4),
    .visao360-table td:nth-child(4),
    .visao360-table th:nth-child(5),
    .visao360-table td:nth-child(5) {
        display: none;
    }

    /* Top clientes lista */
    .list-group-item {
        padding: 0.625rem 0.75rem;
    }

    .list-group-item .fw-500 {
        font-size: 0.8rem;
    }

    /* Graficos Visao 360 */
    #salesChart, #segmentChart, #marketShareChart {
        max-height: 180px !important;
    }
}

@media (max-width: 575px) {
    /* Alert periodo */
    .alert.d-flex {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .alert .bi-calendar3 {
        display: none;
    }

    /* Filtros compactos */
    #filterPanel .row.g-3 > div {
        flex: 0 0 50%;
        max-width: 50%;
    }

    #filterPanel .col-md-1 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ========================================
   DASHBOARD - RESPONSIVIDADE
   ======================================== */

@media (max-width: 767px) {
    .welcome-banner {
        padding: 1rem;
        border-radius: 12px;
    }

    .welcome-banner h2 {
        font-size: 1.1rem;
    }

    .welcome-banner p {
        font-size: 0.85rem;
    }

    /* Activity timeline */
    .activity-timeline {
        padding-left: 1rem;
    }

    .activity-item {
        font-size: 0.85rem;
    }
}

/* ========================================
   INSIGHTS - RESPONSIVIDADE
   ======================================== */

@media (max-width: 767px) {
    .insights-box {
        padding: 0.625rem;
        font-size: 0.85rem;
    }

    .suggestions-box {
        padding: 0.625rem;
        font-size: 0.85rem;
    }
}

/* ========================================
   FORMULARIOS CRUD - RESPONSIVIDADE
   ======================================== */

@media (max-width: 767px) {
    .form-check {
        padding-left: 1.5rem;
    }

    .form-check-input {
        width: 1rem;
        height: 1rem;
    }

    .form-check-label {
        font-size: 0.85rem;
    }

    /* Acoes da tabela */
    .table-actions {
        display: flex;
        gap: 0.25rem;
    }

    .table-actions .btn {
        padding: 0.25rem 0.4rem;
    }
}

/* ========================================
   SCROLLBAR CUSTOMIZADA
   ======================================== */

/* Scrollbar para todos os containers com scroll */
.overflow-auto::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar,
#chatMessages::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.overflow-auto::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track,
#chatMessages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.overflow-auto::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb,
#chatMessages::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
    opacity: 0.6;
}

.overflow-auto::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover,
#chatMessages::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Firefox scrollbar */
.overflow-auto,
.table-responsive,
#chatMessages {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #f1f1f1;
}

/* ========================================
   ANIMACOES E TRANSICOES SUAVES
   ======================================== */

.card, .stat-card, .stat-card-enhanced, .btn, .nav-link, .list-group-item {
    transition: all 0.2s ease;
}

/* Smooth scroll para toda a pagina */
html {
    scroll-behavior: smooth;
}

/* ========================================
   TOUCH FRIENDLY - MOBILE
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    /* Aumentar area de toque */
    .btn {
        min-height: 44px;
    }

    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .list-group-item {
        min-height: 48px;
    }

    .form-control, .form-select {
        min-height: 44px;
    }

    /* Remover hover effects em touch */
    .btn:hover,
    .card:hover,
    .stat-card-enhanced:hover {
        transform: none;
    }
}

/* ── Responsive Chart Wrappers ── */
.chart-responsive-wrapper {
    position: relative;
    width: 100%;
}

/* Fix max-height on mobile for dashboard panels */
@media (max-width: 767px) {
    .dashboard-scroll-panel {
        max-height: 300px !important;
    }
}
@media (max-width: 575px) {
    .dashboard-scroll-panel {
        max-height: 250px !important;
    }
}

/* === PRINT === */
@media print {
    .sidebar, .top-navbar, .page-actions { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
}
