/* aiutoma-playground-chat */
#aiutoma-playground-chat-wrapper {
    position: relative;
    margin-bottom: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    transition: height 0.4s ease, opacity 0.4s ease, margin-bottom 0.4s ease;
}

#aiutoma-playground-chat-wrapper.has-content {
    height: 300px;
    opacity: 1;
    margin-bottom: 15px;
}

#aiutoma-playground-chat {
    border: 1px solid #ddd;
    padding: 15px;
    height: 100%;
    overflow-y: auto;
    background: #fafafa;
    border-radius: 4px;
    font-family: monospace;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

#aiutoma-playground-chat-wrapper .toggle-distraction-free {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 10;
    opacity: 0.7;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: #50575e;
}

#aiutoma-playground-chat-wrapper .toggle-distraction-free:hover {
    opacity: 1;
    background: #f6f7f7;
    color: #2271b1;
}

.aiutoma-playground-card.distraction-free {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 100000 !important;
    margin: 0 !important;
    background: #fafafa !important;
    max-width: none !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
}

.aiutoma-playground-card.distraction-free #aiutoma-playground-chat-wrapper {
    flex-grow: 1 !important;
    height: auto !important;
    margin-bottom: 20px !important;
}

.aiutoma-playground-card.distraction-free #aiutoma-playground-chat {
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
}

.aiutoma-playground-card.distraction-free .ui-resizable-se,
.aiutoma-playground-card.distraction-free .ui-resizable-s {
    display: none !important;
}

.aiutoma-playground-card.distraction-free .aiutoma-playground-prompt-wrapper,
.aiutoma-playground-card.distraction-free .aiutoma-toolbar {
    flex-shrink: 0;
}

.ui-resizable-se {
    width: 0px;
    height: 0px;
    border-style: solid;
    border-width: 0 0 10px 10px;
    border-color: transparent transparent gray transparent;
    transform: rotate(0deg);
    position: absolute;
    bottom: 1px;
    right: 1px;
    cursor: se-resize;
}

.ui-resizable-s {
    cursor: s-resize;
    height: 7px;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
}

/* aiutoma-playground-prompt */
.aiutoma-playground-prompt-wrapper {
    position: relative;
}

@keyframes aiutoma-prompt-pulse {
    0% {
        box-shadow: 0 0 55px var(--wp-admin-theme-color-darker-10);
    }

    50% {
        box-shadow: 0 0 75px var(--wp-admin-theme-color-darker-10);
    }

    100% {
        box-shadow: 0 0 55px var(--wp-admin-theme-color-darker-10);
    }
}

#aiutoma-playground-prompt {
    width: 100%;
    height: 82px;
    margin-bottom: 10px;
    border-radius: 50px;
    padding: 30px;
    padding-right: 50px;
    padding-left: 60px;
    resize: none;
    box-shadow: 0 0 55px var(--wp-admin-theme-color-darker-10);
    /*animation: aiutoma-prompt-pulse 5s infinite ease-in-out;*/
}

#aiutoma-playground-attachment-preview {
    display: none;
    position: absolute;
    bottom: 100px;
    left: 15px;
    background: #fff;
    padding: 5px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    gap: 5px;
    flex-wrap: wrap;
    max-width: 80%;
    z-index: 10;
}

#aiutoma-speech-to-text {
    position: absolute;
    right: 30px;
    top: 30px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    display: none;
    color: #50575e;
    transition: color 0.2s ease;
}

#aiutoma-speech-to-text:hover {
    color: #2271b1;
}

#aiutoma-attach-media {
    position: absolute;
    left: 25px;
    top: 30px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    color: #50575e;
    transition: color 0.2s ease;
}

#aiutoma-attach-media:hover {
    color: #2271b1;
}

.aiutoma-prompt-hint {
    position: absolute;
    bottom: 20px;
    right: 30px;
    font-size: 11px;
    color: #a7aaad;
    pointer-events: none;
    font-style: italic;
}

/* aiutoma-toolbar */
.aiutoma-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: #efefef;
    border-radius: 8px;
    position: relative;
    z-index: 1;
}

.aiutoma-toolbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

#aiutoma-playground-model {
    max-width: 300px;
}

.aiutoma-auto-approve-label {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #50575e;
}

.aiutoma-fallback-models-label {
    margin-left: 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #50575e;
}

.aiutoma-toolbar-separator {
    border-left: 1px solid #ccc;
    height: 20px;
    margin: 0 5px;
}

