/* Main CSS for Expense Tracker PWA */

/* Custom utilities */
.btn-primary {
    @apply bg-primary-600 text-white px-4 py-2 rounded-lg font-medium hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900 transition-colors;
}

.btn-secondary {
    @apply bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 px-4 py-2 rounded-lg font-medium hover:bg-gray-300 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900 transition-colors;
}

.btn-danger {
    @apply bg-red-600 text-white px-4 py-2 rounded-lg font-medium hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900 transition-colors;
}

.input-field {
    @apply w-full px-4 py-3 sm:py-2 border-2 border-gray-300 dark:border-gray-600 rounded-xl shadow-sm placeholder-gray-400 dark:placeholder-gray-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all duration-200;
    min-height: 48px; /* Enhanced touch-friendly height for mobile */
    font-size: 16px; /* Prevents zoom on iOS */
    border-style: solid;
    /* Mobile-first enhanced styling */
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

/* Enhanced focus state for mobile */
.input-field:focus {
    @apply border-primary-500 ring-2 ring-primary-500 ring-opacity-50;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Enhanced hover state for desktop */
@media (hover: hover) {
    .input-field:hover {
        @apply border-gray-400 dark:border-gray-500;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
}

/* Error state styling */
.input-field.error,
.input-field[aria-invalid="true"] {
    @apply border-red-500 dark:border-red-400;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Success state styling */
.input-field.success,
.input-field[aria-invalid="false"] {
    @apply border-green-500 dark:border-green-400;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Enhanced select field styling for mobile */
select.input-field {
    @apply appearance-none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 1rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 3rem;
    cursor: pointer;
}

/* Dark mode select arrow */
.dark select.input-field {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%9ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* Select field focus enhancement */
select.input-field:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%233b82f6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

.dark select.input-field:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* Color input specific styling */
input[type="color"].input-field {
    @apply p-2;
    min-height: 48px;
    width: 100%;
    border-radius: 0.75rem;
    cursor: pointer;
    border-width: 2px;
}

input[type="color"].input-field::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 0.5rem;
    overflow: hidden;
}

input[type="color"].input-field::-webkit-color-swatch {
    border: none;
    border-radius: 0.5rem;
}

/* Textarea styling */
textarea.input-field {
    @apply resize-y;
    min-height: 96px; /* Enhanced minimum height for mobile */
    line-height: 1.5;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

/* Number input styling */
input[type="number"].input-field {
    -moz-appearance: textfield;
}

input[type="number"].input-field::-webkit-outer-spin-button,
input[type="number"].input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Date input styling */
input[type="date"].input-field {
    cursor: pointer;
}

input[type="date"].input-field::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

input[type="date"].input-field::-webkit-calendar-picker-indicator:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.card {
    @apply bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-4;
}

.stat-card {
    @apply bg-gradient-to-br from-primary-500 to-primary-600 text-white rounded-lg p-4 shadow-sm;
}

.expense-card {
    @apply bg-gradient-to-br from-red-500 to-red-600 text-white rounded-lg p-4 shadow-sm;
}

.income-card {
    @apply bg-gradient-to-br from-green-500 to-green-600 text-white rounded-lg p-4 shadow-sm;
}

/* Animation utilities */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* Mobile-first responsive utilities */
.safe-area-inset {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Loading states */
.loading {
    position: relative;
    color: transparent;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f59e0b;
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* PWA splash screen styles */
@media (display-mode: standalone) {
    body {
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    button, a, input, select, textarea {
        min-height: 44px;
    }
}

/* Dark mode transitions */
* {
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5);
    border-radius: 3px;
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.5);
}

/* Form validation styles */
.field-error {
    @apply text-red-600 dark:text-red-400 text-sm mt-1;
}

.field-error input, .field-error select, .field-error textarea {
    @apply border-red-300 dark:border-red-600 focus:ring-red-500 focus:border-red-500;
}

/* Transaction type indicators */
.transaction-income {
    @apply border-l-4 border-green-500;
}

.transaction-expense {
    @apply border-l-4 border-red-500;
}

/* Category color indicators */
.category-dot {
    @apply w-3 h-3 rounded-full inline-block mr-2;
}

/* Quick action buttons */
.quick-action {
    @apply fixed bottom-24 right-4 w-14 h-14 bg-primary-600 text-white rounded-full shadow-lg flex items-center justify-center hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 transition-all;
}

/* Swipe gestures for mobile */
.swipe-item {
    touch-action: pan-y;
    user-select: none;
}

/* Filter tabs */
.filter-tab {
    @apply px-4 py-2 text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 border-b-2 border-transparent hover:border-gray-300 dark:hover:border-gray-600 transition-all;
}

.filter-tab.active {
    @apply text-primary-600 dark:text-primary-400 border-primary-600 dark:border-primary-400;
}

/* Responsive grid layouts */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.transaction-grid {
    display: grid;
    gap: 0.75rem;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .card {
        border: 1px solid #ccc !important;
        background: white !important;
    }
}
