/* =============================================================
 * COMUNIK WORKFLOW TEMPLATES — BIBLIOTHEQUE
 * =============================================================
 *
 * Grille de cards "starter packs" + modal preview + filtres.
 *
 */

/* Toolbar (boutons Bibliothèque / Mes workflows + filtres) */
.sb-area-workflows .sb-wf-tabs {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}
.sb-area-workflows .sb-wf-tab {
    padding: 6px 14px;
    border-radius: 6px;
    background: #f1f3f6;
    color: #555;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all .15s ease;
}
.sb-area-workflows .sb-wf-tab:hover {
    background: #e6e9ee;
}
.sb-area-workflows .sb-wf-tab.sb-active {
    background: #2c79ff;
    color: #fff;
    border-color: #2c79ff;
}

/* Conteneur biblio */
.sb-wf-templates-wrap {
    padding: 8px 0 24px;
}

.sb-wf-templates-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 8px 0 18px;
    padding: 0 4px;
}
.sb-wf-templates-filters .sb-wf-filter {
    padding: 4px 12px;
    border-radius: 16px;
    background: #f1f3f6;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .15s ease;
}
.sb-wf-templates-filters .sb-wf-filter:hover {
    background: #e6e9ee;
}
.sb-wf-templates-filters .sb-wf-filter.sb-active {
    background: #2c79ff;
    color: #fff;
    border-color: #2c79ff;
}

/* Grille */
.sb-wf-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 4px;
}

.sb-wf-tpl-card {
    background: #fff;
    border: 1px solid #e6e9ee;
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    transition: all .18s ease;
    position: relative;
    min-height: 180px;
}
.sb-wf-tpl-card:hover {
    border-color: #2c79ff;
    box-shadow: 0 6px 18px rgba(44, 121, 255, .12);
    transform: translateY(-2px);
}

.sb-wf-tpl-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4a90ff 0%, #2c79ff 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.sb-wf-tpl-icon i { color: #fff; }

.sb-wf-tpl-name {
    font-size: 15px;
    font-weight: 600;
    color: #2a2a2a;
    line-height: 1.3;
}

.sb-wf-tpl-desc {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.45;
    flex-grow: 1;
}

.sb-wf-tpl-cat {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 11px;
    background: #f1f3f6;
    color: #555;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.sb-wf-tpl-reqs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.sb-wf-tpl-req {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e8f5e9;
    color: #2e7d32;
    font-weight: 500;
}
.sb-wf-tpl-req.sb-missing {
    background: #fff3cd;
    color: #856404;
}
.sb-wf-tpl-req.sb-missing::before {
    content: '⚠ ';
}

/* Empty state */
.sb-wf-tpl-empty {
    text-align: center;
    color: #888;
    padding: 60px 20px;
}

/* Modal preview */
.sb-wf-tpl-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 25, 35, 0.55);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.sb-wf-tpl-modal-overlay.sb-active {
    display: flex;
}
.sb-wf-tpl-modal {
    background: #fff;
    border-radius: 12px;
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
}
.sb-wf-tpl-modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid #eef0f3;
    display: flex;
    align-items: center;
    gap: 14px;
}
.sb-wf-tpl-modal-header .sb-wf-tpl-icon {
    width: 44px;
    height: 44px;
}
.sb-wf-tpl-modal-title {
    flex-grow: 1;
}
.sb-wf-tpl-modal-title h3 {
    margin: 0;
    font-size: 18px;
    color: #1a1a1a;
}
.sb-wf-tpl-modal-title small {
    color: #888;
    font-size: 12px;
}
.sb-wf-tpl-modal-close {
    cursor: pointer;
    color: #999;
    font-size: 22px;
    padding: 4px 8px;
    border-radius: 6px;
}
.sb-wf-tpl-modal-close:hover {
    background: #f1f3f6;
    color: #333;
}
.sb-wf-tpl-modal-body {
    padding: 18px 22px;
    overflow-y: auto;
}
.sb-wf-tpl-modal-section {
    margin-bottom: 16px;
}
.sb-wf-tpl-modal-section h4 {
    font-size: 13px;
    text-transform: uppercase;
    color: #6b7280;
    margin: 0 0 6px;
    letter-spacing: .04em;
}
.sb-wf-tpl-modal-section p,
.sb-wf-tpl-modal-section li {
    color: #2a2a2a;
    font-size: 13px;
    line-height: 1.5;
    margin: 4px 0;
}
.sb-wf-tpl-modal-section ul {
    margin: 4px 0;
    padding-left: 18px;
}
.sb-wf-tpl-modal-section .sb-wf-tpl-req {
    margin-right: 4px;
}
.sb-wf-tpl-json {
    background: #f6f8fa;
    border: 1px solid #eef0f3;
    border-radius: 6px;
    padding: 10px 12px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 11.5px;
    color: #2a2a2a;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
}
.sb-wf-tpl-modal-footer {
    padding: 14px 22px;
    border-top: 1px solid #eef0f3;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.sb-wf-tpl-modal-footer .sb-btn {
    padding: 8px 16px;
}
.sb-wf-tpl-install-btn {
    background: #27ae60 !important;
    color: #fff !important;
}
.sb-wf-tpl-install-btn:hover {
    background: #219a54 !important;
}

