/* ========================================
   GLOBAL LITEPICKER TASARIMI - TAILWIND OPTİMİZE
   Tüm sayfalarda kullanılacak premium takvim tasarımı
   Tailwind CSS renkleri ve utility class'ları ile optimize edilmiş
   ======================================== */

/* CSS Değişkenleri - Tailwind Renkleri ile Uyumlu */
:root {
    /* Container - Tailwind gray-50/white gradient */
    --lp-container-bg: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    --lp-container-border: rgba(255, 255, 255, 0.8);
    --lp-container-shadow: 
        0 25px 80px rgba(0, 0, 0, 0.15),
        0 8px 30px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    
    /* Rezervasyonlu - Pastel Kırmızı */
    --lp-reserved-bg: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%); /* red-50/red-100 - daha pastel */
    --lp-reserved-text: #b91c1c; /* red-700 - daha yumuşak */
    --lp-reserved-hover: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); /* red-100/red-200 */
    
    /* Geçmiş - Tailwind gray-50/gray-100 */
    --lp-past-bg: #f9fafb; /* gray-50 */
    --lp-past-text: #9ca3af; /* gray-400 */
    --lp-past-border: #e5e7eb; /* gray-200 */
    --lp-past-hover: #f3f4f6; /* gray-100 */
    
    /* Müsait - Tailwind green-50/green-700 */
    --lp-available-bg: #f0fdf4; /* green-50 */
    --lp-available-text: #15803d; /* green-700 */
    --lp-available-border: #bbf7d0; /* green-200 */
    --lp-available-hover: #dcfce7; /* green-100 */
    
    /* Seçili - Açık mavi arka plan, koyu mavi yazı */
    --lp-selected-bg: #dbeafe; /* blue-100 */
    --lp-selected-text: #1e40af; /* blue-800 */
    --lp-selected-border: #3b82f6; /* blue-500 - çerçeve için */
    
    /* Litepicker native değişkenlerini override et */
    --litepicker-is-start-color: #1e40af !important; /* blue-800 */
    --litepicker-is-start-color-bg: #dbeafe !important; /* blue-100 */
    --litepicker-is-end-color: #1e40af !important; /* blue-800 */
    --litepicker-is-end-color-bg: #dbeafe !important; /* blue-100 */
    --litepicker-is-in-range-color: #dbeafe !important; /* blue-100 */
    
    /* Typography - Tailwind font weights */
    --lp-font-weight-normal: 500;
    --lp-font-weight-semibold: 600;
    --lp-font-weight-bold: 700;
}

/* Ana Container - Premium Glassmorphism */
.litepicker {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    border-radius: 1.5rem !important; /* 24px - Tailwind rounded-3xl */
    box-shadow: var(--lp-container-shadow) !important;
    z-index: 99999 !important;
    background: var(--lp-container-bg) !important;
    overflow: hidden !important;
    border: 1px solid var(--lp-container-border) !important;
    animation: lp-slide-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    backdrop-filter: blur(20px) !important;
    width: auto !important;
    /* Footer arka plan/gölge şeritlerini kapat */
    --litepicker-footer-color-bg: transparent !important;
    --litepicker-footer-box-shadow-color: transparent !important;
}

