/**
 * Booking Modal - Premium Feminine UX Design
 * Phòng khám Da liễu Bác sĩ Trần Thịnh
 */

/* ============================================
   Overlay & Container
   ============================================ */
.booking-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(46, 56, 68, 0.85);
    backdrop-filter: blur(8px);
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.booking-modal-overlay.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
    opacity: 1;
    animation: fadeIn 0.3s ease;
}

.booking-modal-container {
    background: #fff;
    border-radius: 20px;
    max-width: 620px;
    width: calc(100% - 30px);
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(30px);
    opacity: 0;
    animation: slideUp 0.4s ease 0.1s forwards;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.shake-vibe {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* ============================================
   Header
   ============================================ */
.booking-modal-header {
    padding: 20px 24px 16px;
    background: linear-gradient(135deg, #E99931 0%, #f5a855 100%);
    color: white;
    position: relative;
    text-align: center;
}

.booking-modal-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 3px 0;
    font-family: 'Marcellus', serif;
}

.booking-modal-subtitle {
    margin: 0;
    opacity: 0.95;
    font-size: 13px;
    font-weight: 400;
}

.booking-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    font-size: 24px;
    z-index: 10;
}

/* Bottom Sheet Handle for Mobile */
.bottom-sheet-handle {
    display: none;
    width: 40px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    margin: 8px auto 4px;
}

.booking-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ============================================
   Progress Indicator (2 steps)
   ============================================ */
.booking-step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 24px;
    background: #fff;
    gap: 16px;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 150px;
}

.step-number {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f0f0f0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    transition: all 0.3s ease;
}

.step-item.active .step-number {
    background: linear-gradient(135deg, #E99931, #f5a855);
    color: white;
    box-shadow: 0 4px 12px rgba(233, 153, 49, 0.4);
}

.step-item.completed .step-number {
    background: #28a745;
    color: white;
}

.step-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    text-align: center;
}

.step-item.active .step-label {
    color: #E99931;
    font-weight: 600;
}

.step-divider {
    flex: 0 0 30px;
    height: 2px;
    background: #e0e0e0;
    margin-bottom: 22px;
}

/* ============================================
   Modal Body
   ============================================ */
.booking-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    position: relative;
}

.booking-form-step {
    display: none;
}

.booking-form-step.active {
    display: block;
    animation: fadeInSlide 0.4s ease;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.step-intro {
    text-align: center;
    margin-bottom: 20px;
}

.step-intro h3 {
    font-size: 18px;
    color: #2E3844;
    margin: 0 0 6px 0;
    font-weight: 600;
}

.step-intro p {
    color: #666;
    margin: 0;
    font-size: 14px;
}

/* Hide title in Step 2 to save space */
#bookingStep2 .step-intro h3 {
    display: none;
}

#bookingStep2 .step-intro {
    margin-bottom: 16px;
}

/* Inline summary in subtitle */
.selected-summary {
    color: #28a745 !important;
    font-weight: 500;
    font-size: 13px;
    text-align: center;
}

