/* ============================================================
   SICI - Design System v1.1
   Melhorias de Identidade Visual e Componentes
   ============================================================ */

/* === TIPOGRAFIA ESTENDIDA === */
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap');

/* Fonte monoespaçada para números (alinhamento perfeito) */
.font-mono {
    font-family: 'Roboto Mono', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Hierarquia tipográfica clara */
.text-display { font-size: 2rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.text-headline { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
.text-title { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
.text-body { font-size: 0.875rem; font-weight: 400; line-height: 1.6; }
.text-caption { font-size: 0.75rem; font-weight: 500; line-height: 1.5; }
.text-overline { 
    font-size: 0.65rem; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

/* === CORES ESTENDIDAS === */
:root {
    /* Escala de cinza institucional */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Cores semânticas refinadas */
    --success-light: #86efac;
    --success-dark: #166534;
    --warning-light: #fcd34d;
    --warning-dark: #b45309;
    --danger-light: #fca5a5;
    --danger-dark: #991b1b;
    --info-light: #93c5fd;
    --info-dark: #1e40af;

    /* Cores de status específicas */
    --status-conforme: var(--success);
    --status-alerta: var(--warning);
    --status-perigo: var(--danger);
    --status-info: var(--info);
    --status-neutro: var(--gray-400);

    /* Elevações (sombras) refinadas */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);
    --shadow-2xl: 0 25px 50px rgba(0,0,0,0.12);
    --shadow-inner: inset 0 2px 4px rgba(0,0,0,0.04);

    /* Transições */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 350ms;
}

/* === TOOLTIP SYSTEM === */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: var(--gray-800);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-fast) var(--ease-out);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    max-width: 280px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    border: 6px solid transparent;
    border-top-color: var(--gray-800);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-fast) var(--ease-out);
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Tooltip posições */
.tooltip-bottom::before {
    bottom: auto;
    top: 100%;
    transform: translateX(-50%) translateY(8px);
}

.tooltip-bottom::after {
    bottom: auto;
    top: 100%;
    transform: translateX(-50%) translateY(4px);
    border-top-color: transparent;
    border-bottom-color: var(--gray-800);
}

.tooltip-right::before {
    bottom: auto;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(8px);
}

.tooltip-right::after {
    bottom: auto;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    border-top-color: transparent;
    border-left-color: var(--gray-800);
}

.tooltip-left::before {
    bottom: auto;
    right: 100%;
    left: auto;
    top: 50%;
    transform: translateY(-50%) translateX(-8px);
}

.tooltip-left::after {
    bottom: auto;
    right: 100%;
    left: auto;
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    border-top-color: transparent;
    border-right-color: var(--gray-800);
}

/* Tooltip com ícone de info */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--gray-200);
    color: var(--gray-500);
    border-radius: 50%;
    font-size: 0.65rem;
    margin-left: 6px;
    cursor: help;
    transition: all var(--duration-fast);
}

.tooltip-icon:hover {
    background: var(--accent);
    color: #fff;
}

/* === BADGES ESTENDIDOS === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all var(--duration-fast);
}

.badge-sm { padding: 2px 8px; font-size: 0.65rem; }
.badge-lg { padding: 6px 14px; font-size: 0.8rem; }

/* Badge com animação de pulso */
.badge-pulse {
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* Badge outline */
.badge-outline-success { 
    background: transparent; 
    color: var(--success); 
    border: 1.5px solid var(--success);
}
.badge-outline-warning { 
    background: transparent; 
    color: var(--warning); 
    border: 1.5px solid var(--warning);
}
.badge-outline-danger { 
    background: transparent; 
    color: var(--danger); 
    border: 1.5px solid var(--danger);
}
.badge-outline-info { 
    background: transparent; 
    color: var(--info); 
    border: 1.5px solid var(--info);
}

/* Badge com ícone */
.badge i { font-size: 0.7em; }

/* === CARDS REFINADOS === */
.card-hover {
    transition: all var(--duration-normal) var(--ease-out);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-interactive {
    cursor: pointer;
    transition: all var(--duration-fast);
}

.card-interactive:hover {
    border-color: var(--accent-light);
    box-shadow: var(--shadow-md);
}

.card-interactive:active {
    transform: scale(0.995);
}

/* Card com status indicator */
.card-status {
    position: relative;
    overflow: hidden;
}

.card-status::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gray-300);
}

.card-status.success::before { background: var(--success); }
.card-status.warning::before { background: var(--warning); }
.card-status.danger::before { background: var(--danger); }
.card-status.info::before { background: var(--info); }

/* === ESTADOS DE COMPONENTES === */
.state-disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.5);
}

.state-loading {
    position: relative;
    pointer-events: none;
}

.state-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* === MELHORIAS EM KPI CARDS === */
.kpi-card-enhanced {
    position: relative;
    overflow: hidden;
}

.kpi-card-enhanced::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1));
    pointer-events: none;
}

.kpi-trend-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 0.6rem;
}

.kpi-trend.up .kpi-trend-icon {
    background: var(--success-bg);
    color: var(--success);
}

.kpi-trend.down .kpi-trend-icon {
    background: var(--danger-bg);
    color: var(--danger);
}

/* === INDICADORES VISUAIS === */
.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.indicator-dot::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0.3;
}

.indicator-dot.success { background: var(--success); color: var(--success); }
.indicator-dot.warning { background: var(--warning); color: var(--warning); }
.indicator-dot.danger { background: var(--danger); color: var(--danger); }
.indicator-dot.info { background: var(--info); color: var(--info); }

/* === SEPARADORES ESTILIZADOS === */
.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 24px 0;
}

.divider-vertical {
    width: 1px;
    background: var(--border);
    margin: 0 16px;
    align-self: stretch;
}

/* === MELHORIAS EM TABELAS === */
.table-row-highlight:hover {
    background: var(--info-bg) !important;
}

.table-cell-numeric {
    font-family: 'Roboto Mono', monospace;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.table-cell-status {
    text-align: center;
}

/* === ANIMAÇÕES REFINADAS === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fadeInUp {
    animation: fadeInUp var(--duration-normal) var(--ease-out) forwards;
}

.animate-fadeInScale {
    animation: fadeInScale var(--duration-normal) var(--ease-out) forwards;
}

.animate-slideInRight {
    animation: slideInRight var(--duration-normal) var(--ease-out) forwards;
}

/* Stagger delays para listas */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }

/* === FOCO E ACESSIBILIDADE === */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.focus-ring:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Skip link para acessibilidade */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    transition: top var(--duration-fast);
}

.skip-link:focus {
    top: 0;
}

/* === UTILITÁRIOS ADICIONAIS === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === TEMA VISUAL CONSISTENTE === */
.theme-blue { --theme-color: var(--accent); }
.theme-green { --theme-color: var(--success); }
.theme-orange { --theme-color: var(--warning); }
.theme-red { --theme-color: var(--danger); }

.theme-indicator {
    width: 3px;
    height: 100%;
    background: var(--theme-color, var(--accent));
}
