/**
 * Styles pour la page des règles conditionnelles
 */

/* Page liste des règles */
.pc-rules-page .pc-rules-intro {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-left: 4px solid #2271b1;
    padding: 12px 16px;
    margin: 20px 0;
}

.pc-rules-page .pc-rules-empty {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border: 1px solid #c3c4c7;
    margin: 20px 0;
}

.pc-rules-page .pc-rules-empty-icon {
    font-size: 48px;
    color: #c3c4c7;
    margin-bottom: 20px;
}

.pc-rules-page .pc-rules-empty-icon .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
}

.pc-rules-page .pc-rules-empty h2 {
    margin: 0 0 10px;
    color: #1d2327;
}

.pc-rules-page .pc-rules-empty p {
    color: #646970;
    margin-bottom: 20px;
}

/* Table des règles */
.pc-rules-table .column-order {
    width: 30px;
}

.pc-rules-table .column-scope {
    width: 120px;
}

.pc-rules-table .column-conditions,
.pc-rules-table .column-actions {
    width: 180px;
}

.pc-rules-table .column-status {
    width: 70px;
}

.pc-rules-table .pc-drag-handle {
    cursor: move;
    color: #c3c4c7;
}

.pc-rules-table .pc-drag-handle:hover {
    color: #2271b1;
}

.pc-rules-table tr.ui-sortable-helper {
    background: #fff;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.pc-rules-table tr.ui-sortable-placeholder {
    visibility: visible !important;
    background: #f0f6fc;
}

/* Toggle switch */
.pc-toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.pc-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pc-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #c3c4c7;
    transition: 0.2s;
    border-radius: 22px;
}

.pc-toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
}

.pc-toggle-switch input:checked + .pc-toggle-slider {
    background-color: #2271b1;
}

.pc-toggle-switch input:checked + .pc-toggle-slider:before {
    transform: translateX(18px);
}

/* Summary badges */
.pc-summary-badge {
    display: inline-block;
    background: #f0f0f1;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
}

.pc-summary-badge small {
    color: #646970;
}

.pc-no-data {
    color: #c3c4c7;
}

/* =========================
   Éditeur de règle
   ========================= */

.pc-rule-editor .pc-section {
    background: #fff;
    border: 1px solid #c3c4c7;
    margin-bottom: 20px;
    padding: 0;
}

.pc-rule-editor .pc-section > h2 {
    margin: 0;
    padding: 12px 15px;
    border-bottom: 1px solid #c3c4c7;
    background: #f6f7f7;
    font-size: 14px;
}

.pc-rule-editor .pc-section > p.description {
    margin: 0;
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f1;
    background: #fafafa;
}

.pc-rule-editor .pc-section .form-table {
    margin: 0;
}

.pc-rule-editor .pc-section .form-table th {
    padding: 15px;
    width: 200px;
}

.pc-rule-editor .pc-section .form-table td {
    padding: 15px;
}

/* Scope options */
.pc-scope-options {
    padding: 15px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.pc-scope-option {
    flex: 1;
    min-width: 200px;
    padding: 15px;
    border: 2px solid #c3c4c7;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.pc-scope-option:hover {
    border-color: #2271b1;
}

.pc-scope-option input[type="radio"] {
    margin-right: 10px;
}

.pc-scope-option input[type="radio"]:checked ~ .pc-scope-label strong {
    color: #2271b1;
}

.pc-scope-option:has(input:checked) {
    border-color: #2271b1;
    background: #f0f6fc;
}

.pc-scope-label {
    display: block;
}

.pc-scope-label strong {
    display: block;
    margin-bottom: 4px;
}

.pc-scope-label span {
    color: #646970;
    font-size: 12px;
}

.pc-scope-selector {
    padding: 0 15px 15px;
}

.pc-scope-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.pc-scope-selector .select2-container {
    width: 100% !important;
}

/* Conditions builder */
.pc-conditions-builder {
    padding: 15px;
}

.pc-conditions-main-logic {
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f6f7f7;
    border-radius: 4px;
}

.pc-conditions-main-logic label {
    margin-right: 10px;
    font-weight: 600;
}

.pc-condition-groups {
    margin-bottom: 15px;
}

.pc-condition-group {
    background: #f9f9f9;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    margin-bottom: 15px;
    padding: 0;
}

.pc-condition-group + .pc-condition-group:before {
    content: '';
    display: block;
    margin: -10px auto 10px;
    padding: 4px 12px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #646970;
    text-align: center;
    width: fit-content;
    position: relative;
    top: -5px;
}

.pc-condition-group + .pc-condition-group[data-logic="AND"]:before {
    content: 'ET';
}

.pc-condition-group + .pc-condition-group[data-logic="OR"]:before {
    content: 'OU';
}

.pc-group-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 15px;
    background: #fff;
    border-bottom: 1px solid #dcdcde;
    border-radius: 4px 4px 0 0;
}