/* Toast */
.sb-wf-tpl-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #2e7d32;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0,0,0,.18);
    z-index: 99999;
    font-size: 13.5px;
    opacity: 0;
    transform: translateY(8px);
    transition: all .2s ease;
}
.sb-wf-tpl-toast.sb-active {
    opacity: 1;
    transform: translateY(0);
}
.sb-wf-tpl-toast.sb-error {
    background: #c0392b;
}

/* Dark mode */
body.sb-dark .sb-wf-tpl-card,
body.sb-theme-dark .sb-wf-tpl-card,
.sb-dark .sb-wf-tpl-card {
    background: #232733;
    border-color: #333947;
}
body.sb-dark .sb-wf-tpl-card:hover,
body.sb-theme-dark .sb-wf-tpl-card:hover {
    border-color: #4a90ff;
}
body.sb-dark .sb-wf-tpl-name { color: #f5f7fa; }
body.sb-dark .sb-wf-tpl-desc { color: #aab2c0; }
body.sb-dark .sb-wf-tpl-cat {
    background: #2e3340;
    color: #c8cdd6;
}
body.sb-dark .sb-area-workflows .sb-wf-tab {
    background: #2e3340;
    color: #c8cdd6;
}
body.sb-dark .sb-area-workflows .sb-wf-tab.sb-active {
    background: #2c79ff;
    color: #fff;
}
body.sb-dark .sb-wf-templates-filters .sb-wf-filter {
    background: #2e3340;
    color: #c8cdd6;
}
body.sb-dark .sb-wf-templates-filters .sb-wf-filter.sb-active {
    background: #2c79ff;
    color: #fff;
}
body.sb-dark .sb-wf-tpl-modal {
    background: #1d2230;
    color: #e9ecf1;
}
body.sb-dark .sb-wf-tpl-modal-header,
body.sb-dark .sb-wf-tpl-modal-footer {
    border-color: #2e3340;
}
body.sb-dark .sb-wf-tpl-modal-title h3 { color: #f5f7fa; }
body.sb-dark .sb-wf-tpl-modal-section h4 { color: #99a2b2; }
body.sb-dark .sb-wf-tpl-modal-section p,
body.sb-dark .sb-wf-tpl-modal-section li { color: #d4d9e2; }
body.sb-dark .sb-wf-tpl-json {
    background: #161a24;
    border-color: #2e3340;
    color: #d4d9e2;
}
body.sb-dark .sb-wf-tpl-req {
    background: #1f3a25;
    color: #6cd29a;
}
body.sb-dark .sb-wf-tpl-req.sb-missing {
    background: #3d3320;
    color: #f0c969;
}

/* Responsive */
@media (max-width: 600px) {
    .sb-wf-templates-grid {
        grid-template-columns: 1fr;
    }
    .sb-wf-tpl-modal {
        max-height: 95vh;
    }
}