/* Animasyon */
@keyframes lp-slide-in {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Hizalama Düzeltmeleri - Orijinal Flexbox Yapısını Koruyarak */
.litepicker .container__months .month-item-weekdays-row {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    width: 100% !important;
}

.litepicker .container__months .month-item-weekdays-row > div {
    flex: 0 0 var(--litepicker-day-width) !important;
    width: var(--litepicker-day-width) !important;
    min-width: var(--litepicker-day-width) !important;
    max-width: var(--litepicker-day-width) !important;
    text-align: center !important;
    box-sizing: border-box !important;
    padding: 5px 0 !important;
}

.litepicker .container__days {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    width: 100% !important;
}

.litepicker .container__days > div,
.litepicker .container__days > a {
    width: var(--litepicker-day-width) !important;
    flex: 0 0 var(--litepicker-day-width) !important;
    min-width: var(--litepicker-day-width) !important;
    max-width: var(--litepicker-day-width) !important;
    box-sizing: border-box !important;
    padding: 5px 0 !important;
    margin: 0 !important;
}

/* Boş günler için - Görünür placeholder */
.litepicker .container__days > div:empty,
.litepicker .container__days > a:empty {
    width: var(--litepicker-day-width) !important;
    flex: 0 0 var(--litepicker-day-width) !important;
    min-width: var(--litepicker-day-width) !important;
    max-width: var(--litepicker-day-width) !important;
    height: var(--litepicker-day-width) !important;
    min-height: var(--litepicker-day-width) !important;
    visibility: visible !important;
    display: block !important;
    box-sizing: border-box !important;
    padding: 5px 0 !important;
    margin: 0.125rem 0 !important;
}

/* Günler - Base Stil - Orijinal Tasarımı Koruyarak */
.litepicker .month-item .day-item {
    border-radius: 0.5rem !important; /* 8px - Tailwind rounded-lg */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-weight: var(--lp-font-weight-normal) !important;
    width: var(--litepicker-day-width) !important;
    min-width: var(--litepicker-day-width) !important;
    max-width: var(--litepicker-day-width) !important;
    min-height: var(--litepicker-day-width) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0.125rem 0 !important; /* Tailwind spacing-0.5 - sadece yukarı/aşağı */
    padding: 0.5rem 0 !important;
    box-sizing: border-box !important;
    text-align: center !important;
}

/* Rezervasyonlu Günler - Pastel Kırmızı */
.litepicker .day-item.is-locked,
.litepicker .day-item.day-item--is-locked,
.litepicker .day-item.reserved-day,
.litepicker .day-item[data-reserved="true"] {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%) !important;
    color: #b91c1c !important;
    border: 1px solid #fecaca !important;
    cursor: not-allowed !important;
    opacity: 1 !important;
    font-weight: var(--lp-font-weight-semibold) !important;
    pointer-events: none !important;
}

.litepicker .day-item.is-locked:hover,
.litepicker .day-item.day-item--is-locked:hover,
.litepicker .day-item.reserved-day:hover,
.litepicker .day-item[data-reserved="true"]:hover {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%) !important;
    transform: none !important;
}

/* Geçmiş Günler - Gri */
.litepicker .day-item.is-past,
.litepicker .day-item.past-day,
.litepicker .day-item[data-past="true"],
.litepicker .day-item.is-disabled:not(.is-locked):not(.reserved-day):not([data-reserved="true"]):not(.is-start-date):not(.is-end-date):not(.is-in-range),
.litepicker .day-item.day-item--is-disabled:not(.is-locked):not(.reserved-day):not([data-reserved="true"]):not(.is-start-date):not(.is-end-date):not(.is-in-range) {
    background-color: var(--lp-past-bg) !important;
    color: var(--lp-past-text) !important;
    border: 1px solid var(--lp-past-border) !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
}

.litepicker .day-item.is-past:hover,
.litepicker .day-item.past-day:hover,
.litepicker .day-item[data-past="true"]:hover,
.litepicker .day-item.is-disabled:not(.is-locked):not(.reserved-day):not([data-reserved="true"]):not(.is-start-date):not(.is-end-date):not(.is-in-range):hover,
.litepicker .day-item.day-item--is-disabled:not(.is-locked):not(.reserved-day):not([data-reserved="true"]):not(.is-start-date):not(.is-end-date):not(.is-in-range):hover {
    background-color: var(--lp-past-hover) !important;
    transform: none !important;
}

/* Müsait Günler - Yeşil */
.litepicker .day-item:not(.is-disabled):not(.is-locked):not(.is-start-date):not(.is-end-date):not(.is-in-range):not(.reserved-day):not([data-reserved="true"]):not(.is-past):not(.past-day):not([data-past="true"]) {
    background-color: var(--lp-available-bg) !important;
    color: var(--lp-available-text) !important;
    border: 1px solid var(--lp-available-border) !important;
}

