/* ============================================================
   Sultan AI Assistant — front-end widget
   ============================================================ */

/* --- Chat bubble toggle --- */
.saa-widget-toggle {
    position: fixed;
    z-index: 999999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--saa-color, #2563eb);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    line-height: 1;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

.saa-widget-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.saa-widget-toggle:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

.saa-widget-toggle svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* --- Chat panel --- */
.saa-chat-panel {
    position: fixed;
    z-index: 999999;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    color: #1f2937;
    overflow: hidden;
}

.saa-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.saa-chat-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.saa-chat-header .saa-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: #6b7280;
    padding: 0 4px;
    line-height: 1;
}

.saa-chat-header .saa-close-btn:hover {
    color: #111827;
}

.saa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 280px;
    max-height: calc(100vh - 220px);
    background: #f9fafb;
}

.saa-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.saa-message.user {
    align-self: flex-end;
    background: var(--saa-color, #2563eb);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.saa-message.assistant {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.saa-message .saa-timestamp {
    display: block;
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

.saa-message.assistant .saa-timestamp {
    color: #6b7280;
}

.saa-message.user .saa-timestamp {
    color: rgba(255, 255, 255, 0.7);
}

.saa-empty-state {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    padding: 30px 10px;
    line-height: 1.6;
}

.saa-empty-state svg {
    width: 48px;
    height: 48px;
    fill: #d1d5db;
    margin-bottom: 12px;
}

.saa-thinking {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px 16px;
    color: #6b7280;
    font-size: 14px;
}

.saa-chat-input {
    display: flex;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.saa-chat-input input {
    flex: 1;
    border: none;
    padding: 12px 14px;
    font-size: 14px;
    outline: none;
    background: #f3f4f6;
    color: #1f2937;
    font-family: inherit;
}

.saa-chat-input input:focus {
    background: #e5e7eb;
}

.saa-chat-input button {
    background: var(--saa-color, #2563eb);
    color: #fff;
    border: none;
    padding: 0 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: opacity 0.15s;
}

.saa-chat-input button:hover {
    opacity: 0.9;
}

.saa-chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Booking form inside chat --- */
.saa-booking-form {
    padding: 14px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    overflow-y: auto;
    flex-shrink: 0;
    max-height: 100%;
    box-sizing: border-box;
}

/* When the booking form is open, collapse the messages area so the
   form (and its Submit/Cancel buttons) stay fully visible within
   the panel's fixed height instead of being clipped by overflow:hidden. */
.saa-chat-panel.saa-booking-active .saa-chat-messages {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 30%;
}

.saa-chat-panel.saa-booking-active .saa-booking-form {
    flex: 1 1 auto;
    min-height: 0;
}

.saa-chat-panel.saa-booking-active .saa-chat-input {
    display: none;
}

.saa-booking-form h4 {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
}

.saa-booking-field {
    margin-bottom: 10px;
}

.saa-booking-field label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 3px;
    font-weight: 500;
}

.saa-booking-field input,
.saa-booking-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    background: #fff;
}

.saa-booking-field input:focus,
.saa-booking-field textarea:focus {
    outline: none;
    border-color: var(--saa-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.saa-booking-field textarea {
    resize: vertical;
    min-height: 60px;
}

.saa-date-row {
    display: flex;
    gap: 8px;
}

.saa-date-row input[type="date"] {
    flex: 1;
}

.saa-time-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.saa-slot-btn {
    padding: 5px 10px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.12s;
    color: #1f2937;
}

.saa-slot-btn:hover {
    border-color: var(--saa-color, #2563eb);
    color: var(--saa-color, #2563eb);
}

.saa-slot-btn.selected {
    background: var(--saa-color, #2563eb);
    color: #fff;
    border-color: var(--saa-color, #2563eb);
}

.saa-slot-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.saa-booking-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.saa-booking-actions button {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

.saa-btn-primary {
    background: var(--saa-color, #2563eb);
    color: #fff;
}

.saa-btn-secondary {
    background: #f3f4f6;
    color: #1f2937;
}

.saa-btn-primary:hover {
    opacity: 0.9;
}

/* --- Position --- */
.saa-widget-position-bottom-right .saa-widget-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
}

.saa-widget-position-bottom-right .saa-chat-panel {
    position: fixed;
    right: 24px;
    bottom: 90px;
    z-index: 999998;
}

.saa-widget-position-bottom-left .saa-widget-toggle {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 999999;
}

.saa-widget-position-bottom-left .saa-chat-panel {
    position: fixed;
    left: 24px;
    bottom: 90px;
    z-index: 999998;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .saa-chat-panel,
    .saa-widget-position-bottom-right .saa-chat-panel,
    .saa-widget-position-bottom-left .saa-chat-panel {
        width: 100vw;
        max-width: 100vw;
        border-radius: 0;
        height: 100vh;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    .saa-chat-messages {
        max-height: calc(100vh - 60px);
    }

    .saa-message {
        max-width: 100%;
    }

    .saa-chat-input input {
        padding: 10px 12px;
        font-size: 16px;
    }

    .saa-chat-input button {
        padding: 0 12px;
        font-size: 16px;
    }

    .saa-chat-input {
        border-top: 1px solid #e5e7eb;
    }
}
