/**
 * Main CSS - Sistema de Controle Financeiro Pessoal
 * 
 * Este arquivo contém variáveis CSS globais e estilos customizados
 * que complementam o Tailwind CSS.
 */

/* ============================================================================
   CSS VARIABLES (Design Tokens)
   ============================================================================ */

:root {
    /* Primary Colors */
    --primary-blue: #2563eb;
    --success-green: #10b981;
    --warning-yellow: #f59e0b;
    --danger-red: #ef4444;
    
    /* Color System (para compatibilidade com responsive.css) */
    --color-primary-500: #2563eb;
    --color-primary-600: #1d4ed8;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-900: #111827;
    --color-danger-500: #ef4444;
    --color-danger-600: #dc2626;
    --color-blue-50: #eff6ff;
    
    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-200: #e5e7eb;
    --gray-600: #4b5563;
    --gray-900: #111827;
    
    /* Semantic Colors */
    --pending-orange: #f97316;
    --paid-green: #10b981;
    --overdue-red: #ef4444;
    --scheduled-blue: #3b82f6;
    --fixed-badge: #8b5cf6;
    
    /* Typography */
    --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-family-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   CUSTOM TAILWIND UTILITIES
   ============================================================================ */

.bg-primary-blue { background-color: var(--primary-blue); }
.text-primary-blue { color: var(--primary-blue); }
.border-primary-blue { border-color: var(--primary-blue); }

.bg-success-green { background-color: var(--success-green); }
.text-success-green { color: var(--success-green); }
.border-success-green { border-color: var(--success-green); }

.bg-warning-yellow { background-color: var(--warning-yellow); }
.text-warning-yellow { color: var(--warning-yellow); }
.border-warning-yellow { border-color: var(--warning-yellow); }

.bg-danger-red { background-color: var(--danger-red); }
.text-danger-red { color: var(--danger-red); }
.border-danger-red { border-color: var(--danger-red); }

.bg-pending-orange { background-color: var(--pending-orange); }
.text-pending-orange { color: var(--pending-orange); }
.border-pending-orange { border-color: var(--pending-orange); }

.bg-paid-green { background-color: var(--paid-green); }
.text-paid-green { color: var(--paid-green); }
.border-paid-green { border-color: var(--paid-green); }

.bg-overdue-red { background-color: var(--overdue-red); }
.text-overdue-red { color: var(--overdue-red); }
.border-overdue-red { border-color: var(--overdue-red); }

.bg-scheduled-blue { background-color: var(--scheduled-blue); }
.text-scheduled-blue { color: var(--scheduled-blue); }
.border-scheduled-blue { border-color: var(--scheduled-blue); }

.bg-fixed-badge { background-color: var(--fixed-badge); }
.text-fixed-badge { color: var(--fixed-badge); }
.border-fixed-badge { border-color: var(--fixed-badge); }

/* ============================================================================
   COMPONENT STYLES
   ============================================================================ */

/* Expense Card */
.expense-card {
    padding: var(--spacing-md);
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.expense-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-blue);
}

.expense-card.paid {
    background-color: #f0fdf4;
}

.expense-card.overdue {
    border-left: 4px solid var(--overdue-red);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.pending {
    background-color: #fff7ed;
    color: var(--pending-orange);
}

.status-badge.scheduled {
    background-color: #eff6ff;
    color: var(--scheduled-blue);
}

.status-badge.paid {
    background-color: #f0fdf4;
    color: var(--paid-green);
}

.status-badge.overdue {
    background-color: #fef2f2;
    color: var(--overdue-red);
}

/* Type Badge (Fixed/Variable) */
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.type-badge.fixed {
    background-color: #f5f3ff;
    color: var(--fixed-badge);
}

.type-badge.variable {
    background-color: var(--gray-50);
    color: var(--gray-600);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn var(--transition-fast);
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp var(--transition-base);
}

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

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

/* Checkbox Custom Style */
.checkbox-expense {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--gray-300);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.checkbox-expense:checked {
    background-color: var(--success-green);
    border-color: var(--success-green);
}

.checkbox-expense:hover:not(:checked) {
    border-color: var(--primary-blue);
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary-blue);
    border-radius: var(--radius-full);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.text-strikethrough {
    text-decoration: line-through;
    opacity: 0.6;
}

.cursor-pointer {
    cursor: pointer;
}

.cursor-not-allowed {
    cursor: not-allowed;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 640px) {
    .expense-card {
        padding: var(--spacing-sm);
    }
    
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    header,
    footer,
    #month-navigation,
    #add-expense-btn,
    .expense-card button {
        display: none;
    }
    
    body {
        background: white;
    }
    
    .expense-card {
        border: 1px solid black;
        page-break-inside: avoid;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus Styles */
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Reduce Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .expense-card {
        border-width: 2px;
    }
    
    button {
        border: 2px solid currentColor;
    }
}

/* ============================================================================
   MOBILE TOUCH OPTIMIZATIONS
   ============================================================================ */

/* Garantir que todos os elementos interativos sejam clicáveis em mobile */
button,
a,
input[type="button"],
input[type="submit"],
input[type="checkbox"],
input[type="radio"],
select {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

/* Prevenir seleção de texto em elementos interativos */
button,
.btn,
.expense-card-button {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Garantir que botões tenham área de toque adequada em mobile */
@media (max-width: 640px) {
    button,
    .btn,
    a.btn {
        min-height: 44px; /* Tamanho mínimo recomendado pela Apple e Google */
        min-width: 44px;
    }

    /* Feedback visual ao tocar */
    button:active:not(:disabled),
    .btn:active:not(:disabled),
    a:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* Prevenir zoom em inputs no iOS */
@media (max-width: 640px) {
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="email"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important; /* iOS não faz zoom se font-size >= 16px */
    }
}

/* Melhorar scroll em dispositivos touch */
.modal-form,
.expense-list-container {
    -webkit-overflow-scrolling: touch;
}
