/**
 * Strona Szablony akcji – styl zgodny z Integracje i Hostinger Reach.
 */
.drone-flow-templates-wrap {
    --drone-flow-gap: 12px;
    --drone-flow-radius: 8px;
    --drone-flow-border: 1px solid #c3c4c7;
}

.drone-flow-templates-toolbar {
    margin-bottom: 16px;
}

.drone-flow-templates-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--drone-flow-gap);
}

.drone-flow-templates-filters select,
.drone-flow-templates-filters input[type="search"] {
    min-height: 36px;
    padding: 4px 8px;
    border-radius: var(--drone-flow-radius);
    border: var(--drone-flow-border);
}

.drone-flow-templates-filters input[type="search"] {
    min-width: 220px;
}

.drone-flow-templates-list .wp-list-table {
    border-radius: var(--drone-flow-radius);
    border: var(--drone-flow-border);
    table-layout: fixed;
    width: 100%;
}
.drone-flow-templates-list .wp-list-table th,
.drone-flow-templates-list .wp-list-table td {
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

.drone-flow-templates-list .column-name {
    width: 30%;
}

.drone-flow-templates-list .column-type {
    width: 15%;
}

.drone-flow-templates-list .column-date {
    width: 20%;
}

.drone-flow-templates-list .column-actions {
    width: 25%;
}

.drone-flow-templates-list .column-actions .button + .button {
    margin-left: 4px;
}

.drone-flow-template-form-card {
    padding: 20px 24px;
    border: var(--drone-flow-border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.drone-flow-template-form-card h2 {
    margin-top: 0;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dcdcde;
}

.drone-flow-template-form-card .form-table th {
    padding-left: 0;
}

.drone-flow-template-form-card .submit {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #dcdcde;
}

.drone-flow-template-form-card .button + .button {
    margin-left: 8px;
}

@media screen and (max-width: 782px) {
    .drone-flow-templates-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .drone-flow-templates-filters input[type="search"] {
        min-width: 0;
    }

    .drone-flow-templates-list .wp-list-table .column-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
}

/* Instrukcja na stronie edycji szablonu */
.drone-flow-template-instruction {
    background: #f0f6fc;
    border-left: 4px solid #2271b1;
}
.drone-flow-template-instruction ul {
    margin: 0.5em 0 0 1em;
    padding: 0;
}
.drone-flow-template-instruction li {
    margin: 0.25em 0;
}
.drone-flow-template-instruction p {
    margin: 0 0 0.5em;
}
.drone-flow-template-instruction p:last-child {
    margin-bottom: 0;
}

/* ========== Ekran wyboru typu szablonu (Dodaj szablon) — prostokąty: ikona z lewej, treść z prawej; logika kolorów jak Statystyki czatu (karta bielszy gradient, ikona nieco żywsza) ========== */
.drone-flow-templates-wrap .drone-flow-template-type-section.drone-flow-chat-section {
    background: #fff;
    border-radius: var(--df-conn-radius, 8px);
    box-shadow: 0 1px 3px 0 rgba(43, 108, 176, 0.08);
    padding: 0;
    border: 1px solid var(--df-conn-border, #e2e8f0);
    margin-bottom: var(--df-conn-space-card, 30px);
}
.drone-flow-templates-wrap .drone-flow-template-type-section .drone-flow-chat-section-title {
    margin: 0;
    padding: var(--df-conn-space-block, 20px) var(--df-conn-space-card, 30px);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: #2d3748;
    border-bottom: 1px solid var(--df-conn-border, #e2e8f0);
    background: #fff;
}
.drone-flow-templates-wrap .drone-flow-template-type-section .drone-flow-chat-section-body {
    padding: var(--df-conn-space-block, 20px) var(--df-conn-space-card, 30px);
    box-sizing: border-box;
}
.drone-flow-templates-wrap .drone-flow-template-type-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin: 0;
}
.drone-flow-templates-wrap .drone-flow-template-type-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 20px;
    padding: 0;
    min-height: 120px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.drone-flow-templates-wrap .drone-flow-template-type-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.drone-flow-templates-wrap .drone-flow-template-type-card:focus {
    outline: 2px solid #2b6cb0;
    outline-offset: 2px;
}
.drone-flow-templates-wrap .drone-flow-template-type-card:focus:not(:focus-visible) {
    outline: none;
}
.drone-flow-templates-wrap .drone-flow-template-type-card:focus-visible {
    outline: 2px solid #2b6cb0;
    outline-offset: 2px;
}
.drone-flow-templates-wrap .drone-flow-template-type-card-icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    margin: 20px 0 20px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.drone-flow-templates-wrap .drone-flow-template-type-card-icon .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
}
.drone-flow-templates-wrap .drone-flow-template-type-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 12px;
    padding: 20px 20px 20px 0;
}
.drone-flow-templates-wrap .drone-flow-template-type-card-heading {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.drone-flow-templates-wrap .drone-flow-template-type-card-title {
    font-size: 17px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.35;
}
.drone-flow-templates-wrap .drone-flow-template-type-card-subtitle {
    margin: 0;
    font-size: 13px;
    color: #50575e;
    line-height: 1.5;
}
.drone-flow-templates-wrap .drone-flow-template-type-card-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #2b6cb0;
    transition: color 0.15s ease;
}
.drone-flow-templates-wrap .drone-flow-template-type-card-hint .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}
.drone-flow-templates-wrap .drone-flow-template-type-card:hover .drone-flow-template-type-card-hint {
    color: #3182ce;
}
.drone-flow-templates-wrap .drone-flow-template-type-card:hover .drone-flow-template-type-card-hint .dashicons {
    transform: translateX(3px);
}

/* Domyślny (typy z filtra) — jak Statystyki: karta jaśniejszy gradient, ikona nieco żywsza w tym samym odcieniu */
.drone-flow-templates-wrap .drone-flow-template-type-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid rgba(100, 116, 139, 0.12);
}
.drone-flow-templates-wrap .drone-flow-template-type-card .drone-flow-template-type-card-icon {
    background: rgba(100, 116, 139, 0.18);
    color: #475569;
}

