/* Custom styles for the Income & Expense Tracker */

/* Mobile-first responsive design */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Smooth transitions for all interactive elements */
* {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Focus styles for better accessibility */
.focus-ring {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Loading spinner */
.spinner {
    border: 2px solid #f3f4f6;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Card hover effects */
.card-hover {
    transition: all 0.2s;
}

.card-hover:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

/* Mobile-optimized form inputs */
@media (max-width: 640px) {
    .form-input, .form-select, .form-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }

    .btn-primary, .btn-secondary, .btn-outline {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        min-height: 44px; /* Touch target size */
    }
}

/* Modal backdrop blur */
.modal-backdrop {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Mobile modal adjustments */
@media (max-width: 640px) {
    .modal-panel {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
}

/* Touch-friendly buttons */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* Improved mobile navigation */
@media (max-width: 640px) {
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 0.75rem;
        z-index: 40;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
        border-radius: 0.5rem;
        transition: all 0.2s;
    }

    .mobile-nav-item:hover {
        background-color: #f3f4f6;
    }

    .mobile-nav-item.active {
        background-color: #dbeafe;
        color: #2563eb;
    }
}

/* Enhanced mobile cards */
@media (max-width: 640px) {
    .mobile-card {
        border-radius: 1rem;
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    }

    .mobile-card:hover {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
}

/* Better mobile typography */
@media (max-width: 640px) {
    h1 {
        font-size: 1.5rem;
        line-height: 2rem;
    }

    h2 {
        font-size: 1.25rem;
        line-height: 1.75rem;
    }

    h3 {
        font-size: 1.125rem;
        line-height: 1.75rem;
    }

    .text-sm {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .text-xs {
        font-size: 0.75rem;
        line-height: 1rem;
    }
}

/* Mobile-optimized grid layouts */
@media (max-width: 640px) {
    .grid-cols-2 {
        gap: 0.75rem;
    }

    .grid-cols-4 {
        gap: 0.5rem;
    }

    .space-y-3 > * + * {
        margin-top: 0.75rem;
    }

    .space-y-4 > * + * {
        margin-top: 1rem;
    }
}

/* Enhanced focus states for mobile */
@media (max-width: 640px) {
    .focus\:ring-2:focus {
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
    }
}

/* Mobile-friendly progress bars */
@media (max-width: 640px) {
    .progress-bar {
        height: 8px;
        border-radius: 4px;
    }
}

/* Better mobile spacing */
@media (max-width: 640px) {
    .px-4 {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .py-6 {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .mb-6 {
        margin-bottom: 1.5rem;
    }

    .mb-4 {
        margin-bottom: 1rem;
    }
}

/* Mobile-optimized icons */
@media (max-width: 640px) {
    .icon-sm {
        width: 1rem;
        height: 1rem;
    }

    .icon-md {
        width: 1.25rem;
        height: 1.25rem;
    }

    .icon-lg {
        width: 1.5rem;
        height: 1.5rem;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .dark\:bg-gray-800 {
        background-color: #1f2937;
    }

    .dark\:text-white {
        color: #ffffff;
    }

    .dark\:border-gray-600 {
        border-color: #4b5563;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    .print\:block {
        display: block !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .contrast\:border {
        border-width: 2px;
    }

    .contrast\:text-black {
        color: #000000;
    }

    .contrast\:bg-white {
        background-color: #ffffff;
    }
}

/* 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;
    }
}

/* Button variants */
.btn-primary {
    background-color: #2563eb;
    color: white;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.5);
}

.btn-secondary {
    background-color: #4b5563;
    color: white;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #374151;
}

.btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(75, 85, 99, 0.5);
}

.btn-outline {
    background-color: white;
    color: #374151;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-outline:hover {
    background-color: #f9fafb;
}

.btn-outline:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.5);
}

.btn-danger {
    background-color: #dc2626;
    color: white;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-danger:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.5);
}

.btn-success {
    background-color: #16a34a;
    color: white;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-success:hover {
    background-color: #15803d;
}

.btn-success:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.5);
}

/* Form input styles */
.form-input {
    display: block;
    width: 100%;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.form-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.form-select {
    display: block;
    width: 100%;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.form-textarea {
    display: block;
    width: 100%;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.form-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

/* Error state for form inputs */
.form-input-error {
    border-color: #fca5a5;
    color: #dc2626;
}

.form-input-error::placeholder {
    color: #fca5a5;
}

.form-input-error:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 1px #ef4444;
}

/* Table styles */
.table-container {
    overflow-x: auto;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: 0.5rem;
}

.table-responsive {
    min-width: 100%;
    border-collapse: collapse;
}

/* Mobile-first responsive utilities */
@media (max-width: 640px) {
    .table-container {
        margin-left: -1rem;
        margin-right: -1rem;
        box-shadow: none;
    }

    .table-responsive {
        min-width: 100%;
    }

    /* Hide certain table columns on mobile */
    .hidden-mobile {
        display: none;
    }
}

/* Status indicators */
.status-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-positive {
    background-color: #4ade80;
}

.status-negative {
    background-color: #f87171;
}

.status-neutral {
    background-color: #fbbf24;
}

/* Amount styling */
.amount-positive {
    color: #16a34a;
    font-weight: 500;
}

.amount-negative {
    color: #dc2626;
    font-weight: 500;
}

.amount-neutral {
    color: #111827;
    font-weight: 500;
}

/* Progress bars */
.progress-bar {
    width: 100%;
    background-color: #e5e7eb;
    border-radius: 9999px;
    height: 0.5rem;
}

.progress-fill {
    background-color: #2563eb;
    height: 0.5rem;
    border-radius: 9999px;
    transition: all 0.3s;
}

/* Custom dropdown styles */
.dropdown-menu {
    position: absolute;
    right: 0;
    z-index: 10;
    margin-top: 0.5rem;
    width: 12rem;
    border-radius: 0.375rem;
    background-color: white;
    padding: 0.25rem 0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #374151;
    transition: background-color 0.15s;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 16rem;
    width: 100%;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    .print-break {
        page-break-before: always;
    }

    body {
        background: white !important;
        color: black !important;
    }

    .shadow, .shadow-lg, .shadow-md, .shadow-sm {
        box-shadow: none !important;
    }
}