.litepicker .day-item:not(.is-disabled):not(.is-locked):not(.is-start-date):not(.is-end-date):not(.is-in-range):not(.reserved-day):not([data-reserved="true"]):not(.is-past):not(.past-day):not([data-past="true"]):hover {
    background-color: var(--lp-available-hover) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 2px 8px rgba(21, 128, 61, 0.2) !important;
}

/* Seçili Tarih Aralığı - Açık Mavi (Aralıktaki günler, ilk ve son hariç) */
.litepicker .container__days .day-item.is-in-range:not(.is-start-date):not(.is-end-date) {
    background-color: #dbeafe !important; /* blue-100 */
    color: #1e40af !important; /* blue-800 */
    font-weight: var(--lp-font-weight-normal) !important;
    border: 1px solid #bfdbfe !important; /* blue-300 */
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1) !important;
}

/* İlk ve Son Tarih - Açık Mavi + Koyu Çerçeve */
.litepicker .day-item.is-start-date,
.litepicker .day-item.is-end-date {
    background-color: #dbeafe !important;
    color: #1e40af !important;
    font-weight: var(--lp-font-weight-bold) !important;
    border: 2px solid #3b82f6 !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), 0 2px 8px rgba(59, 130, 246, 0.3) !important;
    position: relative !important;
    z-index: 10 !important;
}

.litepicker .day-item.is-start-date.is-in-range,
.litepicker .day-item.is-end-date.is-in-range {
    background-color: #dbeafe !important;
    color: #1e40af !important;
    border: 2px solid #3b82f6 !important;
}

/* Typography - Başlıklar */
.litepicker .month-item-header {
    font-weight: var(--lp-font-weight-semibold) !important;
    color: #1f2937 !important; /* gray-800 */
}

.litepicker .month-item-weekdays-row {
    font-weight: var(--lp-font-weight-semibold) !important;
    color: #6b7280 !important; /* gray-500 */
}

/* Butonlar */
.litepicker button {
    border-radius: 0.5rem !important; /* 8px - Tailwind rounded-lg */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-weight: var(--lp-font-weight-normal) !important;
    cursor: pointer !important; /* Hover'da el işareti */
}

.litepicker button:disabled {
    cursor: not-allowed !important;
}

.litepicker button:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

