/* === AI Progress Panel - Floating widget for AI verification tracking === */

#ai-progress-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-height: 450px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 10000;
    font-family: inherit;
    font-size: 13px;
    display: none;
    overflow: hidden;
    animation: aiPanelSlideUp 0.3s ease-out;
}

@keyframes aiPanelSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Header */
#ai-progress-panel .ai-panel-header {
    background: #5cbc9a;
    color: #fff;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

#ai-progress-panel .ai-panel-header .ai-panel-title {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#ai-progress-panel .ai-panel-header .ai-panel-title .ai-panel-count {
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 700;
}

#ai-progress-panel .ai-panel-header .ai-panel-actions {
    display: flex;
    gap: 8px;
}

#ai-progress-panel .ai-panel-header .ai-panel-actions button {
    background: none;
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    opacity: 0.8;
    line-height: 1;
}

#ai-progress-panel .ai-panel-header .ai-panel-actions button:hover {
    opacity: 1;
}

/* Filter tabs */
#ai-progress-panel .ai-panel-filters {
    display: flex;
    gap: 4px;
    padding: 6px 14px;
    background: #f5f5f5;
    border-bottom: 1px solid #e8e8e8;
}

#ai-progress-panel.collapsed .ai-panel-filters {
    display: none;
}

#ai-progress-panel .ai-filter-btn {
    background: #e0e0e0;
    border: none;
    color: #666;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

#ai-progress-panel .ai-filter-btn:hover {
    background: #d0d0d0;
}

#ai-progress-panel .ai-filter-btn.active {
    background: #5cbc9a;
    color: #fff;
}

/* Job list */
#ai-progress-panel .ai-panel-body {
    max-height: 340px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

#ai-progress-panel.collapsed .ai-panel-body {
    max-height: 0;
    overflow: hidden;
}

#ai-progress-panel .ai-panel-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Individual job row */
#ai-progress-panel .ai-job-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    gap: 10px;
    transition: background 0.15s;
}

#ai-progress-panel .ai-job-row:last-child {
    border-bottom: none;
}

#ai-progress-panel .ai-job-row:hover {
    background: #f8f9fa;
}

/* Avatar */
#ai-progress-panel .ai-job-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #5cbc9a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

#ai-progress-panel .ai-job-avatar:hover {
    background: #4aa383;
    transform: scale(1.1);
    text-decoration: none;
    color: #fff;
}

/* Type badge */
.ai-type-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-right: 3px;
}

.ai-type-badge.conformite {
    background: #5cb85c;
    color: #fff;
}

.ai-type-badge.ajout {
    background: #5bc0de;
    color: #fff;
}

/* Status icon */
#ai-progress-panel .ai-job-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

#ai-progress-panel .ai-job-icon.pending {
    color: #f0ad4e;
}

#ai-progress-panel .ai-job-icon.processing {
    color: #5bc0de;
}

#ai-progress-panel .ai-job-icon.success {
    color: #5cb85c;
}

#ai-progress-panel .ai-job-icon.error {
    color: #d9534f;
}

#ai-progress-panel .ai-job-icon.rejected {
    color: #95a5a6;
}

/* Job info */
#ai-progress-panel .ai-job-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

#ai-progress-panel .ai-job-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
    font-size: 12px;
}

#ai-progress-panel .ai-job-contact {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress bar */
.ai-job-progress-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.ai-progress-label {
    font-size: 9px;
    color: #999;
    white-space: nowrap;
    flex-shrink: 0;
}

.ai-job-progress {
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    flex: 1;
}

.ai-progress-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 1s ease-out;
}

.ai-progress-bar.progress-bar-warning {
    background: linear-gradient(90deg, #f0ad4e, #f5c07a);
}

.ai-progress-bar.progress-bar-info {
    background: linear-gradient(90deg, #5bc0de, #7dd3e8);
}

#ai-progress-panel .ai-job-status {
    font-size: 11px;
    color: #777;
    white-space: nowrap;
}

#ai-progress-panel .ai-job-status.pending { color: #f0ad4e; }
#ai-progress-panel .ai-job-status.processing { color: #5bc0de; }
#ai-progress-panel .ai-job-status.success { color: #5cb85c; }
#ai-progress-panel .ai-job-status.error {
    color: #d9534f;
    cursor: help;
    border-bottom: 1px dotted #d9534f;
}
#ai-progress-panel .ai-job-status.rejected { color: #95a5a6; }

/* Action button */
#ai-progress-panel .ai-job-action {
    flex-shrink: 0;
}

#ai-progress-panel .ai-job-action a {
    color: #5cbc9a;
    font-size: 14px;
    text-decoration: none;
    opacity: 0.7;
    padding: 4px;
}

