/**
 * Plexa Chat Styles
 */

/* Container - fixed position fills available space */
.plexa-chat {
    position: fixed;
    top: 32px; /* Below WP admin bar */
    left: 160px; /* WP admin sidebar */
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    overflow: hidden;
}

/* Collapsed admin menu */
.folded .plexa-chat {
    left: 36px;
}

/* Breadcrumb Header */
.plexa-chat-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #222;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 101;
}

.plexa-chat-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #ccc;
}

.plexa-breadcrumb-link {
    color: #4a90d9;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.plexa-breadcrumb-link:hover {
    color: #6bb3f0;
}

.plexa-breadcrumb-link .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.plexa-breadcrumb-sep {
    color: #666;
}

.plexa-breadcrumb-task {
    color: #999;
}

.plexa-breadcrumb-title {
    color: #fff;
    font-weight: 500;
}

/* Chat Zone - scrollable messages area */
.plexa-chat-zone--chat {
    position: absolute;
    top: 49px; /* Below header */
    left: 0;
    right: 0;
    bottom: 65px; /* Space for fixed prompt */
    overflow-y: auto;
    padding: 16px;
}

/* Prompt area - fixed at bottom of screen */
.plexa-chat-prompt {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid #333;
    padding: 12px;
    background: #222;
    z-index: 100;
}

/* Responsive - mobile adjustments */
@media (max-width: 782px) {
    .plexa-chat {
        top: 46px; /* Mobile admin bar is taller */
        left: 0; /* No sidebar on mobile */
    }
}

/* Messages */
.plexa-chat-messages__inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plexa-chat-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
}

/* All messages on left */
.plexa-chat-message--user {
    margin-right: auto;
}

.plexa-chat-message--assistant {
    margin-right: auto;
}

.plexa-chat-message--system {
    margin: 0 auto;
    max-width: 90%;
}

/* Hide avatar for assistant */
.plexa-chat-message--assistant .plexa-chat-avatar {
    display: none;
}

/* Avatar (user only) */
.plexa-chat-avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #4a90d9;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.plexa-chat-avatar .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Bubble */
.plexa-chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.5;
}

/* User prompt - blue with white text */
.plexa-chat-message--user .plexa-chat-bubble {
    background: #4a90d9;
    color: #fff;
    border-bottom-left-radius: 4px;
}

/* Assistant response - no background, no border, white text */
.plexa-chat-message--assistant .plexa-chat-bubble {
    background: transparent;
    color: #fff;
    padding-left: 0;
    padding-right: 0;
}

.plexa-chat-message--system .plexa-chat-bubble {
    background: #333;
    color: #ccc;
    text-align: center;
    font-size: 12px;
}

.plexa-chat-content {
    word-wrap: break-word;
    font-size: 19px;
    white-space: pre-line;
}

.plexa-chat-content p:first-child {
    margin-top: 0;
}

.plexa-chat-content p:last-child {
    margin-bottom: 0;
}

/* Hide time stamps */
.plexa-chat-time {
    display: none;
}

/* Prompt */
.plexa-chat-prompt__form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.plexa-chat-prompt__input-wrap {
    flex: 1 1 auto;
}

.plexa-chat-prompt__input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #444;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
    background: #2a2a2a;
    color: #fff;
}

.plexa-chat-prompt__input::placeholder {
    color: #888;
}

.plexa-chat-prompt__input:focus {
    border-color: #4a90d9;
}

.plexa-chat-prompt__send {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #4a90d9;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.plexa-chat-prompt__send:hover {
    background: #3a7bc8;
}

.plexa-chat-prompt__send:disabled {
    background: #555;
    cursor: not-allowed;
}

.plexa-chat-prompt__send .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Loading */
.plexa-chat-loading {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.plexa-chat-loading__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
    animation: plexa-chat-bounce 1.4s infinite ease-in-out both;
}

.plexa-chat-loading__dot:nth-child(1) {
    animation-delay: -0.32s;
}

.plexa-chat-loading__dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes plexa-chat-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Typing indicator */
.plexa-chat-typing {
    opacity: 0.7;
}

/* Error */
.plexa-chat-error {
    padding: 10px 14px;
    background: #4a2020;
    color: #ff6b6b;
    border-radius: 8px;
    margin: 8px 0;
    font-size: 13px;
}

/* Buttons */
.plexa-chat-button {
    padding: 8px 16px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #2a2a2a;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.plexa-chat-button:hover {
    background: #333;
    border-color: #555;
}

.plexa-chat-button--primary {
    background: #4a90d9;
    border-color: #4a90d9;
    color: #fff;
}

.plexa-chat-button--primary:hover {
    background: #3a7bc8;
    border-color: #3a7bc8;
}

.plexa-chat-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Cards */
.plexa-chat-card {
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    background: #222;
    margin: 8px 0;
}

.plexa-chat-card__image img {
    width: 100%;
    height: auto;
    display: block;
}

.plexa-chat-card__body {
    padding: 12px;
}

.plexa-chat-card__title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.plexa-chat-card__content {
    font-size: 13px;
    color: #aaa;
    line-height: 1.5;
}

.plexa-chat-card__actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

/* Form fields */
.plexa-form-field {
    margin-bottom: 16px;
}

.plexa-form-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: #ccc;
}

.plexa-form-field .required {
    color: #ff6b6b;
}

.plexa-form-field input[type="text"],
.plexa-form-field input[type="email"],
.plexa-form-field input[type="number"],
.plexa-form-field textarea,
.plexa-form-field select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #444;
    border-radius: 6px;
    font-size: 14px;
    background: #2a2a2a;
    color: #fff;
}

.plexa-form-field input:focus,
.plexa-form-field textarea:focus,
.plexa-form-field select:focus {
    outline: none;
    border-color: #4a90d9;
}

.plexa-form-description {
    margin: 4px 0 0;
    font-size: 12px;
    color: #888;
}

.plexa-form-checkbox,
.plexa-form-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #ccc;
}

.plexa-form-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.plexa-form-submit {
    margin-top: 20px;
}

/* Action Buttons (from Action Response) */
.plexa-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.plexa-action-btn {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid #444;
    border-radius: 20px;
    background: #2a2a2a;
    color: #fff;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.plexa-action-btn:hover {
    background: #333;
    border-color: #555;
    color: #fff;
}

.plexa-action-btn--primary {
    background: #4a90d9;
    border-color: #4a90d9;
}

.plexa-action-btn--primary:hover {
    background: #3a7bc8;
    border-color: #3a7bc8;
}

.plexa-action-btn--secondary {
    background: transparent;
    border-color: #4a90d9;
    color: #4a90d9;
}

.plexa-action-btn--secondary:hover {
    background: rgba(74, 144, 217, 0.1);
    color: #6bb3f0;
    border-color: #6bb3f0;
}

/* Hide WordPress admin footer thank you */
#footer-thankyou {
    display: none;
}

/* =========================================================================
   FRONTEND OVERRIDES
   ========================================================================= */

/* Frontend container - inline flow instead of fixed */
.plexa-chat--frontend {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    height: 600px;
    border-radius: 8px;
    overflow: hidden;
}

/* Frontend header - hide breadcrumb on frontend */
.plexa-chat--frontend .plexa-chat-header {
    position: relative;
    display: none;
}

/* Frontend chat zone - relative with scroll */
.plexa-chat--frontend .plexa-chat-zone--chat {
    position: relative;
    top: auto;
    bottom: auto;
    height: calc(100% - 65px);
}

/* Frontend prompt - relative at bottom */
.plexa-chat--frontend .plexa-chat-prompt {
    position: relative;
}
