@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f0f4f8;
}

/* Gradiente animado - alta especificidade */
#header-animado,
div.animated-gradient,
.animated-gradient {
    background: linear-gradient(-45deg, #4f46e5, #6366f1, #7c3aed, #8b5cf6, #a78bfa, #7c3aed, #6366f1, #4f46e5) !important;
    background-size: 300% 300% !important;
    animation: headerGradient 8s ease infinite !important;
}

@keyframes headerGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.input-group {
    transition: all 0.3s ease;
}

.input-group:hover {
    transform: translateY(-2px);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.result-card {
    transition: all 0.3s ease;
}

.result-card:hover {
    transform: scale(1.02);
}

.tab {
    transition: all 0.3s ease;
}

.tab.active {
    border-bottom: 3px solid #4f46e5;
    color: #4f46e5;
}

.tab:hover:not(.active) {
    border-bottom: 3px solid #818cf8;
    color: #818cf8;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 220px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -110px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.sortable-th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sortable-th button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    text-align: left;
    text-transform: uppercase;
}

.sortable-th:hover {
    color: #4f46e5;
    background-color: #eef2ff;
}

.sort-indicator {
    min-width: 0.75rem;
    color: #6366f1;
    font-size: 0.7rem;
}

@media (max-width: 768px) {
    body {
        background-color: #f8fafc;
    }

    .card-section {
        box-shadow: none;
        border: 1px solid #e5e7eb;
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .card-title {
        font-size: 1rem;
    }

    .tab {
        min-width: 8.5rem;
        flex: 0 0 auto;
    }

    #calculadoraTab .lg\:col-span-1 .card-section {
        position: static;
    }

    #precoFinal {
        font-size: 1.75rem !important;
        line-height: 2rem;
    }

    .cost-row {
        gap: 0.75rem;
    }

    .cost-row span:first-child {
        min-width: 0;
    }

    .btn-primary,
    .btn-secondary {
        min-height: 44px;
    }
}

.card-section {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.input-field {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    outline: none;
    transition: all 0.2s;
}

.input-field:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ===== DARK THEME ===== */
body.dark-theme {
    background-color: #0c0e1a !important;
    color: #e2e8f0 !important;
}

body.dark-theme .card-section {
    background: #13162a !important;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.4) !important;
}

body.dark-theme .card-title {
    color: #f1f5f9 !important;
    border-bottom-color: #1e293b !important;
}

body.dark-theme .input-label {
    color: #94a3b8 !important;
}

body.dark-theme .input-field,
body.dark-theme input[type="number"],
body.dark-theme input[type="text"],
body.dark-theme input[type="date"],
body.dark-theme select,
body.dark-theme textarea {
    background: #1a1e36 !important;
    border-color: #2d3348 !important;
    color: #e2e8f0 !important;
}

body.dark-theme .input-field:focus,
body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2) !important;
}

body.dark-theme .btn-secondary {
    background-color: #1a1e36 !important;
    color: #818cf8 !important;
}

body.dark-theme .btn-secondary:hover {
    background-color: #252a42 !important;
}

body.dark-theme .tab {
    color: #94a3b8 !important;
}

body.dark-theme .tab.active {
    color: #818cf8 !important;
    border-bottom-color: #818cf8 !important;
}

body.dark-theme .tab:hover:not(.active) {
    color: #a5b4fc !important;
    border-bottom-color: #a5b4fc !important;
}

/* Tailwind overrides for dark theme */
body.dark-theme .bg-white {
    background-color: #13162a !important;
}

body.dark-theme .bg-gray-50,
body.dark-theme .bg-gray-100 {
    background-color: #0f1225 !important;
}

body.dark-theme .bg-gray-200 {
    background-color: #1e293b !important;
}

body.dark-theme .text-gray-800,
body.dark-theme .text-gray-900 {
    color: #f1f5f9 !important;
}

body.dark-theme .text-gray-700 {
    color: #cbd5e1 !important;
}

body.dark-theme .text-gray-600 {
    color: #94a3b8 !important;
}

body.dark-theme .text-gray-500 {
    color: #64748b !important;
}

body.dark-theme .text-gray-400 {
    color: #64748b !important;
}

body.dark-theme .border-gray-200,
body.dark-theme .border-gray-300 {
    border-color: #1e293b !important;
}

body.dark-theme .divide-gray-200 > * + * {
    border-color: #1e293b !important;
}

body.dark-theme .shadow-lg,
body.dark-theme .shadow-md,
body.dark-theme .shadow {
    box-shadow: 0 10px 25px rgba(0,0,0,0.4) !important;
}

body.dark-theme .hover\:bg-gray-50:hover {
    background-color: #1a1e36 !important;
}

body.dark-theme .hover\:bg-gray-100:hover {
    background-color: #1a1e36 !important;
}

body.dark-theme .bg-indigo-50 {
    background-color: rgba(79,70,229,0.1) !important;
}

body.dark-theme .bg-green-50,
body.dark-theme .bg-green-100 {
    background-color: rgba(34,197,94,0.1) !important;
}

body.dark-theme .bg-red-50,
body.dark-theme .bg-red-100 {
    background-color: rgba(239,68,68,0.1) !important;
}

body.dark-theme .bg-yellow-50,
body.dark-theme .bg-yellow-100 {
    background-color: rgba(234,179,8,0.1) !important;
}

body.dark-theme .bg-blue-50,
body.dark-theme .bg-blue-100 {
    background-color: rgba(59,130,246,0.1) !important;
}

