/**
 * Modern Datepicker Styles with Time Picker
 * Complete styling for datepicker with time selection
 * ✅ Smaller, more compact design
 */

/* ===========================
   Base Calendar Styles
   =========================== */

.datepicker-calendar {
    position: absolute;
    z-index: 9999 !important;
    background: #ffffff !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12) !important;
    padding: 12px !important;
    min-width: 280px !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-10px) scale(0.95) !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

.datepicker-calendar.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
}

.datepicker-calendar.with-timepicker {
    min-width: 300px;
}

.datepicker-calendar.year-picker {
    min-width: 260px;
}

/* Header */
.datepicker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 6px;
}

.datepicker-nav {
    display: flex;
    gap: 3px;
}

.datepicker-btn {
    width: 28px !important;
    height: 28px !important;
    border: none !important;
    background: #f8f9fa !important;
    border-radius: 6px !important;
    cursor: pointer;
    font-size: 18px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #495057 !important;
    transition: all 0.2s ease !important;
}

.datepicker-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.05);
}

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

/* Month and Year Selects */
.datepicker-selects {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: center;
}

.datepicker-select {
    padding: 6px 10px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 6px !important;
    background: white !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #495057 !important;
    cursor: pointer;
    transition: all 0.2s ease !important;
    outline: none;
}

.datepicker-select:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.datepicker-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Days Container */
.datepicker-days {
    margin-bottom: 8px;
}

.datepicker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 6px;
}

.datepicker-weekday {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    padding: 6px 0;
    text-transform: uppercase;
}

/* Date Grid */
.datepicker-dates {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.datepicker-day {
    aspect-ratio: 1;
    border: none !important;
    background: transparent !important;
    border-radius: 6px !important;
    cursor: pointer;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #495057 !important;
    transition: all 0.2s ease !important;
    position: relative;
    outline: none;
    min-height: 32px !important;
}

.datepicker-day:hover:not(.disabled) {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    color: #667eea;
    transform: scale(1.05);
}

.datepicker-day:focus {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.datepicker-day.other-month {
    color: #adb5bd;
}

.datepicker-day.today {
    background: #e7f3ff;
    color: #0066cc;
    font-weight: 600;
}

.datepicker-day.today::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 3px;
    background: #0066cc;
    border-radius: 50%;
}

.datepicker-day.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    font-weight: 600 !important;
}

.datepicker-day.selected:hover {
    transform: scale(1.05);
}

.datepicker-day.disabled {
    color: #dee2e6;
    cursor: not-allowed;
    background: transparent;
}

.datepicker-day.disabled:hover {
    transform: none;
}

/* Range Mode */
.datepicker-day.range-start,
.datepicker-day.range-end {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.datepicker-day.in-range {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

/* Multiple Mode */
.datepicker-day.multi-selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* ===========================
   Year Picker Grid
   =========================== */

.year-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 6px 0;
}

.year-item {
    width: 100%;
    aspect-ratio: 2.5;
    border-radius: 6px;
    font-size: 13px;
}

/* ===========================
   Time Picker Styles
   =========================== */

.datepicker-timepicker {
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
    margin-top: 8px;
}

.timepicker-title {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timepicker-title i {
    color: #667eea;
    font-size: 14px;
}

.timepicker-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.time-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.time-label {
    font-size: 10px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.time-input {
    width: 50px;
    height: 42px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #495057;
    outline: none;
    transition: all 0.2s ease;
    background: white;
}

.time-input:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.time-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.time-input::-webkit-inner-spin-button,
.time-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.time-input[type="number"] {
    -moz-appearance: textfield;
}

.time-separator {
    font-size: 24px;
    font-weight: 600;
    color: #667eea;
    margin-top: 18px;
}

/* Quick Time Buttons */
.quick-times {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}

.quick-time-btn {
    padding: 5px 12px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-time-btn:hover {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    color: #667eea;
    transform: translateY(-1px);
}

.quick-time-btn:active {
    transform: translateY(0);
}

/* ===========================
   Footer
   =========================== */

.datepicker-footer {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    border-top: 1px solid #f0f0f0;
    padding-top: 10px;
}

.datepicker-footer-btn {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.datepicker-footer-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
    color: #667eea;
    transform: translateY(-1px);
}

.datepicker-footer-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.datepicker-footer-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.datepicker-footer-btn:active {
    transform: translateY(0);
}

.datepicker-footer-btn i {
    font-size: 13px;
}

/* ===========================
   Input Field Enhancements
   =========================== */

input.datepicker {
    cursor: pointer;
    position: relative;
}

input.datepicker::placeholder {
    color: #adb5bd;
    font-size: 14px;
}

input.datepicker:focus {
    border-color: #667eea !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15) !important;
}

/* Icon for datepicker input */
input.datepicker {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23667eea' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

/* Time picker input icon */
input[data-format*="HH:MM"].datepicker {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23667eea' viewBox='0 0 16 16'%3E%3Cpath d='M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71V3.5z'/%3E%3Cpath d='M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z'/%3E%3C/svg%3E");
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 480px) {
    .datepicker-calendar {
        min-width: 260px;
        padding: 10px;
    }
    
    .datepicker-calendar.with-timepicker {
        min-width: 280px;
    }
    
    .datepicker-day {
        font-size: 12px;
        min-height: 28px;
    }
    
    .datepicker-btn {
        width: 26px;
        height: 26px;
        font-size: 16px;
    }
    
    .datepicker-select {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    .time-input {
        width: 45px;
        height: 38px;
        font-size: 16px;
    }
    
    .time-separator {
        font-size: 20px;
    }
}

/* ===========================
   Dark Mode Support
   =========================== */

@media (prefers-color-scheme: dark) {
    .datepicker-calendar {
        background: #1e1e1e;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    }
    
    .datepicker-btn {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .datepicker-select {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #404040;
    }
    
    .datepicker-day {
        color: #e0e0e0;
    }
    
    .datepicker-day.other-month {
        color: #6c757d;
    }
    
    .datepicker-day:hover:not(.disabled) {
        background: rgba(102, 126, 234, 0.2);
    }
    
    .time-input {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #404040;
    }
    
    .datepicker-footer-btn {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #404040;
    }
    
    .quick-time-btn {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #404040;
    }
    
    .timepicker-title,
    .time-label {
        color: #e0e0e0;
    }
}

/* ===========================
   Animations
   =========================== */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.datepicker-day.selected {
    animation: pulse 0.3s ease;
}

/* ===========================
   Accessibility
   =========================== */

.datepicker-calendar:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 4px;
}

.datepicker-day:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .datepicker-day.selected {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .datepicker-btn:hover {
        border: 2px solid currentColor;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .datepicker-calendar,
    .datepicker-btn,
    .datepicker-day,
    .time-input,
    .quick-time-btn,
    .datepicker-footer-btn {
        transition: none;
    }
    
    .datepicker-day.selected {
        animation: none;
    }
}
