/* ==========================================================================
   Billr - Revolutionary UI Design System
   Production-Ready Custom CSS for world-class design patterns and animations
   ========================================================================== */

/* Base Variables */
:root {
    --primary-50: #f0f9ff;
    --primary-100: #e0f2fe;
    --primary-200: #bae6fd;
    --primary-300: #7dd3fc;
    --primary-400: #38bdf8;
    --primary-500: #0ea5e9;
    --primary-600: #0284c7;
    --primary-700: #0369a1;
    --primary-800: #075985;
    --primary-900: #0c4a6e;
    
    --secondary-50: #faf5ff;
    --secondary-100: #f3e8ff;
    --secondary-200: #e9d5ff;
    --secondary-300: #d946ef;
    --secondary-400: #c026d3;
    --secondary-500: #a21caf;
    --secondary-600: #86198f;
    --secondary-700: #701a75;
    --secondary-800: #581c87;
    --secondary-900: #4c1d95;
    
    --gradient-primary: linear-gradient(135deg, var(--primary-600), var(--secondary-600));
    --gradient-surface: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.7));
    --gradient-mesh: radial-gradient(ellipse at top, var(--primary-50), transparent),
                     radial-gradient(ellipse at bottom, var(--secondary-50), transparent);
    
    --shadow-soft: 0 2px 15px -3px rgba(0, 0, 0, 0.07), 0 10px 20px -2px rgba(0, 0, 0, 0.04);
    --shadow-medium: 0 4px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 30px -5px rgba(0, 0, 0, 0.05);
    --shadow-hard: 0 10px 40px -10px rgba(0, 0, 0, 0.15), 0 20px 50px -10px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);
    --shadow-glow-lg: 0 0 30px rgba(14, 165, 233, 0.2);
    
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    --border-radius-2xl: 20px;
    --border-radius-3xl: 24px;
    
    --animation-bounce-subtle: bounceSubtle 3s ease-in-out infinite;
    --animation-float: float 6s ease-in-out infinite;
    --animation-glow: glow 2s ease-in-out infinite alternate;
    --animation-shimmer: shimmer 2.5s linear infinite;
    --animation-gradient-shift: gradientShift 8s ease-in-out infinite;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

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

/* Glass Morphism Effects */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px) saturate(180%) brightness(110%);
    -webkit-backdrop-filter: blur(20px) saturate(180%) brightness(110%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-soft);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px) saturate(180%) brightness(110%);
    -webkit-backdrop-filter: blur(20px) saturate(180%) brightness(110%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-soft);
}

.glass-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-medium);
}

/* Enhanced Buttons */
.btn-primary {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(to right, var(--primary-600), var(--secondary-600));
    color: white;
    font-weight: 600;
    border-radius: var(--border-radius-xl);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: scale(1);
}

.btn-primary:hover {
    background: linear-gradient(to right, var(--primary-700), var(--secondary-700));
    box-shadow: var(--shadow-glow);
    transform: scale(1.05);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid #e5e5e5;
    color: #404040;
    font-weight: 600;
    border-radius: var(--border-radius-xl);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: scale(1);
}

.btn-secondary:hover {
    background: #fafafa;
    border-color: var(--primary-300);
    color: var(--primary-700);
    box-shadow: var(--shadow-medium);
    transform: scale(1.05);
}

.btn-secondary:active {
    transform: scale(0.95);
}

