/* Custom CSS for FinanzasPro PWA */

/* CSS Variables for consistent theming */
:root {
    --primary-blue: #3B82F6;
    --secondary-purple: #8B5CF6;
    --success-green: #10B981;
    --error-red: #EF4444;
    --warning-yellow: #F59E0B;
    --neutral-gray: #6B7280;
    --light-gray: #F3F4F6;
    --white: #FFFFFF;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 0.75rem;
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.3s ease-out;
    --transition-slow: 0.5s ease-out;
}

/* Global styles */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Custom animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-100%);
    }
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
        transform: translate3d(0,0,0);
    }
    40%, 43% {
        animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
        transform: translate3d(0, -30px, 0);
    }
    70% {
        animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
        transform: translate3d(0, -15px, 0);
    }
    90% {
        transform: translate3d(0,-4px,0);
    }
}

/* Animation utility classes */
.animate-fadeIn {
    animation: fadeIn var(--transition-normal) forwards;
}

.animate-slideIn {
    animation: slideIn var(--transition-normal) forwards;
}

.animate-scaleIn {
    animation: scaleIn var(--transition-normal) forwards;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
    animation: bounce 1s infinite;
}

/* Enhanced button styles */
button, .btn {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}

button:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

button:active, .btn:active {
    transform: translateY(0);
}

button:focus-visible, .btn:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Calculator button specific styles */
.calc-btn {
    min-height: 44px;
    font-size: 1.125rem;
    font-weight: 500;
    border: 1px solid #E5E7EB;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.calc-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.calc-btn:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Card hover effects */
.card-hover {
    transition: all var(--transition-normal);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Toast notifications */
#toastContainer .toast {
    animation: slideIn var(--transition-normal) ease-out;
}

/* Navigation active states */
.nav-item.active {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-purple));
    color: white;
    transform: translateX(4px);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-purple));
    border-radius: 0 4px 4px 0;
}

/* Bottom navigation enhancements */
.bottom-nav-item.active {
    color: var(--primary-blue);
    transform: translateY(-2px);
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--primary-blue);
    border-radius: 50%;
}

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

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

/* Chart container styles */
canvas {
    max-height: 400px;
}

/* Responsive typography */
@media (max-width: 768px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
}

/* Focus styles for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-blue-600 { background-color: #0000ff; }
    .bg-green-600 { background-color: #008000; }
    .bg-red-600 { background-color: #ff0000; }
    .text-gray-600 { color: #000000; }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    :root {
        --light-gray: #1F2937;
        --white: #111827;
        --neutral-gray: #9CA3AF;
    }
}

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

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .bg-blue-600, .bg-green-600, .bg-red-600, .bg-purple-600 {
        background: white !important;
        color: black !important;
        border: 1px solid black !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    button, .btn, .calc-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-item, .mobile-nav-item, .bottom-nav-item {
        min-height: 44px;
    }
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-gray);
}

::-webkit-scrollbar-thumb {
    background: var(--neutral-gray);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-blue);
}

/* Selection styles */
::selection {
    background: var(--primary-blue);
    color: white;
}

::-moz-selection {
    background: var(--primary-blue);
    color: white;
}

/* Utility classes for common patterns */
.gradient-bg {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-purple));
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.shadow-glow {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

/* Error boundary styles */
.error-boundary {
    padding: 2rem;
    text-align: center;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--border-radius);
    margin: 1rem;
}

.error-boundary h2 {
    color: var(--error-red);
    margin-bottom: 1rem;
}

.error-boundary p {
    color: #991b1b;
    margin-bottom: 1rem;
}

/* PWA install banner styles */
#installBanner {
    box-shadow: var(--shadow-md);
    border-bottom: 3px solid var(--secondary-purple);
}

/* Transaction item hover effects */
#transactionsList > div:hover {
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.05), transparent);
}

/* Chart loading state */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--neutral-gray);
}

/* Mobile bottom padding for fixed navigation */
@media (max-width: 1023px) {
    main {
        padding-bottom: 80px;
    }
}

/* Safari-specific fixes */
@supports (-webkit-touch-callout: none) {
    .min-h-screen {
        min-height: -webkit-fill-available;
    }
}
