/**
 * Space Booking Frontend Styles
 * @package     com_esbooking
 * @copyright   Copyright (C) 2025 場地租借系統
 */

.space-booking-container {
    padding: 20px 0;
    padding-bottom: 120px; /* 為 minicart 留出空間 */
}

.space-header {
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 20px;
}

.space-title {
    font-size: 2rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 10px;
}

.space-venue {
    font-size: 1.1rem;
    color: #6c757d;
    margin-bottom: 0;
}

.space-venue i {
    margin-right: 5px;
}

.space-images {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.space-images .carousel-item img {
    height: 400px;
    object-fit: cover;
    cursor: pointer;
}

/* Thumbnail grid */
.space-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}

.space-thumb {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
}

.space-thumb:hover {
    opacity: 0.9;
}

.space-thumb.active {
    border-color: #0d6efd;
    opacity: 1;
}

/* Lightbox */
.space-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.space-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
}

.space-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.space-lightbox-content img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.space-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 10px;
}

.space-lightbox-close:hover {
    color: #ff6b6b;
}

.space-lightbox-prev,
.space-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 4px;
    transition: background 0.2s;
}

.space-lightbox-prev:hover,
.space-lightbox-next:hover {
    background: rgba(255,255,255,0.3);
}

.space-lightbox-prev {
    left: -60px;
}

.space-lightbox-next {
    right: -60px;
}

.space-lightbox-counter {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
}

.space-description,
.space-specifications {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.space-description h3,
.space-specifications h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #212529;
}

.description-content {
    line-height: 1.6;
    color: #495057;
}

.booking-form-sticky {
    position: sticky;
    top: 20px;
}

.booking-form-sticky .card {
    border: 2px solid #0d6efd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.booking-form-sticky .card-header {
    border-bottom: 2px solid rgba(255,255,255,0.2);
}

.booking-form-sticky .card-header h4 {
    font-size: 1.25rem;
}

.price-display {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 2px dashed #0d6efd;
}

.price-display #total-price {
    font-weight: 700;
}

#add-to-cart-btn {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 12px;
}

#add-to-cart-btn:disabled {
    cursor: not-allowed;
}

.booking-notes {
    background: #fff3cd;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ffc107;
}

.booking-notes i {
    margin-right: 5px;
}

/* Form elements */
.form-label strong {
    color: #212529;
}

.form-select {
    padding: 12px 20px !important;
    line-height: 1.5;
    height: auto;
}

.form-text {
    font-size: 0.875rem;
    margin-top: 5px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .space-title {
        font-size: 1.5rem;
    }

    .space-venue {
        font-size: 1rem;
    }

    .space-images .carousel-item img {
        height: 250px;
    }

    .space-thumb {
        width: 56px;
        height: 42px;
    }

    .space-lightbox-prev { left: -40px; }
    .space-lightbox-next { right: -40px; }

    .booking-form-sticky {
        position: static;
        margin-top: 30px;
    }
}

/* Loading spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Mini Cart - 固定在底部 */
.minicart-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: #ffffff;
    border-top: 3px solid #0d6efd;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
    padding: 10px 15px;
    overflow-x: auto;
    overflow-y: hidden;
}

.minicart-container.active {
    display: flex;
    align-items: center;
    gap: 15px;
}

.minicart-header {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    border-right: 2px solid #dee2e6;
    height: 80px;
}

.minicart-header h5 {
    margin: 0;
    font-size: 0.9rem;
    color: #6c757d;
}

.minicart-header .cart-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0d6efd;
}

.minicart-items {
    flex: 1;
    display: flex;
    gap: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 0;
}

.minicart-item {
    flex-shrink: 0;
    width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 5px;
}

.minicart-item-image {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid #dee2e6;
}

.minicart-item-name {
    font-size: 0.75rem;
    line-height: 1.2;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
}

.minicart-actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 15px;
    border-left: 2px solid #dee2e6;
    height: 80px;
    justify-content: center;
}

.minicart-actions .btn {
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 6px 15px;
}

.minicart-close {
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 25px;
    height: 25px;
    line-height: 1;
}

.minicart-close:hover {
    color: #dc3545;
}

/* Scrollbar styling for minicart */
.minicart-items::-webkit-scrollbar {
    height: 6px;
}

.minicart-items::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.minicart-items::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.minicart-items::-webkit-scrollbar-thumb:hover {
    background: #555;
}
/* ========================================
    DateTime Selector Styles (左側展開)
    ======================================== */

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#datetime-selector {
    background: #ffffff;
    border: 2px solid #0d6efd;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.15);
}