#ai-progress-panel .ai-job-action a:hover {
    opacity: 1;
}

/* Dismiss button */
#ai-progress-panel .ai-job-dismiss {
    color: #999 !important;
    font-size: 11px !important;
    margin-left: 4px;
    opacity: 0.5;
    vertical-align: middle;
}

#ai-progress-panel .ai-job-dismiss:hover {
    color: #d9534f !important;
    opacity: 1;
}

/* Confirm classification button */
#ai-progress-panel .ai-job-action .btn-confirm-ai {
    background: #f0ad4e;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 3px;
    opacity: 1;
    transition: background 0.2s;
    white-space: nowrap;
}

#ai-progress-panel .ai-job-action .btn-confirm-ai:hover {
    background: #ec971f;
    opacity: 1;
}

#ai-progress-panel .ai-job-action .btn-confirm-ai i {
    margin-right: 2px;
}

/* Spinner animation */
#ai-progress-panel .ai-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: aiSpin 0.8s linear infinite;
}

@keyframes aiSpin {
    to { transform: rotate(360deg); }
}

/* Group header */
#ai-progress-panel .ai-job-group-header {
    cursor: pointer;
    background: #fafafa;
}

#ai-progress-panel .ai-job-group-header:hover {
    background: #f0f4f2;
}

#ai-progress-panel .ai-job-group-header.expanded {
    border-bottom-color: #5cbc9a;
}

.ai-group-count {
    display: inline-block;
    background: #5cbc9a;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
}
.ai-group-count.ai-count-success { background: #5cbc9a; }
.ai-group-count.ai-count-pending { background: #f0ad4e; }
.ai-group-count.ai-count-error { background: #e74c3c; }
.ai-group-count.ai-count-rejected { background: #95a5a6; }

.ai-group-toggle {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: #999;
    font-size: 11px;
    transition: transform 0.2s;
}

.ai-job-group-header.expanded .ai-group-toggle i {
    transform: rotate(90deg);
}

/* Group children (collapsed by default) */
.ai-group-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.ai-group-children.expanded {
    max-height: 500px;
}

#ai-progress-panel .ai-job-child {
    padding: 6px 14px 6px 44px;
    font-size: 11px;
    border-bottom: 1px solid #f5f5f5;
    background: #fdfdfd;
}

#ai-progress-panel .ai-job-child:last-child {
    border-bottom: 1px solid #e8e8e8;
}

#ai-progress-panel .ai-job-child .ai-job-icon {
    width: 16px;
    height: 16px;
    font-size: 11px;
}

#ai-progress-panel .ai-job-child .ai-spinner {
    width: 10px;
    height: 10px;
}

#ai-progress-panel .ai-job-child .ai-job-name {
    font-size: 11px;
}

#ai-progress-panel .ai-job-child .ai-job-status {
    font-size: 10px;
}

/* Visual separation between pending/awaiting and done sections */
#ai-progress-panel .ai-child-separator {
    height: 0;
    border-top: 1px dashed #d5d5d5;
    margin: 0 14px 0 44px;
}

/* Dim confirmed/rejected/done child rows */
#ai-progress-panel .ai-job-child.ai-child-done {
    opacity: 0.45;
    background: #f9f9f9;
}
#ai-progress-panel .ai-job-child.ai-child-done:hover {
    opacity: 0.7;
}

/* Slide-in animation for new jobs */
#ai-progress-panel .ai-job-row.ai-job-temp {
    transition: all 0.4s ease-out;
}

/* === Confirmation Modal === */
#modal-ai-confirm-classification .modal-header {
    background: #5cbc9a;
    color: #fff;
}

#modal-ai-confirm-classification .modal-header .close {
    color: #fff;
    opacity: 0.8;
}

#modal-ai-confirm-classification .modal-header .close:hover {
    opacity: 1;
}

.ai-confirm-info {
    margin-bottom: 15px;
}

.ai-confirm-info p {
    margin-bottom: 5px;
}

/* Multi-doc sections in confirmation modal */
.ai-confirm-doc-section {
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fdfdfd;
}

.ai-confirm-doc-section:last-child {
    margin-bottom: 0;
}

.ai-confirm-doc-header {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

.ai-confirm-doc-header i {
    color: #d9534f;
    margin-right: 4px;
}

.ai-confirm-doc-section .ai-confirm-table {
    margin-bottom: 0;
    font-size: 12px;
}

.ai-confirm-table .ai-confirm-type-select {
    min-width: 200px;
}

/* Responsive */
@media (max-width: 480px) {
    #ai-progress-panel {
        width: calc(100% - 20px);
        right: 10px;
        bottom: 10px;
    }
}