body.dark-theme .sales-summary-card {
    background-color: #151a2e !important;
    border-color: #2d3348 !important;
}

body.dark-theme .sales-summary-card p:first-child {
    color: #cbd5e1 !important;
}

body.dark-theme .sales-summary-card p:last-child {
    color: #f8fafc !important;
}

body.dark-theme .result-card {
    background: #13162a !important;
}

body.dark-theme .printer-option {
    border-color: #2d3348 !important;
    background: #13162a !important;
}

body.dark-theme .printer-option.selected,
body.dark-theme .printer-option:hover {
    border-color: #6366f1 !important;
}

body.dark-theme table th {
    background-color: #1a1e36 !important;
    color: #f1f5f9 !important;
}

body.dark-theme table td {
    color: #e2e8f0 !important;
    border-color: #1e293b !important;
}

body.dark-theme table tr:nth-child(even) {
    background-color: rgba(255,255,255,0.02) !important;
}

body.dark-theme table tr:hover {
    background-color: rgba(79,70,229,0.05) !important;
}

body.dark-theme .custom-scrollbar::-webkit-scrollbar-track {
    background: #13162a;
}

body.dark-theme .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #374151;
}

body.dark-theme .tooltip .tooltiptext {
    background-color: #1e293b;
}

body.dark-theme #changelogModal .bg-white {
    background-color: #13162a !important;
}

body.dark-theme #changelogModal .text-gray-700,
body.dark-theme #changelogModal .text-gray-600 {
    color: #cbd5e1 !important;
}

body.dark-theme #changelogModal .border-t {
    border-color: #1e293b !important;
}

body.dark-theme #changelogModal .border-gray-300 {
    border-color: #2d3348 !important;
}

body.dark-theme h1, body.dark-theme h2, body.dark-theme h3,
body.dark-theme h4, body.dark-theme h5, body.dark-theme h6 {
    color: #f1f5f9 !important;
}

body.dark-theme p, body.dark-theme span, body.dark-theme label,
body.dark-theme li, body.dark-theme td, body.dark-theme th {
    color: inherit;
}

body.dark-theme .text-indigo-600,
body.dark-theme .text-indigo-700,
body.dark-theme .text-indigo-800 {
    color: #c7d2fe !important;
}

body.dark-theme .bg-indigo-100 {
    background-color: rgba(99,102,241,0.18) !important;
}

body.dark-theme .bg-indigo-100.text-indigo-700,
body.dark-theme #changelogModal .bg-indigo-100.text-indigo-700 {
    color: #c7d2fe !important;
}

/* Keep header gradient unchanged in dark mode */
body.dark-theme .animated-gradient,
body.dark-theme #header-animado {
    /* no change - already dark */
}

/* Dark theme toggle animation */
#btnTheme {
    transition: transform 0.3s, background 0.3s;
}
#btnTheme:hover {
    transform: scale(1.1);
}

.btn-primary {
    background: linear-gradient(-45deg, #4f46e5, #6366f1, #7c3aed, #8b5cf6, #6366f1, #4f46e5);
    background-size: 300% 300%;
    animation: headerGradient 8s ease infinite;
    color: white;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

.btn-secondary {
    background-color: white;
    color: #4f46e5;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background-color: #eef2ff;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

.printer-option {
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.printer-option:hover {
    border-color: #a5b4fc;
}

.printer-option.selected {
    border-color: #4f46e5;
    background-color: #eef2ff;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
    animation: fadeIn 0.3s ease-out;
}

.subtab {
    transition: all 0.3s ease;
    color: #6b7280;
}

.subtab.active {
    border-color: #4f46e5;
    color: #4f46e5;
    background-color: #eef2ff;
}

.subtab:hover:not(.active) {
    background-color: #f9fafb;
}

/* ==================== RESPONSIVIDADE MOBILE ==================== */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .card-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .input-label {
        font-size: 0.75rem;
    }
    
    .input-field {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Header responsivo */
    .header-buttons {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    
    .header-buttons button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
    
    /* Tabs responsivo */
    .tab {
        padding: 0.75rem 0.5rem !important;
        font-size: 0.7rem !important;
    }
    
    /* Grid responsivo */
    .grid-cols-1.md\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Impressora select responsivo */
    #impressoraSelect,
    #secadoraSelect {
        grid-template-columns: 1fr !important;
    }
    
    .printer-option {
        padding: 0.5rem;
    }
    
    .printer-option h3 {
        font-size: 0.875rem;
    }
    
    .printer-option p {
        font-size: 0.7rem;
    }
    
    /* Resultado responsivo */
    .cost-row {
        font-size: 0.75rem;
    }
    
    #precoFinal {
        font-size: 1.75rem !important;
    }
    
    #valorLucro {
        font-size: 1rem !important;
    }
    
    /* Botões de ação */
    .btn-primary {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Subtabs */
    .subtab {
        font-size: 0.65rem !important;
        padding: 0.5rem 0.25rem !important;
    }
    
    /* Tabela histórico */
    table {
        font-size: 0.7rem;
    }
    
    table th, table td {
        padding: 0.5rem 0.25rem !important;
    }
    
    /* Footer */
    footer {
        font-size: 0.8rem;
    }
    
    footer .grid {
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .tab {
        font-size: 0.6rem !important;
        padding: 0.5rem 0.25rem !important;
    }
    
    .tab span {
        display: none;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    #precoFinal {
        font-size: 1.5rem !important;
    }
}

@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
