/* Styles for Side Panel */
.create-trigger-panel {
    position: fixed;
    top: 32px; /* Adjusted for WordPress admin bar */
    right: -100%;
    width: 450px; /* Increased from 350px */
    height: calc(100vh - 32px); /* Adjusted for WordPress admin bar */
    background: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease-in-out, right 0.3s ease-in-out;
    z-index: 99999;
    border-left: 3px solid #0073aa;
    border-radius: 8px 0 0 8px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.create-trigger-panel.open {
    right: 0;
    transform: translateX(0);
}

.close-button {
    position: absolute;
    top: 18px; /* Adjusted to align with heading */
    right: 20px;
    background: none;
    border: none;
    font-size: 20px; /* Slightly reduced size */
    cursor: pointer;
    padding: 5px;
    z-index: 3;
    line-height: 1;
    display: flex;
    align-items: center;
    color: #0073aa;
    height: 24px;
}

.close-button:hover {
    color: #005a87;
}

.panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.panel-content h2 {
    margin-top: 0;
    font-size: 24px;
    color: #0073aa;
    line-height: 24px;
    padding: 20px;
    padding-right: 50px; /* Adjusted for close button */
    background: #fff;
    position: relative;
    z-index: 2;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
}

.panel-content form {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Create a scrollable container for form fields */
.form-fields-container {
    flex: 1;
    padding: 5px 20px 80px; /* Adjusted top padding to reduce space */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Wrapper for the save button */
.save-button-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #ddd;
    z-index: 2;
}

.panel-content form .field-mapping-panel {
    margin-bottom: 20px;
}

.panel-content form button[type="submit"] {
    margin: 0;
    align-self: flex-start;
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    text-decoration: none;
    text-shadow: none;
    padding: 0 10px;
    min-height: 30px;
    line-height: 2.15384615;
    border-width: 1px;
    border-style: solid;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.panel-content form button[type="submit"]:disabled {
    background: #ccc !important;
    border-color: #ccc !important;
    color: #666 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.panel-content form button[type="submit"]:hover {
    background: #135e96;
    border-color: #135e96;
    color: #fff;
}

.panel-content form label {
    margin-top: 10px;
    font-weight: bold;
}

.required {
    color: #dc3545;
    margin-left: 3px;
}

.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    display: block;
    text-align: left;
    width: 100%;
}

.error-input {
    border-color: #dc3545 !important;
}

.form-fields-container label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
}

.form-fields-container input[type="text"],
.form-fields-container select,
.ts-control {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    height: 40px;
    background-color: #F0F9FF;
}

/* TomSelect specific styles to match the input field */
.ts-wrapper.single .ts-control {
    height: 40px;
    background-color: #F0F9FF;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
}

.ts-wrapper.single .ts-control input {
    height: 28px;
    cursor: default;
    opacity: 0;
    position: absolute;
}

.ts-wrapper.single.input-active .ts-control input {
    opacity: 0;
}

.ts-control {
    cursor: pointer !important;
}

.ts-dropdown {
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-top: 4px;
}

.ts-dropdown .option {
    padding: 8px;
}

/* Styles for Toggle Switch */
.toggle-switch {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Hide default checkbox */
.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-label {
    position: relative;
    width: 36px;
    height: 18px;
    background-color: #ccc;
    border-radius: 20px;
    transition: background-color 0.25s ease-in-out;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
}

.toggle-label:before {
    content: '';
    position: absolute;
    left: 3px;
    width: 14px;
    height: 14px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease-in-out;
}

/* Checked state */
.toggle-switch input[type="checkbox"]:checked+.toggle-label {
    background-color: #0073aa;
}

.toggle-switch input[type="checkbox"]:checked+.toggle-label:before {
    transform: translateX(18px);
}

/* Ensure status text is properly positioned */
.status-label {
    font-size: 10px;
    font-weight: bold;
    color: #333;
}

/* Styles for Field Mapping Items */
.field-mapping-item {
    padding: 3px;
}

/* Styles for Variable Mapping Items */
.variable-mapping-item {
    padding: 5px;
}

/* Label styles for both field and variable mapping */
.field-mapping-item label,
.variable-mapping-item label {
    font-weight: bold;
    color: #333;
    display: flex;
    margin-bottom: 5px;
}

/* Input styles for both field and variable mapping */
.field-mapping-item input,
.variable-mapping-item input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

/* Error message styles */
.error {
    color: red;
    font-size: 12px;
    margin-top: 5px;
}

/* Responsive adjustments */
@media screen and (max-width: 782px) {
    .create-trigger-panel {
        top: 46px; /* Adjusted for mobile WordPress admin bar */
        width: 100%;
        height: calc(100vh - 46px);
        right: -100%;
        border-radius: 0;
        border-left: none;
        padding: 0;
    }

    .create-trigger-panel.open {
        right: 0;
    }

    .panel-content {
        padding-top: 20px;
    }

    .panel-content h2 {
        font-size: 20px;
        margin-bottom: 15px;
        padding-right: 40px; /* Space for close button */
    }

    .form-fields-container {
        padding: 10px 0;
        gap: 15px;
    }

    .form-fields-container input[type="text"],
    .form-fields-container select {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        height: auto;
        margin-bottom: 10px;
    }

    .save-button-wrapper {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 15px;
        background: #fff;
        border-top: 1px solid #ddd;
        margin: 0 -15px;
    }

    .panel-content form button[type="submit"] {
        padding: 12px 20px;
        font-size: 16px;
        height: auto;
        margin: 0;
    }
}

@media screen and (max-width: 600px) {
    .create-trigger-panel {
        padding: 12px;
    }

    .panel-content h2 {
        font-size: 18px;
    }

    .form-fields-container input[type="text"],
    .form-fields-container select {
        padding: 10px;
        font-size: 14px;
    }

    .save-button-wrapper {
        padding: 12px;
        margin: 0 -12px;
    }

    .panel-content form button[type="submit"] {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* Fix for very small screens */
@media screen and (max-width: 375px) {
    .create-trigger-panel {
        padding: 10px;
    }

    .form-fields-container {
        padding: 5px 0;
        gap: 10px;
    }

    .save-button-wrapper {
        padding: 10px;
        margin: 0 -10px;
    }
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.loading-state::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Loading text style */
.loading-text {
    color: #666;
    font-style: italic;
    margin: 10px 0;
    text-align: center;
}

.ts-wrapper.multi .ts-control {
    min-height: 40px;
    height: auto;
    padding: 4px;
    background-color: #F0F9FF;
}

.ts-wrapper.multi .ts-control > div {
    background: #fff;
    border: 1px solid #ccc;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 3px;
}

.ts-wrapper.plugin-remove_button .item {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
}

.ts-wrapper.multi .ts-control > div.item {
    margin: 2px;
    padding: 4px 8px;
    background: #fff;
    color: #333;
    border-radius: 3px;
}

.ts-wrapper.plugin-remove_button .item .remove {
    padding-left: 8px;
    color: #999;
    text-decoration: none;
    cursor: pointer;
}

.ts-dropdown .option {
    padding: 8px;
    cursor: pointer;
}

.ts-dropdown .active {
    background-color: #0073aa;
    color: #fff;
}

/* Additional styles moved from inline styles */
.panel-content h2 {
    margin-top: 0;
    font-size: 24px;
    color: #0073aa;
}

/* Center align all table column contents */
.wp-list-table.widefat td,
.wp-list-table.widefat th {
    text-align: center;
    vertical-align: middle;
}

/* Checkbox column styling */
.wp-list-table .column-cb {
    width: 40px;
    padding: 8px 0;
}

.wp-list-table .check-column {
    padding: 8px 0;
    width: 40px;
}

.wp-list-table .check-column input[type="checkbox"] {
    margin: 0;
    vertical-align: middle;
    transform: scale(1.2);
}

/* Button styling for automation page */
#create-trigger-button {
    float: right;
    border-radius: 4px;
    padding: 4px 16px;
}

#bulk-delete-button {
    display: none;
    float: right;
    margin-right: 20px;
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
    border-radius: 4px;
    padding: 4px 16px;
}

.no-automations-found td {
    text-align: center;
    padding: 20px;
}

/* Hidden elements */
.hidden {
    display: none !important;
}

/* Automation header styling */
.automation-header {
    margin-bottom: 20px;
}

.clearfix {
    clear: both;
}

/* Ensure the toggle switch is centered */
.toggle-switch {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Center align the action buttons */
/* .wp-list-table.widefat td:last-child {
    display: flex;
    justify-content: center;
    gap: 10px;
} */