/**
 * Scry Search for Meilisearch Admin Styles
 * 
 * @package scry_ms_Search
 * @since 1.0.0
 */

/* Task Drawer Toggle Button */
.scrywp-task-drawer-toggle-wrapper {
    position: fixed;
    bottom: 40px;
    right: 0;
    z-index: 100000;
}

@media screen and (max-width: 782px) {
    .scrywp-task-drawer-toggle-wrapper {
        bottom: 20px;
        right: 0;
    }
}

.scrywp-task-drawer-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px 12px 16px;
    background: #fff;
    color: #2271b1;
    border: 1px solid #2271b1;
    border-radius: 6px 0 0 6px;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scrywp-task-drawer-toggle:hover {
    background: #f0f0f1;
    border-color: #135e96;
    color: #135e96;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.scrywp-task-drawer-toggle:active {
    transform: translateY(0);
    box-shadow: -2px 0 6px rgba(0, 0, 0, 0.15);
}

.scrywp-task-drawer-toggle .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: #2271b1;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
}

/* Task Drawer Overlay */
.scrywp-task-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.scrywp-task-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Task Drawer */
.scrywp-task-drawer {
    position: fixed;
    top: 0;
    right: -500px;
    width: 500px;
    max-width: 90vw;
    height: 100vh;
    background: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 100002;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    overflow: hidden;
}

.scrywp-task-drawer.open {
    right: 0;
}

/* Drawer Header */
.scrywp-task-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #ccd0d4;
    background: #f6f7f7;
}

.scrywp-task-drawer-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.scrywp-task-drawer-title .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: #2271b1;
}

.scrywp-task-drawer-close {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #50575e;
    font-size: 20px;
    line-height: 1;
    transition: color 0.2s ease;
}

.scrywp-task-drawer-close:hover {
    color: #1d2327;
}

.scrywp-task-drawer-close .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Drawer Content */
.scrywp-task-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.scrywp-task-drawer-loading,
.scrywp-task-drawer-empty {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
}

.scrywp-task-drawer-error {
    text-align: center;
    padding: 40px 20px;
    color: #842029;
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 4px;
    margin: 20px;
}

.scrywp-task-drawer-error-message {
    margin-top: 10px;
    font-size: 13px;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
    color: #842029;
}


/* Tasks List */
.scrywp-task-drawer-list {
    margin-bottom: 20px;
}

.scrywp-task-item {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.scrywp-task-item:hover {
    border-color: #2271b1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.scrywp-task-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.scrywp-task-item-title {
    font-weight: 600;
    font-size: 14px;
    color: #1d2327;
    margin: 0;
}

.scrywp-task-item-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.scrywp-task-item-status.enqueued {
    background: #f0f0f1;
    color: #50575e;
}

.scrywp-task-item-status.processing {
    background: #fff3cd;
    color: #856404;
}

.scrywp-task-item-status.succeeded {
    background: #d1e7dd;
    color: #0f5132;
}

.scrywp-task-item-status.failed {
    background: #f8d7da;
    color: #842029;
}

.scrywp-task-item-body {
    font-size: 13px;
    color: #646970;
}

.scrywp-task-item-row {
    display: flex;
    margin-bottom: 8px;
    gap: 10px;
}

.scrywp-task-item-label {
    font-weight: 600;
    min-width: 100px;
}

.scrywp-task-item-value {
    flex: 1;
    word-break: break-word;
}

.scrywp-task-item-error {
    margin-top: 10px;
    padding: 10px;
    background: #f8d7da;
    border-left: 4px solid #842029;
    color: #842029;
    font-size: 12px;
}

.scrywp-task-item-error-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.scrywp-task-item-error-message {
    font-family: monospace;
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-word;
}

.scrywp-task-item-details {
    margin-top: 10px;
    padding: 10px;
    background: #f6f7f7;
    border-radius: 3px;
    font-size: 12px;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

/* Pagination */
.scrywp-task-drawer-pagination {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #ccd0d4;
    background: #f6f7f7;
    gap: 16px;
    flex-wrap: wrap;
}

.scrywp-task-drawer-pagination-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.scrywp-task-drawer-pagination button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid #2271b1;
    border-radius: 3px;
    background: #fff;
    color: #2271b1;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.scrywp-task-drawer-pagination button:hover:not(:disabled) {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.scrywp-task-drawer-pagination button:active:not(:disabled) {
    background: #135e96;
    border-color: #135e96;
}

.scrywp-task-drawer-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #ccd0d4;
    color: #646970;
}

.scrywp-task-drawer-pagination button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
}

.scrywp-task-drawer-pagination-info {
    font-size: 13px;
    color: #646970;
    font-weight: 500;
    white-space: nowrap;
    text-align: center;
}

.scrywp-task-drawer-page-input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    padding: 4px 8px;
    border: 1px solid #ccd0d4;
    border-radius: 3px;
    white-space: nowrap;
}

.scrywp-task-drawer-page-label {
    font-size: 13px;
    color: #646970;
    font-weight: 500;
    margin: 0;
    white-space: nowrap;
}

.scrywp-task-drawer-page-input {
    width: 50px;
    padding: 2px 4px;
    border: none;
    border-radius: 2px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    background: transparent;
    color: #1d2327;
    appearance: textfield;
    -moz-appearance: textfield;
}

.scrywp-task-drawer-page-input::-webkit-outer-spin-button,
.scrywp-task-drawer-page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.scrywp-task-drawer-page-input:focus {
    outline: none;
    background: #fff;
    box-shadow: inset 0 0 0 1px #2271b1;
}

.scrywp-task-drawer-total-pages {
    font-size: 13px;
    color: #646970;
    font-weight: 500;
    white-space: nowrap;
}

/* Responsive */
@media screen and (max-width: 782px) {

    /* Ensure toggle button is always visible on narrow screens */
    .scrywp-task-drawer-toggle-wrapper {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Drawer should be completely off-screen when closed */
    .scrywp-task-drawer {
        width: 100vw;
        max-width: 100vw;
        right: -100vw;
    }

    /* Drawer fully visible when open */
    .scrywp-task-drawer.open {
        right: 0;
    }

    .scrywp-task-drawer-pagination {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .scrywp-task-drawer-pagination-center {
        order: 0;
    }

    .scrywp-task-drawer-pagination-info {
        order: 1;
    }

    .scrywp-task-drawer-pagination button {
        width: 100%;
        justify-content: center;
    }
}