/* ========================================
   IPCF TESOURARIA - CSS GLOBAL
   Design System Compartilhado
======================================== */

/* ========================================
   VARIÁVEIS DE DESIGN - PREMIUM
======================================== */
:root {
    /* Cores Primárias IPCF - Modernizadas */
    --cor-primaria: #16a34a;
    --cor-primaria-light: #22c55e;
    --cor-primaria-dark: #15803d;
    --cor-secundaria: #059669;
    --cor-acento: #d97706;
    --cor-acento-light: #f59e0b;
    
    /* Cores Funcionais */
    --cor-receita: #16a34a;
    --cor-receita-bg: #dcfce7;
    --cor-despesa: #dc2626;
    --cor-despesa-bg: #fee2e2;
    --cor-info: #2563eb;
    --cor-info-bg: #dbeafe;
    --cor-warning: #f59e0b;
    --cor-warning-bg: #fef3c7;
    --cor-success: #10b981;
    --cor-success-bg: #d1fae5;
    
    /* Neutros */
    --cor-branco: #ffffff;
    --cor-fundo: #f8f9fa;
    --cor-fundo-alt: #f1f3f5;
    --cor-borda: #e9ecef;
    --cor-texto: #1f2937;
    --cor-texto-light: #6b7280;
    --cor-texto-lighter: #9ca3af;
    
    /* Tipografia */
    --font-principal: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Crimson Pro', Georgia, serif;
    
    /* Tamanhos de Fonte */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    
    /* Espaçamentos */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    
    /* Bordas */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Transições */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

/* ========================================
   RESET E BASE
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-principal);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--cor-texto);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(22, 163, 74, 0.01) 10px,
            rgba(22, 163, 74, 0.01) 20px
        );
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   CONTAINER
======================================== */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* ========================================
   HEADER GLOBAL - PREMIUM
======================================== */
.header {
    background: linear-gradient(135deg, #16a34a 0%, #059669 50%, #0d9488 100%);
    color: var(--cor-branco);
    padding: var(--space-8);
    margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) var(--space-6);
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
    box-shadow: 0 10px 40px rgba(22, 163, 74, 0.3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        transparent 0%,
        rgba(255, 255, 255, 0.05) 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.05) 75%,
        transparent 100%
    );
    background-size: 200% 200%;
    animation: shimmer 8s linear infinite;
    pointer-events: none;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.logo-icon {
    width: 130px;
    height: 52px;
    background: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    position: relative;
    flex-shrink: 0;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 5px 8px;
    display: block;
}

.logo-icon::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.header h1 {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
    margin-bottom: var(--space-1);
}

.header-subtitle {
    opacity: 0.9;
    font-size: var(--text-sm);
}

.header-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* ========================================
   MENU DE NAVEGAÇÃO
======================================== */
.nav-menu {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4) 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: var(--space-4);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--cor-branco);
    text-decoration: none;
    border-radius: var(--radius-xl);
    font-weight: 600;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.nav-link:hover::before {
    width: 300px;
    height: 300px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========================================
   BOTÕES
======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-principal);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #16a34a 0%, #059669 100%);
    color: var(--cor-branco);
    box-shadow: 0 4px 15px rgba(22, 163, 74, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #15803d 0%, #047857 100%);
    box-shadow: 0 6px 25px rgba(22, 163, 74, 0.5);
}

.btn-secondary {
    background: var(--cor-fundo-alt);
    color: var(--cor-texto);
}

.btn-secondary:hover {
    background: var(--cor-borda);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: var(--cor-branco);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-success::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: left 0.5s;
}

.btn-success:hover::before {
    left: 100%;
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.5);
}

.btn-danger {
    background: var(--cor-despesa);
    color: var(--cor-branco);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-info {
    background: var(--cor-info);
    color: var(--cor-branco);
}

.btn-info:hover {
    background: #1d4ed8;
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-lg);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(255, 255, 255, 0.2);
    color: var(--cor-branco);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   CARDS - PREMIUM
======================================== */
.card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-2xl);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    margin-bottom: var(--space-6);
    overflow: hidden;
    transition: all var(--transition-base);
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #16a34a, #059669, #0d9488);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 48px rgba(22, 163, 74, 0.15);
}

.card:hover::before {
    opacity: 1;
}

.card-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--cor-borda);
}

.card-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--cor-texto);
    margin-bottom: var(--space-2);
}

.card-subtitle {
    font-size: var(--text-sm);
    color: var(--cor-texto-light);
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--cor-borda);
    background: var(--cor-fundo);
}

/* ========================================
   FORMULÁRIOS
======================================== */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--cor-texto);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--cor-borda);
    border-radius: var(--radius-lg);
    font-family: var(--font-principal);
    font-size: var(--text-base);
    color: var(--cor-texto);
    background: var(--cor-branco);
    transition: all var(--transition-base);
    position: relative;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--cor-primaria);
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.1),
                0 4px 12px rgba(22, 163, 74, 0.15);
    transform: translateY(-2px);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-help {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--cor-texto-light);
}