.aiutoma-session-btn {
    padding: 0 8px;
    min-height: 28px;
    line-height: normal;
}

#aiutoma-export-session .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

#aiutoma-import-session .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* aiutoma-examples */
.aiutoma-examples-wrapper,
.aiutoma-recent-prompts-wrapper {
    margin-top: 15px;
}

.aiutoma-examples-title,
.aiutoma-recent-prompts-title {
    margin-top: 0;
    margin-bottom: 8px;
    color: #646970;
    font-weight: 600;
}

.aiutoma-examples-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aiutoma-example-btn {
    font-size: 12px;
    padding: 4px 8px;
    height: auto;
    min-height: 0;
    line-height: 1.4;
}

/* aiutoma-recent-prompts */
.aiutoma-recent-prompts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aiutoma-no-recent-prompts {
    margin: 0;
    font-size: 12px;
    color: #8c8f94;
}

.aiutoma-recent-prompt-btn {
    font-size: 12px;
    padding: 4px 8px;
    height: auto;
    min-height: 0;
    line-height: 1.4;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.aiutoma-recent-prompts-log-link {
    margin-top: 15px;
    text-align: right;
}

/* aiutoma-cards */
.aiutoma-playground-card {
    max-width: 100%;
    margin-top: 20px;
    padding: 25px;
    border-radius: 8px;
    min-height: 75vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.aiutoma-api-config-card {
    max-width: 800px;
    margin-top: 20px;
    padding: 25px;
    border-radius: 8px;
}

.aiutoma-api-config-title {
    margin-top: 0;
}

#test-results {
    margin-top: 10px;
    font-weight: bold;
}

.aiutoma-api-config-notice {
    margin-top: 20px !important;
}

/* aiutoma-layout */
.aiutoma-cards-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-top: 20px;
    flex-wrap: wrap;
}

.aiutoma-column-card {
    flex: 1 1 45%;
    margin-top: 0;
    margin-bottom: 0;
    min-width: 300px;
    max-width: 100%;
}

.aiutoma-empty-column {
    flex: 1 1 45%;
    min-width: 300px;
}

.aiutoma-context-card,
.aiutoma-rag-card,
.aiutoma-abilities-card {
    margin-top: 20px;
    max-width: 100%;
    box-sizing: border-box;
}

.aiutoma-card-summary-wrap {
    cursor: pointer;
    outline: none;
    padding-bottom: 5px;
    list-style: none;
    display: block;
    position: relative;
}

.aiutoma-card-summary-wrap::-webkit-details-marker {
    display: none;
}

.aiutoma-card-summary-wrap h2 {
    display: inline-block;
    margin: 0;
}

.aiutoma-card-summary-wrap::after {
    content: '+';
    font-size: 22px;
    font-weight: 400;
    color: #646970;
    line-height: 1;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s ease;
}

details[open]>.aiutoma-card-summary-wrap::after {
    content: '−';
}

.aiutoma-card-title {
    margin-top: 0;
}

/* aiutoma-backups */
.aiutoma-backups-container {
    margin-top: 15px;
    text-align: left;
}

.aiutoma-backups-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    text-align: right;
}

.aiutoma-backups-summary {
    cursor: pointer;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
}

.aiutoma-backups-list {
    margin-top: 10px;
    margin-bottom: 0;
    max-height: 150px;
    overflow-y: auto;
    padding-left: 0;
    color: #666;
    font-family: monospace;
    list-style: none;
}

.aiutoma-backup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding: 6px 0;
}

.aiutoma-backup-time {
    font-weight: 600;
    display: block;
}

.aiutoma-backup-desc {
    font-size: 11px;
    color: #8c8f94;
}

/* aiutoma-rollback */
.aiutoma-rollback-btn-wrapper {
    margin-top: 8px;
    text-align: right;
}

.aiutoma-rollback-btn {
    border-color: #d63638 !important;
    color: #d63638 !important;
}

/* aiutoma-messages */
.aiutoma-msg-user {
    margin-bottom: 15px;
    background: #e3f2fd;
    padding: 10px;
    border-radius: 4px;
}

.aiutoma-msg-loading {
    margin-bottom: 15px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 8px;
}

.aiutoma-msg-loading svg {
    width: 16px;
    height: 16px;
    animation: aiutoma-spin 1s linear infinite;
}

.aiutoma-msg-ai {
    margin-bottom: 15px;
    margin-top: 15px;
    background: #fff;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 4px;
}