#datetime-selector.is-open {
    animation: fadeInDown 0.3s ease-out;
}

#datetime-selector h5 {
    color: #0d6efd;
    font-weight: 600;
    margin-bottom: 0;
}

#datetime-selector h5 i {
    margin-right: 8px;
}

#close-datetime-selector {
    transition: all 0.2s;
}

#close-datetime-selector:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.time-selector {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#datetime-selector .form-label {
    margin-bottom: 5px;
    color: #495057;
}

#datetime-selector .datepicker {
    cursor: pointer;
    background-color: white;
}

#datetime-selector .alert-info {
    background-color: #e7f3ff;
    border-color: #b3d9ff;
    color: #004085;
}

#daily-duration {
    margin-top: 10px;
    padding: 10px;
}

#daily-duration strong {
    color: #0d6efd;
    font-size: 1.1em;
}

#monthly-year,
#monthly-month-start,
#monthly-month-end {
    font-weight: 500;
}

.hourly-timeslots-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

@media (min-width: 768px) {
    .hourly-timeslots-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* jQuery UI Datepicker customization */
.ui-datepicker {
    font-family: inherit;
    font-size: 0.9rem;
}

.ui-datepicker-header {
    background: #0d6efd;
    color: white;
    border-radius: 4px 4px 0 0;
}

.ui-datepicker-title {
    color: white;
}

.ui-state-active,
.ui-widget-content .ui-state-active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: white;
}
/* ========================================
   Selected Items List Styles
   ======================================== */

.selected-items-list {
    margin-top: 15px;
    padding: 10px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.selected-items-list .form-label {
    color: #495057;
    margin-bottom: 8px;
}

.items-list {
    max-height: 200px;
    overflow-y: auto;
}

.selected-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    font-size: 0.9rem;
}

.selected-item span {
    flex: 1;
    color: #004085;
}

.selected-item .btn-remove {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    transition: background 0.2s;
}

.selected-item .btn-remove:hover {
    background: #c82333;
}

/* ========================================
   時段佔用狀態樣式
   ======================================== */

/* 已佔用（在購物車中） */
.js-hourly-slot.slot-occupied {
    background-color: #fff3cd !important;
    border-color: #ffc107 !important;
    color: #856404 !important;
    text-decoration: line-through;
    opacity: 0.8;
}

/* 付款中（已結帳未完成付款） */
.js-hourly-slot.slot-pending {
    background-color: #ffe0b2 !important;
    border-color: #ff9800 !important;
    color: #e65100 !important;
    text-decoration: line-through;
    opacity: 0.8;
}

/* 已預約（已完成付款） */
.js-hourly-slot.slot-booked {
    background-color: #f8d7da !important;
    border-color: #dc3545 !important;
    color: #721c24 !important;
    text-decoration: line-through;
    opacity: 0.8;
}

/* 不可用（一般） */
.js-hourly-slot.slot-unavailable {
    background-color: #e9ecef !important;
    border-color: #adb5bd !important;
    color: #6c757d !important;
    opacity: 0.6;
}

/* 佔用時段內的狀態標籤 */
.js-hourly-slot small {
    font-size: 0.7em;
    opacity: 0.9;
}

/* ========================================
   Flatpickr 日曆佔用日期標記
   ======================================== */

/* 佔用日期共用：加小圓點 */
.flatpickr-day .fp-occupied-dot {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
}

.flatpickr-day {
    position: relative;
}

/* 購物車中（黃色） */
.fp-status-cart {
    background-color: #fff8e1 !important;
    border-color: #ffc107 !important;
    color: #795548 !important;
}
.fp-dot-cart {
    background-color: #ffc107;
}

/* 付款中（橘色） */
.fp-status-pending {
    background-color: #fff3e0 !important;
    border-color: #ff9800 !important;
    color: #e65100 !important;
}
.fp-dot-pending {
    background-color: #ff9800;
}

/* 已預約（紅色） */
.fp-status-confirmed,
.fp-status-completed {
    background-color: #fce4ec !important;
    border-color: #e53935 !important;
    color: #c62828 !important;
}
.fp-dot-confirmed,
.fp-dot-completed {
    background-color: #e53935;
}

/* 禁用的佔用日期（日租/月租整天佔用）：加刪除線 + 降透明度 */
.fp-disabled-occupied {
    text-decoration: line-through !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* 部分佔用但仍可點的日期（時租模式有部分時段被佔）：邊框強調 */
.fp-occupied:not(.flatpickr-disabled) {
    cursor: pointer !important;
    font-weight: bold !important;
}

/* hover 時顯示 tooltip 效果 */
.fp-occupied[title]:hover {
    cursor: help;
}