/* Input Alanları */
input[id*="reservation-date-range"],
input[id*="date-range"],
input[id*="caravan-reservation-date-range"] {
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

input[id*="reservation-date-range"]:focus,
input[id*="date-range"]:focus,
input[id*="caravan-reservation-date-range"]:focus {
    outline: none !important;
    border-color: var(--brand-primary-color, #2563eb) !important; /* blue-600 */
    box-shadow: 0 0 0 3px rgba(34, 81, 147, 0.1) !important;
}

/* Responsive - Mobile First */
@media (max-width: 768px) {
    .litepicker {
        border-radius: 1rem !important; /* 16px - Tailwind rounded-xl */
        margin: 0.5rem !important; /* Tailwind spacing-2 */
        /* Mobilde ekran dışına taşmayı engelle */
        max-width: calc(100vw - 16px) !important;
        /* Not: Genişliği sabitle - seçim yapınca modal genişleyip titremesin */
        width: min(calc(var(--litepicker-day-width) * 7 + 28px), calc(100vw - 16px)) !important;
        padding: 12px 14px 10px !important; /* Footer satırı için nefes alanı */
        box-sizing: border-box !important;
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) scale(1.02) !important;
        max-height: calc(100vh - 24px) !important;
        overflow: auto !important;
        z-index: 99999 !important;
    }

    /* Mobilde gün hücresi küçült: 7 sütun kesin sığsın */
    .litepicker {
        --litepicker-day-width: 36px !important;
        /* 5 satır / 6 satır aylarında modal titremesin */
        --lp-day-row-height: 40px;
        --lp-day-row-gap: 6px;
    }

    /* Ay container tek ay gibi davransın */
    .litepicker .container__months {
        flex-wrap: wrap !important;
        justify-content: center !important;
        width: 100% !important;
    }
    .litepicker .container__months .month-item {
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    .litepicker .month-item .day-item {
        font-size: 0.875rem !important; /* Tailwind text-sm */
        padding: 0 !important;
        height: var(--lp-day-row-height) !important;
        min-height: var(--lp-day-row-height) !important;
    }

    /* Günler alanı: her zaman 6 satır yer ayır (yükseklik titremesin) */
    .litepicker .container__days {
        display: grid !important;
        grid-template-columns: repeat(7, var(--litepicker-day-width)) !important;
        grid-auto-rows: var(--lp-day-row-height) !important;
        row-gap: var(--lp-day-row-gap) !important;
        column-gap: 0 !important;
        justify-content: center !important;
        align-content: start !important;
        width: 100% !important;
        min-height: calc(var(--lp-day-row-height) * 6 + var(--lp-day-row-gap) * 5) !important;
    }

    .litepicker .container__days > div,
    .litepicker .container__days > a {
        width: var(--litepicker-day-width) !important;
        height: var(--lp-day-row-height) !important;
        min-height: var(--lp-day-row-height) !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Boş gün placeholder'ları da aynı hücre yüksekliğinde dursun */
    .litepicker .container__days > div:empty,
    .litepicker .container__days > a:empty {
        height: var(--lp-day-row-height) !important;
        min-height: var(--lp-day-row-height) !important;
        margin: 0 !important;
        padding: 0 !important;
        visibility: visible !important;
    }

    /* Footer: beyaz zeminde stabil görünüm */
    .litepicker .container__footer {
        display: grid !important;
        grid-template-columns: 1fr auto auto !important;
        grid-template-areas:
            "preview preview preview"
            "cancel . apply" !important;
        gap: 0.5rem !important;
        padding-top: 0.5rem !important;
        align-items: center !important;
        width: 100% !important;
        background: transparent !important;
        box-shadow: none !important;
        border-top: 0 !important;
    }

    /* Seçilen tarih aralığı tam görünsün (gerekirse 2 satıra kırılsın) */
    .litepicker .container__footer .preview-date-range {
        grid-area: preview !important;
        width: 100% !important;
        text-align: center !important;
        font-size: 0.75rem !important; /* 12px */
        line-height: 1.25rem !important;
        white-space: normal !important;
        overflow: visible !important;
        color: #374151 !important; /* gray-700 */
        word-break: break-word !important;
    }

    .litepicker .container__footer .button-cancel {
        grid-area: cancel !important;
        justify-self: start !important;
        white-space: nowrap !important;
    }

    .litepicker .container__footer .button-apply {
        grid-area: apply !important;
        justify-self: end !important;
        white-space: nowrap !important;
    }
    
}

/* Mobilde açıldığında overlay üstünde net görünsün */
body.lp-open .litepicker {
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35) !important;
}

/* Performance Optimizations */
.litepicker * {
    will-change: transform;
}

.litepicker .month-item .day-item {
    contain: layout style paint;
}

/* Hizalama İyileştirmeleri - Orijinal Yapıyı Koruyarak */
.litepicker .container__days .day-item {
    box-sizing: border-box !important;
}

/* Month item genişliği - 7 gün için tam genişlik */
.litepicker .container__months .month-item {
    width: calc(var(--litepicker-day-width) * 7) !important;
    min-width: calc(var(--litepicker-day-width) * 7) !important;
    max-width: calc(var(--litepicker-day-width) * 7) !important;
}

/* Accessibility */
.litepicker button:focus-visible {
    outline: 2px solid #3b82f6 !important; /* blue-500 */
    outline-offset: 2px !important;
}

/* Print Styles */
@media print {
    .litepicker {
        box-shadow: none !important;
        border: 1px solid #d1d5db !important; /* gray-300 */
    }
}
