:root {
    /* Cores e Temas */
    --primary: #0d6efd;
    --secondary: #6c757d;
    --success: #198754;
    --info: #0dcaf0;
    --warning: #ffc107;
    --danger: #dc3545;
    --light: #f8f9fa;
    --dark: #212529;
    
    /* Densidade e Espaçamento */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --appbar-h: 56px;
    --topnav-h: 48px; /* Reduzido de 52px */
    --bottomnav-h: 60px;
    
    /* Tipografia Densa */
    --font-xs: 11px;
    --font-sm: 13px;
    --font-md: 14px;
    --font-lg: 16px;
    
    /* Cores de Fundo Específicas */
    --bg-body: #f8f9fa;
    --bg-surface: #ffffff;
    --border-color: #e9ecef;

    /* Cores dos Módulos do Menu */
    --color-home: #0d6efd;      /* Primary */
    --color-clients: #0dcaf0;   /* Info */
    --color-tickets: #dc3545;   /* Danger */
    --color-services: #6f42c1;  /* Purple */
    --color-quotes: #ffc107;    /* Warning */
    --color-os: #0a58ca;        /* Dark Blue */
    --color-calendar: #d63384;  /* Pink */
    --color-finance: #198754;   /* Success */
    --color-reports: #6c757d;   /* Secondary */
    --color-products: #fd7e14;  /* Orange */
    --color-resources: #20c997; /* Teal */
    --color-gallery: #e83e8c;   /* Magenta */
    --color-users: #6610f2;     /* Indigo */
}

html {
    font-size: 16px;
}

body {
    background-color: var(--bg-body);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding-bottom: calc(var(--bottomnav-h) + 20px); /* Espaço para bottom nav */
}

@media (min-width: 768px) {
    body {
        padding-bottom: 24px;
    }
}

/* Links e Interações */
a { text-decoration: none; }