/* ============================================
   Service Grid
   ============================================ */
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.service-card {
    padding: 20px 16px;
    border: 2px solid #f0f0f0;
    border-radius: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.service-card:hover {
    border-color: #E99931;
    background: #fff8f0;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(233, 153, 49, 0.15);
}

.service-card.selected {
    border-color: #E99931;
    background: linear-gradient(135deg, #fff8f0, #fff);
    box-shadow: 0 8px 24px rgba(233, 153, 49, 0.25);
}

.service-icon {
    font-size: 40px;
    color: #E99931;
    margin-bottom: 12px;
    display: block;
}

.service-name {
    font-weight: 600;
    color: #2E3844;
    margin-bottom: 6px;
    font-size: 16px;
}

.service-description {
    font-size: 13px;
    color: #777;
    line-height: 1.4;
}

/* ============================================
   Date/Time Selection
   ============================================ */
.datetime-selection {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px dashed #f0f0f0;
}

.section-title {
    font-size: 18px;
    color: #2E3844;
    margin: 0 0 20px 0;
    font-weight: 600;
    text-align: center;
}

.date-picker-wrapper {
    margin-bottom: 25px;
}

.date-input {
    cursor: pointer !important;
}

.time-selection {
    margin-top: 25px;
}

.time-periods {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.period-option {
    flex: 1;
    cursor: pointer;
}

.period-option input {
    display: none;
}

.period-option span {
    display: block;
    padding: 10px;
    text-align: center;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    transition: all 0.3s ease;
}

.period-option input:checked+span {
    background: #fff8f0;
    border-color: #E99931;
    color: #E99931;
    box-shadow: 0 4px 10px rgba(233, 153, 49, 0.15);
}

.slot-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.slot-btn {
    padding: 10px 5px;
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 8px;
    font-size: 14px;
    color: #212529;
    cursor: pointer;
    transition: all 0.2s ease;
}

.slot-btn:hover {
    border-color: #E99931;
    color: #E99931;
    background: #fff8f0;
}

.slot-btn.active {
    background: #E99931;
    color: #fff;
    border-color: #E99931;
    box-shadow: 0 4px 8px rgba(233, 153, 49, 0.3);
}

@media (max-width: 480px) {
    .slot-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   Form Elements
   ============================================ */
.form-label {
    display: block;
    margin-bottom: 6px;
    color: #2E3844;
    font-weight: 600;
    font-size: 13px;
}

.form-label i {
    color: #E99931;
    margin-right: 4px;
    font-size: 12px;
}

.required {
    color: #E99931;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
    background: #fafafa;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #E99931;
    background: white;
    box-shadow: 0 0 0 4px rgba(233, 153, 49, 0.1);
}

/* Fix iOS Auto-zoom by ensuring font-size is at least 16px */
@media (max-width: 767px) {

    .form-input,
    .form-textarea {
        font-size: 16px !important;
        padding: 12px 16px;
    }
}

.form-input.error {
    border-color: #dc3545;
    background: #fff5f5;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-error {
    display: none;
    color: #dc3545;
    font-size: 13px;
    margin-top: 6px;
}

.form-input.error~.form-error {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

/* Removed bulky selected-info box - now using inline summary in subtitle */

/* ============================================
   Privacy Notice
   ============================================ */
.privacy-notice {
    background: #f0f8ff;
    border: 1px solid #bee5eb;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #0c5460;
}

.privacy-notice i {
    font-size: 16px;
    color: #17a2b8;
}

/* ============================================
   Success State
   ============================================ */
.booking-success {
    text-align: center;
    padding: 40px 20px;
}

.success-icon {
    font-size: 80px;
    color: #28a745;
    margin-bottom: 20px;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.success-title {
    font-size: 26px;
    color: #2E3844;
    margin: 0 0 15px 0;
    font-weight: 600;
}

.success-message {
    color: #666;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.success-booking-id {
    background: #f9f9f9;
    padding: 15px 20px;
    border-radius: 30px;
    display: inline-block;
    margin-top: 10px;
    border: 2px dashed #E99931;
    margin-bottom: 30px;
}

.success-booking-id strong {
    color: #E99931;
    font-size: 20px;
}

.success-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 320px;
    margin: 20px auto 0;
}

.btn-success-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s ease;
}

.btn-success-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

#addToCalendarBtn {
    background: #fff;
    border: 2px solid #E99931;
    color: #E99931;
}

#addToCalendarBtn:hover {
    background: #fff8f0;
}

.skin-quiz_active {
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    color: white;
}

.skin-quiz-link {
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    color: white;
}

.skin-quiz-link:hover {
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
}

/* ============================================
   Loading State
   ============================================ */
.booking-loading {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.booking-loading.active {
    display: block;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top-color: #E99931;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.booking-loading p {
    color: #666;
    font-size: 16px;
}

/* ============================================
   Footer Buttons
   ============================================ */
.booking-modal-footer {
    padding: 20px 30px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.btn-booking {
    padding: 14px 30px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-booking:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-booking-primary {
    background: linear-gradient(135deg, #E99931, #f5a855);
    color: white;
    flex: 1;
}

.btn-booking-primary:not(:disabled):hover {
    background: linear-gradient(135deg, #d88520, #E99931);
    box-shadow: 0 4px 12px rgba(233, 153, 49, 0.4);
    transform: translateY(-2px);
}

/* Thumb-zone optimization for mobile */
@media (max-width: 575px) {
    .btn-booking {
        padding: 16px 20px;
        font-size: 16px;
        border-radius: 14px;
    }

    .booking-modal-footer {
        padding: 15px 20px 25px;
        /* Extra bottom padding for safe area */
    }
}

.btn-booking-secondary {
    background: white;
    color: #666;
    border: 2px solid #e0e0e0;
}

.btn-booking-secondary:hover {
    background: #f9f9f9;
    border-color: #ccc;
}

/* ============================================
   Flatpickr Customization
   ============================================ */
.flatpickr-calendar {
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
    border: none !important;
}

.flatpickr-day.selected {
    background: #E99931 !important;
    border-color: #E99931 !important;
}

.flatpickr-day:hover:not(.disabled) {
    background: #fff8f0 !important;
    border-color: #E99931 !important;
}

.flatpickr-day.disabled {
    color: #ccc !important;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 575px) {
    .booking-modal-overlay {
        align-items: flex-end;
        /* Align to bottom for sheet effect */
    }

    .booking-modal-container {
        max-width: 100%;
        width: 100%;
        margin-bottom: 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-top-left-radius: 25px;
        border-top-right-radius: 25px;
        max-height: 94vh;
        transform: translateY(100%);
        animation: slideFromBottom 0.5s cubic-bezier(0.32, 1, 0.23, 1) 0.1s forwards;
    }

    .bottom-sheet-handle {
        display: block;
    }

    .booking-modal-header {
        padding: 4px 18px 14px;
        /* Reduced top padding for handle */
    }

    .booking-modal-close {
        top: 15px;
        right: 15px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
}

@keyframes slideFromBottom {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .booking-modal-container {
        max-width: calc(100% - 16px);
        max-height: 92vh;
        border-radius: 14px;
    }

    .booking-modal-header {
        padding: 20px 18px 14px;
    }

    .booking-modal-title {
        font-size: 22px;
    }

    .booking-step-indicator {
        padding: 16px 12px;
        gap: 8px;
    }

    .step-item {
        max-width: 120px;
    }

    .step-number {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .step-label {
        font-size: 12px;
    }

    .step-divider {
        flex: 0 0 20px;
    }

    .booking-modal-body {
        padding: 16px;
    }

    .step-intro {
        margin-bottom: 16px;
    }

    .step-intro h3 {
        font-size: 18px;
    }

    .step-intro p {
        font-size: 13px;
    }

    .service-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .service-card {
        padding: 16px 12px;
    }

    .service-icon {
        font-size: 32px;
    }

    .service-name {
        font-size: 14px;
    }

    .service-description {
        font-size: 12px;
    }

    .time-options {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .time-card {
        flex-direction: row;
        text-align: left;
        padding: 16px;
    }

    .time-card i {
        font-size: 24px;
    }

    .form-input,
    .form-textarea {
        padding: 11px 13px;
        font-size: 14px;
    }

    .form-group {
        margin-bottom: 14px;
    }

    .datetime-selection {
        margin-top: 20px;
        padding-top: 20px;
    }

    .booking-modal-footer {
        padding: 14px 16px;
        flex-direction: column-reverse;
    }

    .btn-booking {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }

    .btn-booking-secondary {
        margin-top: 0;
    }
}

@media (max-width: 480px) {
    .service-grid {
        grid-template-columns: 1fr;
    }

    .step-label {
        display: none;
    }

    .booking-modal-subtitle {
        font-size: 13px;
    }

    .btn-success-action {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   Success Mode (Full Screen Focus)
   ============================================ */
.booking-modal-container.success-mode .booking-modal-header .booking-modal-title,
.booking-modal-container.success-mode .booking-step-indicator,
.booking-modal-container.success-mode .booking-modal-footer,
.booking-modal-container.success-mode .bottom-sheet-handle {
    display: none !important;
}

.booking-modal-container.success-mode .booking-modal-header {
    border-bottom: none;
    padding-bottom: 0;
    justify-content: flex-end;
    /* Only keep close button */
    min-height: auto;
}

.booking-modal-container.success-mode .booking-modal-body {
    padding-top: 10px;
}

/* Enhanced Success Animation */
.booking-success {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}