/**
 * Thai Buddhist Era Datepicker (Thaidate Picker)
 * CSS Stylesheet - Apple Modern HIG & Bootstrap 5 Compatible
 * LTC Equipment Lending System
 */

.thaidate-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.thaidate-input-group {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

.thaidate-display-input {
    cursor: pointer;
    background-color: #ffffff !important;
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    padding-right: 2.5rem !important;
}

.thaidate-icon-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #64748b;
    padding: 0.25rem 0.4rem;
    border-radius: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    transition: all 0.15s ease-in-out;
}

.thaidate-icon-btn:hover {
    color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.08);
}

/* Calendar Popup Modal / Dropdown */
.thaidate-popup {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.35rem;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 1rem;
    box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.22), 0 4px 6px -2px rgba(0, 0, 0, 0.08);
    width: 320px;
    max-width: 95vw;
    padding: 0.85rem;
    z-index: 2050 !important;
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    display: none;
    user-select: none;
}

.thaidate-popup.active {
    display: block !important;
}

/* Header with Month & Year Dropdowns */
.thaidate-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.thaidate-nav-btn {
    background: #f1f5f9;
    border: none;
    color: #334155;
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.15s ease-in-out;
}

.thaidate-nav-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.thaidate-selectors {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-grow: 1;
}

.thaidate-select-month,
.thaidate-select-year {
    font-size: 0.84rem;
    font-weight: 600;
    font-family: 'Sarabun', sans-serif;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    padding: 0.3rem 0.4rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease;
}

.thaidate-select-month {
    flex: 1.2;
}

.thaidate-select-year {
    flex: 1;
}

.thaidate-select-month:focus,
.thaidate-select-year:focus {
    border-color: #3b82f6;
    background-color: #ffffff;
}

/* Weekday Labels */
.thaidate-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 0.35rem;
}

.thaidate-weekday {
    font-size: 0.76rem;
    font-weight: 700;
    color: #64748b;
    padding: 0.25rem 0;
}

.thaidate-weekday.weekend {
    color: #ef4444;
}

/* Days Grid */
.thaidate-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.thaidate-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.84rem;
    font-weight: 500;
    color: #1e293b;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.12s ease-in-out;
    background: transparent;
    border: 1px solid transparent;
}

.thaidate-day:hover {
    background-color: #f1f5f9;
    color: #0284c7;
}

.thaidate-day.other-month {
    color: #cbd5e1;
}

.thaidate-day.today {
    font-weight: 700;
    color: #0284c7;
    border-color: #bae6fd;
    background-color: rgba(2, 132, 199, 0.06);
}

.thaidate-day.selected {
    background-color: #0284c7 !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.3);
}

/* Footer Action Buttons */
.thaidate-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.65rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
    gap: 0.35rem;
}

.thaidate-btn-action {
    font-size: 0.76rem;
    font-weight: 600;
    font-family: 'Sarabun', sans-serif;
    border-radius: 0.4rem;
    padding: 0.25rem 0.55rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.thaidate-btn-today {
    background: #e0f2fe;
    color: #0369a1;
}

.thaidate-btn-today:hover {
    background: #bae6fd;
}

.thaidate-btn-clear {
    background: #f8fafc;
    color: #64748b;
}

.thaidate-btn-clear:hover {
    background: #f1f5f9;
    color: #dc2626;
}

.thaidate-btn-close {
    background: #f1f5f9;
    color: #334155;
    margin-left: auto;
}

.thaidate-btn-close:hover {
    background: #e2e8f0;
}

/* Backdrop for Mobile devices */
.thaidate-mobile-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2040 !important;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.thaidate-mobile-backdrop.active {
    display: block;
}

/* Responsive on Mobile (< 576px) */
@media (max-width: 575.98px) {
    .thaidate-popup.modal-mode {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 320px !important;
        max-width: 90vw !important;
        z-index: 2050 !important;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25) !important;
    }
}