/* ========================================
   TABELAS
======================================== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.table thead {
    background: var(--cor-fundo);
}

.table th {
    padding: var(--space-4);
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--cor-texto-light);
    border-bottom: 2px solid var(--cor-borda);
    white-space: nowrap;
}

.table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--cor-borda);
    font-size: var(--text-sm);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--cor-fundo);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* ========================================
   BADGES
======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge-receita {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #6ee7b7;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.badge-despesa {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #fca5a5;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.badge-info {
    background: var(--cor-info-bg);
    color: var(--cor-info);
}

.badge-warning {
    background: var(--cor-warning-bg);
    color: var(--cor-warning);
}

.badge-success {
    background: var(--cor-success-bg);
    color: var(--cor-success);
}

/* ========================================
   ALERTAS - PREMIUM
======================================== */
.alert {
    padding: var(--space-5);
    border-radius: var(--radius-xl);
    border-left: 4px solid;
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.alert-info {
    background: linear-gradient(135deg, rgba(219, 234, 254, 0.8), rgba(191, 219, 254, 0.6));
    color: #1e40af;
    border-left-color: var(--cor-info);
}

.alert-warning {
    background: linear-gradient(135deg, rgba(254, 243, 199, 0.8), rgba(253, 230, 138, 0.6));
    color: #92400e;
    border-left-color: var(--cor-warning);
}

.alert-success {
    background: linear-gradient(135deg, rgba(209, 250, 229, 0.8), rgba(167, 243, 208, 0.6));
    color: #065f46;
    border-left-color: var(--cor-success);
}

.alert-danger {
    background: linear-gradient(135deg, rgba(254, 226, 226, 0.8), rgba(254, 202, 202, 0.6));
    color: #991b1b;
    border-left-color: var(--cor-despesa);
}

/* ========================================
   MODAL
======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    z-index: 9999;
    animation: fadeIn var(--transition-base);
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--cor-branco);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    animation: slideUp var(--transition-slow);
}

.modal-header {
    padding: var(--space-8) var(--space-8) var(--space-6);
    border-bottom: 1px solid var(--cor-borda);
}

.modal-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--cor-texto);
}

.modal-body {
    padding: var(--space-6) var(--space-8);
}

.modal-footer {
    padding: var(--space-6) var(--space-8);
    border-top: 1px solid var(--cor-borda);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* ========================================
   LOADING
======================================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-4);
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--cor-borda);
    border-top-color: var(--cor-primaria);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: var(--text-lg);
    font-weight: 500;
    color: var(--cor-texto-light);
}

/* ========================================
   UTILITÁRIOS
======================================== */
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.no-print {
    /* Esconde na impressão */
}

/* ========================================
   HELPERS
======================================== */
.no-print {
    /* Esconde na impressão */
}

.print-only {
    display: none;
}

/* ========================================
   ANIMAÇÕES
======================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   TOAST NOTIFICATIONS
======================================== */
#toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    z-index: 99999;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    font-family: var(--font-principal);
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    min-width: 260px;
    max-width: 380px;
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    background: linear-gradient(135deg, #16a34a 0%, #059669 100%);
    border-left: 4px solid #14532d;
}

.toast-error {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border-left: 4px solid #7f1d1d;
}

.toast-info {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-left: 4px solid #1e3a8a;
}

.toast-warning {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border-left: 4px solid #78350f;
}

.toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
}

.toast-msg {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 2px;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.toast-close:hover { color: white; }

@media (max-width: 480px) {
    #toast-container {
        top: auto;
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
    .toast { max-width: 100%; }
}

/* ========================================
   IMPRESSÃO
======================================== */
@media print {
    body {
        background: white;
    }
    
    .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        page-break-inside: avoid;
    }
}

/* ========================================
   RESPONSIVO
======================================== */
@media (max-width: 768px) {
    .container {
        padding: var(--space-4);
    }
    
    .header {
        padding: var(--space-6);
        margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) var(--space-4);
    }
    
    .header h1 {
        font-size: var(--text-2xl);
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .nav-menu {
        flex-direction: column;
        width: 100%;
    }
    
    .nav-link {
        width: 100%;
    }
    
    .table-wrapper {
        margin: 0 calc(var(--space-4) * -1);
    }
    
    .modal-content {
        margin: var(--space-4);
    }
}

/* ========================================
   RODAPÉ DE CRÉDITO
======================================== */
.dev-credit {
    text-align: center;
    padding: var(--space-6) 0 var(--space-4);
    margin-top: var(--space-8);
    border-top: 1px solid var(--cor-borda);
    font-size: var(--text-xs);
    color: var(--cor-texto-lighter);
}