/* ============================================
   EletroSys - Design System Global
   ============================================ */

/* --- Animações de Entrada --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out forwards;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.4s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

/* Stagger delay para listas de cards */
.stagger-1 { animation-delay: 0.05s; opacity: 0; }
.stagger-2 { animation-delay: 0.1s; opacity: 0; }
.stagger-3 { animation-delay: 0.15s; opacity: 0; }
.stagger-4 { animation-delay: 0.2s; opacity: 0; }
.stagger-5 { animation-delay: 0.25s; opacity: 0; }
.stagger-6 { animation-delay: 0.3s; opacity: 0; }

/* --- Scrollbar Global Premium --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- Componentes Reutilizáveis --- */

/* Card padrão */
.card {
    background: white;
    border-radius: 1.5rem;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Botão primário */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #0f172a;
    color: white;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 8px 25px -5px rgba(15, 23, 42, 0.3);
}

/* Botão accent */
.btn-accent {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #3b82f6;
    color: white;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-accent:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 8px 25px -5px rgba(59, 130, 246, 0.4);
}

/* Botão success */
.btn-success {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #10b981;
    color: white;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 8px 25px -5px rgba(16, 185, 129, 0.4);
}

/* Input padrão */
.input-standard {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    outline: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.input-standard:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.625rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state i {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 1rem;
}

.empty-state h4 {
    font-size: 1rem;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    color: #94a3b8;
    max-width: 300px;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

/* Table premium */
.table-premium thead tr {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.table-premium thead th {
    padding: 1rem 1.5rem;
    font-size: 0.625rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #64748b;
}

.table-premium tbody tr {
    transition: background 0.15s ease;
}

.table-premium tbody tr:hover {
    background: #f8fafc;
}

.table-premium tbody td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    color: #334155;
}

/* Modal backdrop */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
}

.modal-content {
    background: white;
    border-radius: 1.5rem;
    box-shadow: 0 32px 64px -16px rgba(0, 0, 0, 0.25);
    max-width: 42rem;
    width: 100%;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-content {
    transform: scale(1) translateY(0);
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 200;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-warning { background: #f59e0b; }
.toast-info { background: #3b82f6; }

/* Page transition */
.page-enter {
    animation: fadeInUp 0.4s ease-out;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Glass effect */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Focus visible para acessibilidade */
*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    body { background: white !important; }
    .card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; }
    .help-tip { display: none !important; }
}

/* ============================================
   Sistema de Tutoriais - Balões de Ajuda
   ============================================ */

/* Ícone de ajuda ⓘ */
.help-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 900;
    cursor: help;
    transition: all 0.2s ease;
    vertical-align: middle;
    margin-left: 0.35rem;
    flex-shrink: 0;
    user-select: none;
}

/* Garante que TODA dica exiba o "?" mesmo sem conteúdo interno */
.help-tip::before {
    content: '?';
    font-size: 0.65rem;
    font-weight: 900;
    line-height: 1;
}

.help-tip:hover,
.help-tip.active {
    background: #3b82f6;
    color: white;
    transform: scale(1.15);
    box-shadow: 0 4px 12px -2px rgba(59, 130, 246, 0.4);
}

.help-tip i {
    font-size: 0.6rem;
    line-height: 1;
}

/* Balão de tutorial */
.help-balloon {
    position: fixed;
    z-index: 9999;
    width: 300px;
    max-width: calc(100vw - 24px);
    padding: 1rem 1.15rem;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.5;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.96);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    /* Posição é definida via JS inline (position: fixed + top/left em px) */
}

.help-balloon.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Seta do balão */
.help-balloon::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #0f172a;
    transform: rotate(45deg);
    border-radius: 2px;
}

/* Posições: o "ancoradouro" é calculado em JS; as classes só ajustam a seta.
   As coordenadas principais (top/left) vêm inline via positionBalloon(). */
.help-balloon.pos-bottom {
    margin-left: 0;
}
.help-balloon.pos-bottom::before {
    top: -5px;
    left: 50%;
    margin-left: -6px;
}

.help-balloon.pos-top {
    margin-left: 0;
}
.help-balloon.pos-top::before {
    bottom: -5px;
    left: 50%;
    margin-left: -6px;
}

.help-balloon.pos-left {
    margin-top: 0;
}
.help-balloon.pos-left::before {
    right: -5px;
    top: 50%;
    margin-top: -6px;
}

.help-balloon.pos-right {
    margin-top: 0;
}
.help-balloon.pos-right::before {
    left: -5px;
    top: 50%;
    margin-top: -6px;
}

/* Título dentro do balão */
.help-balloon .help-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #60a5fa;
    margin-bottom: 0.5rem;
}

.help-balloon .help-title i {
    font-size: 0.85rem;
}

/* Texto do balão */
.help-balloon .help-text {
    color: #cbd5e1;
    font-size: 0.78rem;
    line-height: 1.6;
}

.help-balloon .help-text strong {
    color: #f8fafc;
    font-weight: 700;
}

/* Dica extra / atalho */
.help-balloon .help-extra {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.7rem;
    color: #94a3b8;
}

.help-balloon .help-extra i {
    color: #fbbf24;
    margin-right: 0.3rem;
}

/* Modo tour: destaque no elemento */
.help-tip-tour-highlight {
    position: relative;
    z-index: 9998;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3),
                0 0 0 8px rgba(59, 130, 246, 0.1);
    border-radius: 0.75rem;
}

/* Overlay escuro pro modo tour */
.help-tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 9997;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.help-tour-overlay.show {
    opacity: 1;
}

/* Botão "Modo Tour" no header */
.help-tour-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border: none;
    border-radius: 0.6rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px -2px rgba(59, 130, 246, 0.3);
}

.help-tour-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px -4px rgba(59, 130, 246, 0.5);
}

/* Responsivo: balão menor em mobile */
@media (max-width: 768px) {
    .help-balloon {
        width: 220px;
        padding: 0.8rem 1rem;
        font-size: 0.75rem;
    }
    .help-balloon.pos-bottom,
    .help-balloon.pos-top {
        margin-left: -110px;
    }
}

/* ============================================
   MODO COMPACTO - Densidade reduzida
   Ativado via html.compact-mode (toggle no header)
   Para notebooks / monitores pequenos
   ============================================ */
.compact-mode .btn-primary,
.compact-mode .btn-accent,
.compact-mode .btn-success {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 0.6rem;
    gap: 0.4rem;
}

.compact-mode .input-standard {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 0.6rem;
}

.compact-mode .card { border-radius: 1rem; }
.compact-mode .modal-content { border-radius: 1rem; }
.compact-mode .table-premium thead th { padding: 0.5rem 0.75rem; }
.compact-mode .table-premium tbody td { padding: 0.5rem 0.75rem; }
.compact-mode .badge { padding: 0.2rem 0.55rem; }
.compact-mode .empty-state { padding: 2.5rem 1.5rem; }
.compact-mode .main-content-padding { padding: 1.25rem; }

/* FIX: campo de busca com lupa — o texto nunca pode ficar embaixo do icone.
   Especificidade + !important para vencer .input-standard e .compact-mode .input-standard */
.input-standard.input-search-icon,
.compact-mode .input-standard.input-search-icon {
    padding-left: 3rem !important;
}