.aiutoma-msg-error {
    margin-bottom: 15px;
    color: #d63638;
    background: #fcf0f1;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #f8c3c4;
}

.aiutoma-msg-tool-result {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ccc;
}

.aiutoma-msg-tool-result.aiutoma-error {
    color: #d63638;
}

.aiutoma-msg-tool-result.aiutoma-success {
    color: #46b450;
}

.aiutoma-msg-tool-details {
    margin-top: 6px;
    cursor: pointer;
}

.aiutoma-msg-tool-details summary {
    color: #666;
    font-size: 10px;
}

.aiutoma-msg-tool-pre,
.aiutoma-msg-sql-pre {
    margin-top: 4px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    overflow-x: auto;
    color: #333;
    font-size: 10px;
}

.aiutoma-msg-sql-pre {
    background: #282c34;
    color: #abb2bf;
    padding: 10px;
    font-family: monospace;
    line-height: 1.4;
    font-size: 13px;
}

.aiutoma-tool-header-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
    user-select: none;
}

.aiutoma-tool-header-toggle:hover {
    background: #e9ecef !important;
}

.aiutoma-tool-help {
    margin-left: auto;
    color: #646970;
    background: #f0f0f1;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #ccc;
}

.aiutoma-code-ta {
    width: 100%;
    font-family: monospace;
}

.aiutoma-code-ta+.CodeMirror {
    height: auto !important;
    min-height: 100px;
}

.aiutoma-pre-wrap {
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 11px;
    margin: 5px 0 0 0;
    background: #fff;
    padding: 8px;
    border: 1px solid #ddd;
    max-height: 200px;
    overflow-y: auto;
}

.aiutoma-hl-keyword {
    color: #c678dd;
}

.aiutoma-hl-string {
    color: #98c379;
}

.aiutoma-hl-var {
    color: #e06c75;
}

.aiutoma-hl-func {
    color: #61afef;
}

/* Select2 WP Admin overrides */
.select2-container {
    max-width: 100%;
}

.select2-container--default .select2-selection--single {
    height: 30px;
    border: 1px solid #8c8f94;
    border-radius: 3px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    color: #2c3338;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 28px;
}

.aiutoma-hidden {
    display: none !important;
}

.aiutoma-btn-danger {
    color: #d63638 !important;
    border-color: #d63638 !important;
}

/* aiutoma-context styling removed as now uses layout classes */

.aiutoma-context-columns {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.aiutoma-context-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

.aiutoma-context-col label {
    margin-bottom: 8px;
    font-size: 13px;
}

.aiutoma-context-textarea {
    width: 100%;
    height: 350px;
    margin-bottom: 10px;
    font-family: monospace;
    font-size: 12px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
}

/* Mobile Responsiveness */
@media screen and (max-width: 782px) {
    .aiutoma-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px;
    }

    .aiutoma-toolbar-left {
        flex-direction: row;
        align-items: center;
        width: 100%;
        gap: 10px;
        flex-wrap: wrap;
    }

    .aiutoma-toolbar-right {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        gap: 10px;
    }

    .aiutoma-toolbar-separator {
        display: none;
    }

    #aiutoma-playground-model+.select2-container {
        flex: 1;
        width: calc(100% - 80px) !important;
        min-width: 0;
        order: 1;
    }

    .aiutoma-toolbar-left .aiutoma-session-btn {
        order: 2;
    }

    #aiutoma-fallback-models-container {
        width: 100%;
        margin-left: 0;
        order: 3;
    }

    .aiutoma-playground-card {
        padding: 15px;
        margin-top: 10px;
    }

    .aiutoma-context-columns {
        flex-direction: column;
        gap: 10px;
    }

    .aiutoma-cards-row {
        flex-direction: column;
        gap: 10px;
    }

    .aiutoma-column-card,
    .aiutoma-empty-column {
        flex: 1 1 100%;
        min-width: 100%;
    }

    #aiutoma-playground-prompt {
        height: 60px;
        padding: 15px 45px;
        border-radius: 30px;
        font-size: 14px;
    }

    #aiutoma-attach-media {
        left: 15px;
        top: 20px;
    }

    #aiutoma-speech-to-text {
        right: 15px;
        top: 20px;
    }

    .aiutoma-prompt-hint {
        display: none;
    }
    
    .aiutoma-hide-on-mobile {
        display: none;
    }
}