/* AIDevis v2.2 - Single row compact bar */

.aidevis-container {
    max-width: 100%;
    margin: 14px 0 16px 0;
}

.aidevis-bar-inline {
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

/* Header */
.aidevis-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    user-select: none;
}

.aidevis-bar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
}

.aidevis-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    flex-shrink: 0;
}

.aidevis-toggle {
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.3s;
}

.aidevis-toggle.open {
    transform: rotate(180deg);
}

/* Form wrapper */
.aidevis-form {
    padding: 0 14px 10px;
}

/* === Single row: all elements inline === */
.aidevis-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

/* Textarea: takes remaining space */
.aidevis-textarea {
    flex: 1;
    min-width: 150px;
    height: 34px;
    min-height: 34px;
    max-height: 120px;
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
    outline: none;
    line-height: 1.4;
    background: rgba(255,255,255,0.93);
    color: #333;
}

.aidevis-textarea:focus {
    background: #fff;
}

/* Upload: just a paperclip icon button */
.aidevis-upload-zone {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: 1.5px dashed rgba(255,255,255,0.35);
    border-radius: 6px;
    cursor: pointer;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.aidevis-upload-zone:hover,
.aidevis-upload-zone.dragover {
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.15);
}

.aidevis-upload-icon {
    font-size: 16px;
    line-height: 1;
}

/* Client: let Dolibarr native handle it, just size it */
.aidevis-field-client {
    flex-shrink: 0;
    min-width: 200px;
    max-width: 300px;
}

.aidevis-field-client input[type="text"] {
    height: 34px !important;
    box-sizing: border-box;
}

/* Submit button */
.aidevis-submit-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    height: 34px;
    box-sizing: border-box;
    white-space: nowrap;
}

.aidevis-submit-btn:hover:not(:disabled) {
    filter: brightness(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

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

/* History button */
.aidevis-hist-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.aidevis-hist-btn:hover {
    background: rgba(255,255,255,0.15);
}

/* History panel */
.aidevis-history-panel {
    margin-top: 8px;
    background: #fff;
    border-radius: 8px;
    max-height: 350px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.aidevis-hist-section {
    padding: 8px 12px 4px;
    font-size: 12px;
    color: #263C5C;
    border-bottom: 1px solid #eee;
}

.aidevis-hist-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.1s;
}

.aidevis-hist-item:hover {
    background: #f0f4fa;
}

.aidevis-hist-other {
    background: #fafafa;
}

.aidevis-hist-other:hover {
    background: #f0f0f5;
}

.aidevis-hist-text {
    font-size: 13px;
    color: #333;
    line-height: 1.3;
    margin-bottom: 3px;
}

.aidevis-hist-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #999;
}

.aidevis-hist-del {
    cursor: pointer;
    color: #ccc;
    font-size: 16px;
    font-weight: bold;
    padding: 0 4px;
    border-radius: 3px;
}

.aidevis-hist-del:hover {
    color: #e74c3c;
    background: #fef0f0;
}

.aidevis-hist-empty {
    padding: 12px;
    text-align: center;
    color: #bbb;
    font-size: 12px;
    font-style: italic;
}

/* File chips below the row */
.aidevis-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0;
}

.aidevis-file-list:not(:empty) {
    margin-top: 6px;
}

.aidevis-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    font-size: 11px;
}

.aidevis-file-chip .file-remove {
    cursor: pointer;
    opacity: 0.7;
    font-weight: bold;
}

.aidevis-file-chip .file-remove:hover {
    opacity: 1;
}

/* Error / Loading */
.aidevis-error {
    margin-top: 6px;
    padding: 6px 10px;
    background: rgba(231,76,60,0.15);
    border: 1px solid rgba(231,76,60,0.3);
    border-radius: 6px;
    font-size: 12px;
    color: #fdd;
}

.aidevis-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 13px;
    opacity: 0.9;
}

.aidevis-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: aidevis-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* Hide labels */
.aidevis-form label,
.aidevis-field-client label {
    display: none;
}

@media (max-width: 768px) {
    .aidevis-row {
        flex-wrap: wrap;
    }
    .aidevis-textarea {
        min-width: 100%;
    }
    .aidevis-field-client {
        min-width: 150px;
        flex: 1;
    }
}
