/* Responsive date range selector styling */

/* Date input styling */
input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    color: #374151;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input[type="date"]:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
    outline: 0;
}

/* Style the calendar icon */
input[type="date"]::-webkit-calendar-picker-indicator {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'%3E%3C/path%3E%3C/svg%3E");
    opacity: 0.7;
    cursor: pointer;
}

/* Date Range Container */
#dateRangeContainer {
    position: relative;
    z-index: 50;
}

/* Animation for the date container */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

#dateRangeContainer:not(.hidden) {
    animation: fadeIn 0.2s ease;
}

/* Custom button styling */
#customDateToggle {
    cursor: pointer;
    position: relative;
}

/* Apply button transitions */
#applyButton {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#applyButton.hidden {
    opacity: 0;
    transform: translateY(5px);
    pointer-events: none;
}

#applyButton:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* Visual effect for date updates */
@keyframes dateUpdated {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.date-updated {
    animation: dateUpdated 0.5s ease-out;
    border-color: #3b82f6 !important;
}

/* Custom styling for formatted date inputs */
.formatted-date-input {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.formatted-date-input:not(.has-value) {
    color: #9ca3af; /* Gray-400 */
    font-style: italic;
}

.formatted-date-input.has-value {
    color: #374151; /* Gray-700 */
    font-style: normal;
}

/* Error state styling */
.formatted-date-input.error {
    border-color: #ef4444 !important; /* Red-500 */
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
    animation: shake 0.4s linear;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

#dateRangeError {
    animation: fadeIn 0.3s ease;
}

/* Date input container styling */
.date-input-container {
    position: relative;
    cursor: pointer;
    width: 14ch; /* 10ch for DD/MM/YYYY + 4ch for padding and icon */
}

.date-input-container:hover .formatted-date-input {
    border-color: #60a5fa;
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.2);
}

.date-input-container:active .formatted-date-input {
    background-color: #f9fafb;
}

.calendar-icon {
    pointer-events: none;
}

/* Responsive design for smaller screens */
@media (max-width: 640px) {
    .period-tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        justify-content: space-between;
    }
    
    .period-tabs a, 
    .period-tabs button {
        text-align: center;
        flex: 1;
        min-width: auto;
        padding: 0.5rem;
        border-radius: 0.375rem;
    }
    
    #dateRangeContainer {
        margin-top: 0.5rem;
        border-radius: 0.5rem;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    
    .date-input-container {
        width: 12ch; /* Slightly smaller on mobile */
    }
    
    #dateRangeForm button[type="submit"] {
        width: 100%;
        margin-top: 0.5rem;
    }
}