.pc-group-title {
    font-weight: 600;
    color: #1d2327;
}

.pc-group-logic {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pc-group-logic label {
    font-size: 12px;
    color: #646970;
}

.pc-remove-group {
    color: #b32d2e !important;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.pc-remove-group:hover {
    color: #a00 !important;
}

.pc-group-conditions {
    padding: 15px;
}

.pc-condition-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
}

.pc-condition-row:last-child {
    margin-bottom: 0;
}

.pc-condition-row select {
    flex: 1;
}

.pc-condition-row .pc-condition-attribute {
    flex: 2;
}

.pc-condition-row .pc-condition-value {
    flex: 2;
}

.pc-remove-condition {
    color: #b32d2e !important;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.pc-remove-condition:hover {
    color: #a00 !important;
}

.pc-add-condition {
    margin: 10px 15px 15px;
}

.pc-add-condition .dashicons,
#pc-add-group .dashicons,
#pc-add-action .dashicons {
    vertical-align: middle;
    margin-right: 4px;
}

/* Actions list */
.pc-actions-list {
    padding: 15px;
}

.pc-no-actions {
    padding: 30px;
    text-align: center;
    color: #646970;
    background: #f9f9f9;
    border: 1px dashed #c3c4c7;
    border-radius: 4px;
}

.pc-action-row {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    margin-bottom: 15px;
}

.pc-action-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    border-bottom: 1px solid #dcdcde;
    background: #f9f9f9;
    border-radius: 4px 4px 0 0;
}

.pc-action-header select {
    flex: 1;
    max-width: 300px;
}

.pc-remove-action {
    color: #b32d2e !important;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.pc-remove-action:hover {
    color: #a00 !important;
}

.pc-action-config {
    padding: 15px;
}

.pc-action-config:empty {
    display: none;
}

.pc-config-row {
    margin-bottom: 15px;
}

.pc-config-row:last-child {
    margin-bottom: 0;
}

.pc-config-row label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.pc-config-row .select2-container {
    width: 100% !important;
}

.pc-config-columns {
    display: inline-block;
    margin-left: 20px;
}

.pc-config-columns select {
    width: 60px;
}

.pc-action-config-price {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.pc-action-config-price .pc-config-row {
    margin-bottom: 0;
}

.pc-price-unit {
    margin-left: 5px;
    color: #646970;
}

#pc-add-action {
    margin: 0 15px 15px;
}

/* Sidebar postboxes */
.pc-rule-editor .postbox {
    margin-bottom: 20px;
}

.pc-postbox-publish .inside {
    padding: 0;
    margin: 0;
}

.pc-publish-status {
    padding: 15px;
    border-bottom: 1px solid #c3c4c7;
}