.btn-ghost {
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    border-radius: var(--border-radius-xl);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-danger {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(to right, #ef4444, #dc2626);
    color: white;
    font-weight: 600;
    border-radius: var(--border-radius-xl);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: scale(1);
}

.btn-danger:hover {
    background: linear-gradient(to right, #dc2626, #b91c1c);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
    transform: scale(1.05);
}

.btn-danger:active {
    transform: scale(0.95);
}

/* Enhanced Cards */
.card-elevated {
    background: white;
    border-radius: var(--border-radius-2xl);
    box-shadow: var(--shadow-medium);
    padding: 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card-elevated:hover {
    box-shadow: var(--shadow-hard);
    transform: translateY(-2px);
}

.card-interactive {
    background: white;
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-soft);
    padding: 1.25rem;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card-interactive:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-1px);
    border-color: var(--primary-200);
}

.card-glass {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--border-radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
}

/* Dark mode support for card-glass */
.dark .card-glass {
    background: rgba(38, 38, 38, 0.9); /* neutral-800 with opacity */
    border: 1px solid rgba(82, 82, 91, 0.3); /* neutral-600 with opacity */
    box-shadow: 0 2px 15px -3px rgba(0, 0, 0, 0.2), 0 10px 20px -2px rgba(0, 0, 0, 0.15);
}

/* Enhanced card styling for better contrast */
.card-glass h3 {
    color: rgb(38 38 38); /* neutral-800 */
}

.dark .card-glass h3 {
    color: rgb(245 245 245); /* neutral-100 */
}

/* Grid Layouts */
.grid-responsive {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-dashboard {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

@media (min-width: 1024px) {
    .grid-dashboard {
        grid-template-columns: repeat(3, 1fr);
    }
}

.grid-features {
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .grid-features {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid-features {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Form Elements */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e5e5;
    border-radius: var(--border-radius-lg);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    color: #1f2937; /* Ensure text is dark gray/black for readability */
}

/* Dark mode support for form inputs */
.dark .form-input {
    background: rgb(38 38 38); /* neutral-800 */
    border: 2px solid rgb(82 82 91); /* neutral-600 */
    color: rgb(245 245 245); /* neutral-100 */
}

.dark .form-input::placeholder {
    color: rgb(163 163 163); /* neutral-400 */
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.dark .form-input:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.dark .form-input.error {
    border-color: rgb(248 113 113); /* red-400 */
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

/* Dark mode support for form labels */
.dark .form-label {
    color: rgb(209 213 219); /* neutral-300 */
}

.form-group {
    margin-bottom: 1.5rem;
}

/* Enhanced form styling for expense forms */
.expense-form-container {
    background: rgb(255 255 255); /* white */
    border: 1px solid rgb(229 231 235); /* neutral-200 */
    border-radius: 0.75rem; /* rounded-xl */
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); /* shadow-sm */
    padding: 1.5rem;
}

.dark .expense-form-container {
    background: rgb(38 38 38); /* neutral-800 */
    border: 1px solid rgb(82 82 91); /* neutral-700 */
}

/* Consistent input styling to match filter form */
.expense-form-input {
    width: 100%;
    padding: 0.5rem 0.75rem; /* px-3 py-2 */
    border: 1px solid rgb(209 213 219); /* border-neutral-300 */
    border-radius: 0.5rem; /* rounded-lg */
    background-color: rgb(255 255 255); /* bg-white */
    color: rgb(17 24 39); /* text-neutral-900 */
    font-size: 1rem;
    transition: all 0.2s ease;
}

.expense-form-input::placeholder {
    color: rgb(107 114 128); /* placeholder-neutral-500 */
}

.dark .expense-form-input {
    border: 1px solid rgb(82 82 91); /* dark:border-neutral-600 */
    background-color: rgb(38 38 38); /* dark:bg-neutral-800 */
    color: rgb(245 245 245); /* dark:text-neutral-100 */
}

.dark .expense-form-input::placeholder {
    color: rgb(163 163 163); /* dark:placeholder-neutral-400 */
}

.expense-form-input:focus {
    outline: none;
    border-color: rgb(59 130 246); /* focus:ring-blue-500 */
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.expense-form-label {
    display: block;
    font-size: 0.875rem; /* text-sm */
    font-weight: 500; /* font-medium */
    color: rgb(55 65 81); /* text-neutral-700 */
    margin-bottom: 0.25rem; /* mb-1 */
}

.dark .expense-form-label {
    color: rgb(209 213 219); /* dark:text-neutral-300 */
}

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: var(--animation-shimmer);
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: var(--animation-shimmer);
    border-radius: var(--border-radius-lg);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes bounceSubtle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes glow {
    from { box-shadow: 0 0 20px rgba(14, 165, 233, 0.15); }
    to { box-shadow: 0 0 30px rgba(14, 165, 233, 0.25); }
}

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

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

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

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

/* Animation Classes */
.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in-scale {
    animation: fadeInScale 0.5s ease-out;
}

.animate-float {
    animation: var(--animation-float);
}

.animate-glow {
    animation: var(--animation-glow);
}

.animate-bounce-subtle {
    animation: var(--animation-bounce-subtle);
}

/* Text Effects */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient-animate {
    background: linear-gradient(270deg, var(--primary-600), var(--secondary-600), var(--primary-600));
    background-size: 200% 200%;
    animation: var(--animation-gradient-shift);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Responsive Utilities */
.container-responsive {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .container-responsive {
        padding: 0 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container-responsive {
        padding: 0 2rem;
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focus-visible:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --surface-color: #1f2937;
        --text-color: #f9fafb;
        --border-color: #374151;
    }
    
    .card-elevated {
        background: var(--surface-color);
        border-color: var(--border-color);
        color: var(--text-color);
    }
    
    .form-input {
        background: var(--surface-color);
        border-color: var(--border-color);
        color: var(--text-color);
    }
    
    .form-label {
        color: var(--text-color);
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-break {
        break-after: page;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn-primary,
    .btn-secondary,
    .btn-ghost,
    .btn-danger {
        border: 2px solid currentColor;
    }
    
    .glass,
    .glass-dark,
    .glass-card {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: none;
    }
}

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