/* Jak Statystyki czatu: najpierw karta w bielszym/jaśniejszym odcieniu, potem ikona nieco żywsza (ten sam ton) */
.drone-flow-templates-wrap .drone-flow-template-type-card--webhook {
    background: linear-gradient(135deg, #f5f4ff 0%, #e8e7fc 100%);
    border: 1px solid rgba(99, 102, 241, 0.12);
}
.drone-flow-templates-wrap .drone-flow-template-type-card--webhook .drone-flow-template-type-card-icon {
    background: rgba(99, 102, 241, 0.2);
    color: #6366f1;
}
.drone-flow-templates-wrap .drone-flow-template-type-card--email {
    background: linear-gradient(135deg, #eff6ff 0%, #e0eefe 100%);
    border: 1px solid rgba(37, 99, 235, 0.12);
}
.drone-flow-templates-wrap .drone-flow-template-type-card--email .drone-flow-template-type-card-icon {
    background: rgba(37, 99, 235, 0.2);
    color: #2563eb;
}
.drone-flow-templates-wrap .drone-flow-template-type-card--sms {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid rgba(5, 150, 105, 0.12);
}
.drone-flow-templates-wrap .drone-flow-template-type-card--sms .drone-flow-template-type-card-icon {
    background: rgba(5, 150, 105, 0.22);
    color: #059669;
}
.drone-flow-templates-wrap .drone-flow-template-type-card--gmail {
    background: linear-gradient(135deg, #fef2f2 0%, #fce4e4 100%);
    border: 1px solid rgba(234, 67, 53, 0.12);
}
.drone-flow-templates-wrap .drone-flow-template-type-card--gmail .drone-flow-template-type-card-icon {
    background: rgba(234, 67, 53, 0.2);
    color: #ea4335;
}
.drone-flow-templates-wrap .drone-flow-template-type-card--slack {
    background: linear-gradient(135deg, #faf5fa 0%, #f3e8f3 100%);
    border: 1px solid rgba(74, 21, 75, 0.12);
}
.drone-flow-templates-wrap .drone-flow-template-type-card--slack .drone-flow-template-type-card-icon {
    background: rgba(74, 21, 75, 0.22);
    color: #4a154b;
}
.drone-flow-templates-wrap .drone-flow-template-type-card--sheets {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid rgba(15, 157, 88, 0.12);
}
.drone-flow-templates-wrap .drone-flow-template-type-card--sheets .drone-flow-template-type-card-icon {
    background: rgba(15, 157, 88, 0.22);
    color: #0f9d58;
}
.drone-flow-templates-wrap .drone-flow-template-type-card--docs {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid rgba(66, 133, 244, 0.12);
}
.drone-flow-templates-wrap .drone-flow-template-type-card--docs .drone-flow-template-type-card-icon {
    background: rgba(66, 133, 244, 0.2);
    color: #4285f4;
}

@media screen and (max-width: 782px) {
    .drone-flow-templates-wrap .drone-flow-template-type-cards {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .drone-flow-templates-wrap .drone-flow-template-type-section .drone-flow-chat-section-body {
        padding: 16px 20px;
    }
    .drone-flow-templates-wrap .drone-flow-template-type-card-body {
        padding: 18px 18px 18px 0;
    }
    .drone-flow-templates-wrap .drone-flow-template-type-card-icon {
        width: 52px;
        height: 52px;
        margin: 18px 0 18px 18px;
    }
    .drone-flow-templates-wrap .drone-flow-template-type-card-icon .dashicons {
        font-size: 26px;
        width: 26px;
        height: 26px;
    }
    .drone-flow-templates-wrap .drone-flow-template-type-card-title {
        font-size: 16px;
    }
    .drone-flow-templates-wrap .drone-flow-template-type-card-subtitle {
        font-size: 12px;
    }
}

/* Mapowanie Sheets: zmienne w dowolnej kolejności (chips) */
.drone-flow-map-keys-cell {
    min-width: 220px;
    max-width: 400px;
}
.drone-flow-map-keys-add-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.drone-flow-map-keys-add-row select.drone-flow-map-key-add {
    flex: 1;
    min-width: 0;
    max-width: 240px;
}
.drone-flow-map-keys-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.drone-flow-map-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 2px 8px;
    background: #f0f0f1;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
}
.drone-flow-map-chip .drone-flow-remove-chip {
    padding: 0 2px;
    margin: 0;
    min-width: 18px;
    height: 18px;
    line-height: 1;
    font-size: 16px;
    color: #50575e;
    background: none;
    border: none;
    border-radius: 2px;
    cursor: pointer;
}
.drone-flow-map-chip .drone-flow-remove-chip:hover {
    color: #b32d2e;
    background: #fcf0f1;
}

.drone-flow-map-chip-static {
    background: #e5e7eb;
    border-color: #9ca3af;
    font-style: italic;
}

.drone-flow-map-keys-add-row .drone-flow-map-static-add {
    margin-left: 4px;
}

/* ========== Audyt §1, §3: pełna szerokość na mobile, tabele ========== */
@media screen and (max-width: 900px) {
    body.drone-flow-action-templates-page #wpcontent,
    body.drone-flow-action-templates-page #wpbody-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box;
    }
    body.drone-flow-action-templates-page .wrap.drone-flow-templates-wrap {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
        box-sizing: border-box;
    }
    body.drone-flow-action-templates-page .drone-flow-templates-wrap .drone-flow-templates-toolbar,
    body.drone-flow-action-templates-page .drone-flow-templates-wrap .drone-flow-templates-list,
    body.drone-flow-action-templates-page .drone-flow-templates-wrap .wp-list-table {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    body.drone-flow-action-templates-page .drone-flow-templates-wrap .wp-list-table th,
    body.drone-flow-action-templates-page .drone-flow-templates-wrap .wp-list-table td {
        overflow-wrap: break-word;
        word-break: break-word;
    }
}

/* Edytor treści szablonu E-mail (wp_editor) — pełny TinyMCE + zakładka Text + media */
.drone-flow-email-template-editor-wrap {
    max-width: 100%;
}

.drone-flow-email-template-editor-wrap .wp-editor-wrap {
    max-width: 100%;
}

.drone-flow-email-template-editor-wrap .mce-tinymce,
.drone-flow-email-template-editor-wrap .wp-editor-container {
    box-sizing: border-box;
}