/* App Bar (Header) */
.app-bar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: #111;
    color: #fff;
    padding: 0 var(--space-md);
    height: var(--appbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-title {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
}
.app-title:hover { color: #eee; }

.app-actions a {
    color: rgba(255,255,255,0.85);
    margin-left: 12px;
    font-weight: 500;
    font-size: var(--font-sm);
    transition: color 0.2s;
}
.app-actions a:hover { color: #fff; }

/* Top Navigation (Desktop) */
.top-nav {
    position: sticky;
    top: var(--appbar-h);
    z-index: 1010;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    padding: 6px var(--space-md);
    gap: 6px;
    overflow-x: auto;
    height: 50px; /* Reduced height for compactness */
    align-items: center;
    scrollbar-width: none; /* Firefox */
}
.top-nav::-webkit-scrollbar { display: none; }

.top-nav a {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px; /* Reduced padding */
    border-radius: 50rem; /* Pill shape */
    color: var(--secondary);
    font-weight: 600;
    font-size: 0.75rem; /* Smaller font size (approx 12px) */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}

.top-nav a i {
    margin-right: 6px;
    font-size: 1.1em;
    transition: transform 0.2s;
}

.top-nav a:hover {
    background-color: var(--light);
    color: var(--primary);
    transform: translateY(-1px);
}

.top-nav a:hover i {
    transform: scale(1.1);
}

.top-nav a.active {
    background: linear-gradient(135deg, var(--primary), #0a58ca);
    color: white;
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.3);
    border-color: transparent;
}

.top-nav a.active i {
    color: white;
}

/* Generic Nav Item (for other uses if any) */
.nav-item {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--secondary);
    font-weight: 500;
    font-size: var(--font-sm);
    white-space: nowrap;
    transition: all 0.2s;
}
.nav-item:hover, .nav-item.active {
    background: var(--light);
    color: var(--primary);
}
.nav-item i { margin-right: 6px; }

/* Bottom Navigation (Mobile) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottomnav-h);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1020;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
    font-size: 10px;
    font-weight: 500;
    flex: 1;
    height: 100%;
}
.bottom-nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}
.bottom-nav-item.active { color: var(--primary); }

/* Utility Helpers for Dense Layout */
.min-h-unset { min-height: unset !important; }

/* Media Queries */
@media (min-width: 768px) {
    .bottom-nav { display: none; }
    
    /* Ajustes Desktop */
    .dense-header-row {
        display: grid;
        /* O template-columns deve ser definido localmente ou via classes utilitárias ex: .grid-os */
        gap: 16px;
        padding: 8px 16px;
        background: var(--light);
        border-radius: var(--radius-sm);
        margin-bottom: 8px;
        font-size: var(--font-xs);
        font-weight: 700;
        text-transform: uppercase;
        color: var(--secondary);
        align-items: center;
    }

    .dense-item {
        display: grid;
        /* O template-columns deve ser definido localmente ou via classes utilitárias ex: .grid-os */
        align-items: center;
        padding: 8px 16px;
        gap: 16px;
    }
    
    .dense-content {
        flex-direction: row;
        align-items: center;
        gap: 16px;
    }
    
    .dense-actions {
        flex-direction: row;
        justify-content: flex-end;
    }
    
    /* Utilitários de visibilidade avançados */
    .mobile-only { display: none !important; }
    .desktop-only { display: block !important; }
}

@media (max-width: 767.98px) {
    .dense-header-row { display: none; }
    .mobile-only { display: block !important; }
    .desktop-only { display: none !important; }
    
    /* Ajustes finos para mobile */
    .container { padding: 0 var(--space-sm); }
}

/* Badges e Status */
.badge-status {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.bg-subtle-primary { background: #cfe2ff; color: #084298; }
.bg-subtle-secondary { background: #e2e3e5; color: #41464b; }
.bg-subtle-success { background: #d1e7dd; color: #0f5132; }
.bg-subtle-info { background: #cff4fc; color: #055160; }
.bg-subtle-warning { background: #fff3cd; color: #664d03; }
.bg-subtle-danger { background: #f8d7da; color: #842029; }
.bg-subtle-light { background: #f8f9fa; color: #636464; }
.bg-subtle-dark { background: #d3d3d4; color: #141619; }

/* Utilitários de Texto */
.text-xs { font-size: var(--font-xs) !important; }

/* TomSelect Customization */
.ts-wrapper.single .ts-control {
    background-image: none !important;
    padding-right: 0.75rem !important; /* Reset padding to normal since no arrow is there */
}

/* Remove a seta nativa do Bootstrap (SVG background) que persiste indevidamente */
.ts-wrapper.form-select,
.ts-control.form-select {
    background-image: none !important;
}

.ts-wrapper.single .ts-control::after {
    display: none !important;
}

/* Mobile Menu Styling (Offcanvas) */
#mainMenuOffcanvas .list-group-item {
    border: none;
    padding: 10px 16px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--secondary);
    border-radius: 8px;
    margin-bottom: 2px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

#mainMenuOffcanvas .list-group-item:hover {
    background-color: var(--light);
    color: var(--primary);
    transform: translateX(4px);
}

#mainMenuOffcanvas .list-group-item.active {
    background: linear-gradient(135deg, var(--primary), #0a58ca);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.3);
}

#mainMenuOffcanvas .list-group-item i {
    margin-right: 10px;
    font-size: 1.1em;
    width: 24px;
    text-align: center;
    transition: transform 0.2s;
}

#mainMenuOffcanvas .list-group-item:hover i {
    transform: scale(1.1);
}

/* --- Menu Color System --- */

/* Mapping classes to variables */
.nav-home { --item-color: var(--color-home); }
.nav-clients { --item-color: var(--color-clients); }
.nav-tickets { --item-color: var(--color-tickets); }
.nav-services { --item-color: var(--color-services); }
.nav-quotes { --item-color: var(--color-quotes); }
.nav-os { --item-color: var(--color-os); }
.nav-calendar { --item-color: var(--color-calendar); }
.nav-finance { --item-color: var(--color-finance); }
.nav-reports { --item-color: var(--color-reports); }
.nav-products { --item-color: var(--color-products); }
.nav-resources { --item-color: var(--color-resources); }
.nav-gallery { --item-color: var(--color-gallery); }
.nav-users { --item-color: var(--color-users); }

/* Apply colors to Top Nav (Desktop) */
.top-nav a[class*="nav-"] {
    color: var(--item-color);
    border-color: transparent;
}

.top-nav a[class*="nav-"]:hover {
    background-color: color-mix(in srgb, var(--item-color), white 90%);
    color: var(--item-color) !important;
    transform: translateY(-2px);
}

.top-nav a[class*="nav-"].active {
    background: linear-gradient(135deg, var(--item-color), color-mix(in srgb, var(--item-color), black 20%));
    color: white !important;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--item-color), transparent 70%);
}

/* Apply colors to Mobile Menu (Offcanvas) */
#mainMenuOffcanvas .list-group-item[class*="nav-"] {
    color: var(--item-color);
}

#mainMenuOffcanvas .list-group-item[class*="nav-"]:hover {
    background-color: color-mix(in srgb, var(--item-color), white 90%);
    color: var(--item-color);
}

#mainMenuOffcanvas .list-group-item[class*="nav-"].active {
    background: linear-gradient(135deg, var(--item-color), color-mix(in srgb, var(--item-color), black 20%));
    color: white !important;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--item-color), transparent 70%);
}