.pc-publish-actions {
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pc-publish-actions .spinner {
    float: none;
    margin: 0 10px 0 0;
}

.pc-publish-actions .deletion {
    color: #b32d2e;
}

.pc-publish-actions .deletion:hover {
    color: #a00;
}

.pc-postbox-help .inside {
    font-size: 13px;
}

.pc-postbox-help h4 {
    margin: 0 0 10px;
}

.pc-postbox-help ol {
    margin: 0 0 15px 20px;
    padding: 0;
}

.pc-postbox-help li {
    margin-bottom: 5px;
}

.pc-postbox-help p {
    margin: 0;
    color: #646970;
}

/* Required indicator */
.required {
    color: #d63638;
}

/* Select2 customization */
.select2-container--default .select2-selection--multiple {
    min-height: 36px;
    border-color: #8c8f94;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Responsive */
@media screen and (max-width: 782px) {
    .pc-scope-options {
        flex-direction: column;
    }
    
    .pc-scope-option {
        min-width: auto;
    }
    
    .pc-condition-row {
        flex-wrap: wrap;
    }
    
    .pc-condition-row select {
        flex: 1 1 100%;
    }
    
    .pc-group-header {
        flex-wrap: wrap;
    }
    
    .pc-group-logic {
        margin-left: 0;
        width: 100%;
        margin-top: 10px;
    }
}

/* Loading state */
.pc-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.pc-loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2271b1;
    border-radius: 50%;
    animation: pc-spin 0.8s linear infinite;
}

@keyframes pc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notices */
.pc-notice {
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 4px;
}

.pc-notice-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.pc-notice-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ===== BLOCS MULTIPLES ===== */

.pc-section-blocks {
    background: #f6f7f7;
    padding: 20px;
    border-radius: 8px;
}

.pc-blocks-container {
    margin-bottom: 20px;
}

.pc-block {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.pc-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #f0f0f1;
    border-bottom: 1px solid #c3c4c7;
    border-radius: 7px 7px 0 0;
}

.pc-block-drag-handle {
    cursor: move;
    color: #787c82;
}

.pc-block-name {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-weight: 500;
}

.pc-block-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #2271b1;
    padding: 5px;
}

.pc-block-toggle:hover {
    color: #135e96;
}

.pc-remove-block {
    color: #b32d2e;
}

.pc-remove-block:hover {
    color: #a00;
}

.pc-block-content {
    padding: 20px;
}

.pc-block-conditions,
.pc-block-actions {
    margin-bottom: 20px;
}

.pc-block-conditions h4,
.pc-block-actions h4 {
    margin: 0 0 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
    color: #1d2327;
    font-size: 14px;
}

.pc-block-condition-groups {
    margin-bottom: 15px;
}

.pc-block-actions-list {
    margin-bottom: 15px;
}

/* Action config pour modify_attribute_price */
.pc-action-config-attribute-price .pc-config-row {
    margin-bottom: 12px;
}

.pc-action-config-attribute-price label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    color: #1d2327;
}

.pc-action-config-attribute-price select,
.pc-action-config-attribute-price input {
    width: 100%;
    max-width: 300px;
}

.pc-action-config-attribute-price .description {
    font-size: 12px;
    color: #646970;
    font-style: italic;
    margin-top: 5px;
}

/* Boutons dans les blocs */
.pc-block .button-small {
    font-size: 12px;
    padding: 2px 8px;
    min-height: 26px;
}

#pc-add-block {
    margin-top: 10px;
}

#pc-add-block .dashicons {
    margin-right: 5px;
    vertical-align: middle;
}

/* Amélioration des conditions et actions dans les blocs */
.pc-block .pc-condition-group {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
}

.pc-block .pc-group-header {
    background: transparent;
    border-bottom: 1px solid #e0e0e0;
    padding: 0 0 10px;
    margin-bottom: 10px;
}

.pc-block .pc-condition-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.pc-block .pc-condition-row select {
    flex: 1;
    min-width: 120px;
}

.pc-block .pc-action-row {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
}

.pc-block .pc-action-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.pc-block .pc-action-header select {
    flex: 1;
    max-width: 250px;
}

.pc-block .pc-action-config {
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

/* Responsive blocs */
@media screen and (max-width: 782px) {
    .pc-block-header {
        flex-wrap: wrap;
    }
    
    .pc-block-name {
        order: 2;
        width: 100%;
        margin-top: 10px;
    }
    
    .pc-block .pc-condition-row select {
        flex: 1 1 100%;
    }
}
