/* ========================================
   AI Support Chat Widget — Gym Plan
   Dark theme with green accent
   ======================================== */

/* Shift panel up when cookie banner is visible */
body:has(.cookie-banner) #chat-panel {
    bottom: 158px;
}

/* Chat Panel */
#chat-panel {
    display: none;
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 520px;
    min-width: 300px;
    min-height: 300px;
    z-index: 9990;
    background: #1a1a1a;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #2a2a2a;
}

#chat-panel.open {
    display: flex;
}

/* Resize handle - top-left corner */
.chat-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 10;
}

.chat-resize-handle::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 8px 0 0;
    border-color: rgba(255, 255, 255, 0.2) transparent transparent transparent;
}

#chat-panel.resizing {
    transition: none;
    user-select: none;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.chat-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.chat-header-close:hover {
    opacity: 1;
}

/* Chat Notice */
.chat-notice {
    padding: 8px 16px;
    background: #111111;
    font-size: 0.75rem;
    color: #888;
    text-align: center;
    flex-shrink: 0;
    border-bottom: 1px solid #2a2a2a;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    background: #1a1a1a;
}

/* Message Bubbles */
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-msg-bot {
    align-self: flex-start;
    background: #2a2a2a;
    color: #e5e5e5;
}

.chat-msg-user {
    align-self: flex-end;
    background: #22c55e;
    color: #fff;
}

.chat-msg-bot p {
    margin: 0 0 8px;
}

.chat-msg-bot p:last-child {
    margin-bottom: 0;
}

.chat-msg-bot strong {
    color: #f5f5f5;
    font-weight: 600;
}

.chat-msg-bot ul,
.chat-msg-bot ol {
    margin: 6px 0;
    padding-left: 20px;
}

.chat-msg-bot li {
    margin-bottom: 4px;
}

.chat-msg-bot a {
    color: #22c55e;
    text-decoration: underline;
}

.chat-msg-bot a:hover {
    color: #4ade80;
}

/* Feedback Buttons */
.chat-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.chat-feedback-text {
    font-size: 0.8rem;
    color: #888;
}

.chat-feedback-btn {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #444;
    background: #2a2a2a;
    color: #ccc;
    font-family: inherit;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.chat-feedback-btn:hover {
    border-color: #22c55e;
    color: #22c55e;
}

.chat-feedback-thanks {
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
}

/* Escalation */
.chat-escalate-wrap {
    padding: 4px 0;
}

/* Email Callback Form */
.chat-email-callback {
    padding: 4px 0;
}

.chat-email-prompt {
    font-size: 0.85rem;
    color: #aaa;
    margin: 0 0 8px;
}

.chat-email-form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.chat-email-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    color: #f5f5f5;
    background: #2a2a2a;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-email-input:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.chat-email-input.chat-email-error {
    border-color: #dc2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.chat-email-input:disabled {
    background: #333;
    color: #888;
}

.chat-email-submit {
    padding: 8px 16px;
    background: #22c55e;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.chat-email-submit:hover {
    background: #16a34a;
}

.chat-email-submit:disabled {
    background: #444;
    cursor: not-allowed;
}

.chat-email-or {
    font-size: 0.8rem;
    color: #888;
    margin: 8px 0 0;
}

.chat-email-or a {
    color: #22c55e;
    text-decoration: underline;
}

.chat-email-or a:hover {
    color: #4ade80;
}

.chat-email-thanks {
    font-size: 0.85rem;
    color: #aaa;
    margin: 0;
    font-style: italic;
}

.chat-email-thanks a {
    color: #22c55e;
    text-decoration: underline;
}

/* Typing Indicator */
.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #2a2a2a;
    border-radius: 12px;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
    animation: chatTyping 1.4s ease-in-out infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Input Area */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #2a2a2a;
    flex-shrink: 0;
    background: #1a1a1a;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-family: inherit;
    color: #f5f5f5;
    background: #2a2a2a;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.chat-input:focus {
    background: #333;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.chat-input::placeholder {
    color: #666;
}

.chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #22c55e;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.chat-send:hover {
    background: #16a34a;
}

.chat-send:disabled {
    background: #444;
    cursor: not-allowed;
}

.chat-send svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* ========================================
   Chat Launcher Button
   ======================================== */

#chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #22c55e;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9980;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
    transition: background 0.2s ease, transform 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

#chat-launcher:hover {
    background: #16a34a;
    transform: scale(1.05);
}

#chat-launcher svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 820px) {
    #chat-panel {
        display: none !important;
    }
}
