/* ==================================================
   CORE CRM — Variáveis, Reset, Layout Base
================================================== */

/* ------------------------------------------
   VARIÁVEIS GLOBAIS E TEMA PADRÃO (CLARO)
------------------------------------------ */
:root {
    /* Base — Landing palette */
    --crm-bg: #F8FAFC;
    --crm-column: #F1F5F9;
    --crm-card: #ffffff;
    --crm-border: #E2E8F0;

    /* Radius — Landing style */
    --crm-radius-xs: 8px;
    --crm-radius-sm: 10px;
    --crm-radius-md: 12px;
    --crm-radius-lg: 16px;
    --crm-radius-xl: 20px;
    --crm-radius-pill: 999px;

    /* Espaçamento */
    --crm-space-1: .25rem;
    --crm-space-2: .5rem;
    --crm-space-3: .75rem;
    --crm-space-4: 1rem;
    --crm-space-5: 1.5rem;
    --crm-space-6: 2rem;
    --crm-space-7: 2.5rem;

    /* Tipografia */
    --crm-font-xs: .70rem;
    --crm-font-sm: .82rem;
    --crm-font-md: .95rem;
    --crm-font-lg: 1.1rem;
    --crm-font-xl: 1.4rem;
    --crm-font-2xl: 1.8rem;

    /* Texto — Landing palette */
    --crm-text: #0F172A;
    --crm-muted: #64748B;

    /* Identidade CRM */
    --crm-primary: #121e38;
    --crm-primary-soft: #dbeafe;

    --crm-success: #16a34a;
    --crm-success-soft: #dcfce7;

    --crm-warning: #f59e0b;
    --crm-warning-soft: #fef3c7;

    --crm-danger: #ef4444;
    --crm-danger-soft: #fee2e2;

    /* Estados — Landing style */
    --crm-hover: rgba(37, 99, 235, .06);
    --crm-active: rgba(37, 99, 235, .12);
    --crm-focus: 0 0 0 .22rem rgba(37, 99, 235, .15);

    /* Sombras — Landing style (mais suaves e premium) */
    --crm-shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --crm-shadow-sm: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .05);
    --crm-shadow-md: 0 4px 16px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
    --crm-shadow-lg: 0 8px 32px rgba(15, 23, 42, .08), 0 18px 48px rgba(15, 23, 42, .06);
    --crm-shadow: var(--crm-shadow-sm);

    /* Transições */
    --crm-transition-fast: .12s ease;
    --crm-transition: .18s ease;
    --crm-transition-slow: .28s ease;

    /* Z-index */
    --crm-z-dropdown: 1000;
    --crm-z-sticky: 1010;
    --crm-z-fixed: 1020;
    --crm-z-modal: 1055;
    --crm-z-toast: 1080;
}

/* DARK MODE */
[data-bs-theme="dark"] {
    --crm-bg: #0f172a;
    --crm-column: #1e293b;
    --crm-card: #111827;
    --crm-border: #334155;

    --crm-text: #f1f5f9;
    --crm-muted: #94a3b8;

    --crm-shadow:
        0 1px 2px rgba(0, 0, 0, .30),
        0 4px 12px rgba(0, 0, 0, .20);
    --crm-hover: rgba(255, 255, 255, .05);
    --crm-active: rgba(255, 255, 255, .08);
    --crm-focus: 0 0 0 .22rem rgba(255, 255, 255, .15);
}

/* ------------------------------------------
   BASE E LAYOUT PRINCIPAL
------------------------------------------ */
html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--crm-bg);
    overflow: hidden;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--crm-text);
    font-size: var(--crm-font-md);
}

/* Layout flexível para sidebar + main */
.crm-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.crm-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

.crm-content.m-0.p-0,
.crm-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--crm-space-5);
    min-height: 0;
}

/* Wrapper do Dashboard (se o HTML utilizar) */
.dashboard-page {
    width: 100%;
    min-height: 100%;
}

/* Componentes base */
.crm-card-base {
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-md);
    box-shadow: var(--crm-shadow);
}

.crm-panel-base {
    background: var(--crm-column);
    border-radius: var(--crm-radius-lg);
}

.crm-badge-base {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--crm-radius-pill);
    padding: 0 var(--crm-space-2);
    font-size: var(--crm-font-sm);
}

.crm-input-base {
    border-radius: var(--crm-radius-sm);
    border: 1px solid var(--crm-border);
    transition: border-color var(--crm-transition), box-shadow var(--crm-transition);
}

.crm-avatar-base {
    border-radius: var(--crm-radius-pill);
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.crm-transition {
    transition: all var(--crm-transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--crm-primary);
    box-shadow: var(--crm-focus);
    outline: none;
}

/* ------------------------------------------
   SCROLLBAR PERSONALIZADA
------------------------------------------ */
::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 999px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

.kanban-cards {
    scrollbar-width: thin;
}

/* ------------------------------------------
   SKELETON LOADING
------------------------------------------ */
.skeleton,
.skeleton-card {
    position: relative;
    overflow: hidden;
    background: #e5e7eb;
}

.skeleton::after,
.skeleton-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150px;
    width: 150px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
    100% {
        left: 100%;
    }
}

.skeleton-title {
    height: 18px;
    width: 120px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.skeleton-small {
    height: 12px;
    width: 70px;
    border-radius: 6px;
}

.skeleton-card {
    height: 110px;
    border-radius: 12px;
    margin-bottom: 12px;
}

/* ------------------------------------------
   FONT AWESOME ALINHAMENTO
------------------------------------------ */
.crm-nav-item i {
    width: 18px;
    text-align: center;
    margin-right: 10px;
}

.btn i {
    margin-right: 4px;
}

.task-badge i {
    margin-right: 4px;
}

/* ------------------------------------------
   DARK MODE BASE (ajustes gerais)
------------------------------------------ */
[data-bs-theme="dark"] body {
    background: var(--crm-bg);
}

/* ------------------------------------------
   Sidebar: userSettings como "rodapé"
------------------------------------------ */
#userSettingsBtn {
    position: sticky;
    bottom: 0;
    width: 100%;
    z-index: var(--crm-z-sticky);
}

/* Opcional: garante separação visual quando virar rodapé */
#userSettingsBtn .crm-user {
    width: 100%;
}

/* ── Mobile padding inferior global ── */
/* +50px extra para compensar botões de navegação do mobile que tapam a parte inferior */
@media (max-width: 991.98px) {
    .crm-content {
        padding-bottom: 50px !important;
    }
}
