/**
 * BCATM Category Editor Styles
 */

/* Main Layout */
.BCATM-category-manager {
    margin: 20px 0;
    position: relative;
}

.BCATM-main-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    position: relative; /* For absolute positioning of controls */
}

/* Header Controls */
.BCATM-category-controls {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 20px 0;
    padding: 15px;
}

.BCATM-control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.BCATM-category-select {
    min-width: 177px;
}

#term-search {
    width: 400px;
    padding: 8px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    margin-right:auto;
}

/* Tree Controls (Expand/Collapse All) */
.BCATM-tree-controls {
    z-index: 100;
    gap: 5px;
    text-align: right;
    margin-top: 16px;
    margin-bottom: 15px;
    margin-right: 4px;
}

.BCATM-tree-controls .button {
    display: inline-block;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    text-align: center;
    line-height: 28px;
    cursor: pointer;
}

.BCATM-tree-controls .BCATM-expand-all {
    display:none;
}

.BCATM-tree-controls .button:hover {
    background-color: #f0f0f1;
}

/* Terms Tree */
.BCATM-terms-tree {
    flex: 2;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    overflow: auto;
    padding: 15px;
    position: relative;
}

/* Term List Structure */
.BCATM-term-list {
    margin: 0;
    padding: 0;
    list-style: none;
    min-height: 10px; /* Ensures lists are droppable even when empty */
}

.BCATM-term-list ul,
.BCATM-term-list .BCATM-term-list {
    margin-left: 20px !important;
    padding-left: 12px !important;
    border-left: 1px dashed #ccd0d4;
}

.BCATM-term-list > li {
    margin-bottom: 1px;
}

/* Term Row */
.BCATM-term-row {
    position: relative;
    margin-left: 0 !important;
    padding-left: 0 !important;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.BCATM-term-row:hover {
    border-color: #2271b1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.BCATM-term-content {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    min-height: 40px;
    gap: 8px;
}

/* Drag Handle */
.BCATM-term-handle {
    width: 20px;
    height: 20px;
    cursor: move;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.BCATM-term-handle:hover {
    color: #2271b1;
}

.BCATM-term-handle .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Term Information */
.BCATM-term-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.BCATM-term-name {
    font-size: 14px;
    font-weight: 500;
}

.BCATM-term-count {
    color: #666;
    font-size: 12px;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

/* Hide counts when setting is disabled */
.BCATM-hide-counts .BCATM-term-count {
    display: none;
}

/* Toggle Children Button */
.BCATM-toggle-children {
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #1d2327;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: all 0.2s ease;
}

.BCATM-toggle-children:hover {
    color: #2271b1;
}

.BCATM-toggle-children .dashicons {
    transition: transform 0.2s ease;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.BCATM-toggle-children.expanded .dashicons {
    transform: rotate(90deg);
}

/* Term Actions */
.BCATM-term-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    gap: 8px;
}

.BCATM-term-content:hover .BCATM-term-actions {
    opacity: 1;
}

.BCATM-term-actions .dashicons {
    margin-top: 3px;
}

/* Delete button styles */
.BCATM-quick-delete {
    color: #cc1818;
    display: flex;
    align-items: center;
    gap: 5px;
}

.BCATM-quick-delete:hover {
    color: #dc3232;
}

.BCATM-quick-delete.confirm-delete {
    background-color: #fbe9e7;
    color: #cc1818;
    animation: pulse 1.5s infinite;
    padding: 0 8px;
}

.BCATM-quick-delete.confirm-delete:hover {
    background-color: #e21818;
    color: #ffffff;
}

.BCATM-quick-delete .confirm-text {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* Drag and Drop States */
.BCATM-term-row.is-dragging {
    opacity: 0.7;
    background: #f8f9fa;
    border: 2px dashed #2271b1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Visual indicator for potential parent */
.BCATM-term-row.potential-parent {
    background-color: #f0f7fc;
    border: 2px solid #2271b1;
    border-bottom: none;
    position: relative;
}

.BCATM-term-row.potential-parent::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    background-color: #2271b1;
    z-index: 1;
}

/* Helper text for nesting indication */
.nesting-helper {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #2271b1;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0.9;
    pointer-events: none;
    z-index: 2;
    animation: fadeIn 0.2s ease-in-out;
}

/* Temporary Drop Containers */
.temp-drop-container {
    height: 0;
    opacity: 0;
    transition: all 0.2s ease;
    background: rgba(34, 113, 177, 0.05);
    border-left: 2px dashed #2271b1;
    margin-left: 20px;
    padding: 0;
}

.temp-drop-container.active {
    height: 40px;
    opacity: 1;
    margin-left: 20px !important;
    padding-left: 12px !important;
}

/* Placeholder Styling */
.BCATM-sortable-placeholder {
    border: 2px dashed #2271b1;
    margin-left: 20px;
    height: 40px !important;
    border-radius: 3px;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.BCATM-sortable-placeholder.is-child-indent {
    margin-left: 40px !important;
    border-left: 4px solid #2271b1;
    background: rgba(34, 113, 177, 0.1);
    position: relative;
}

.BCATM-sortable-placeholder.is-child-indent::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    width: 16px;
    height: 2px;
    background-color: #2271b1;
}

/* Drop Zone Indicators */
.BCATM-term-row.show-drop-zone::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30%;
    background: linear-gradient(90deg, transparent, rgba(34, 113, 177, 0.1));
    pointer-events: none;
    z-index: 1;
}

/* Term Editor Sidebar */
.BCATM-term-editor {
    flex: 1;
    min-width: 322px;
    max-width: 400px;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    padding: 25px;
}

.BCATM-term-editor-header {
    background: #f8f9fa;
    border-bottom: 1px solid #ccd0d4;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.BCATM-term-editor-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.BCATM-term-editor-content {
    padding: 20px;
    overflow-y: auto;
}

.BCATM-form-actions .dashicons {
    margin-top:4px;
}

/* Form Fields */
.BCATM-form-field {
    margin-bottom: 20px;
}

.BCATM-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.BCATM-form-field input[type="text"],
.BCATM-form-field textarea,
.BCATM-form-field select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
}

.BCATM-form-field input[type="text"]:focus,
.BCATM-form-field textarea:focus,
.BCATM-form-field select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

.BCATM-form-field .description {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
}

/* OpenAI Controls */
.openai-controls {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

#generate-description {
    width: 100%;
    margin-top: 6px;
}

.dashicons-editor-spellcheck {
    margin-top: 6px;
    margin-right: 6px;
}

/* Form Actions */
.BCATM-form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    gap: 10px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 0.9;
        transform: translateY(-50%);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* RTL Support */
.rtl .BCATM-term-list ul {
    margin-right: 24px;
    margin-left: 0;
    border-right: 1px dashed #ccd0d4;
    border-left: none;
    padding-right: 12px;
    padding-left: 0;
}

.rtl .nesting-helper {
    left: 10px;
    right: auto;
}

/* Accessibility */
.BCATM-category-manager .screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

.BCATM-category-manager button:focus,
.BCATM-category-manager input:focus,
.BCATM-category-manager select:focus,
.BCATM-category-manager textarea:focus {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}

/* Responsive Design */
@media screen and (max-width: 782px) {
    .BCATM-main-container {
        flex-direction: column;
    }

    .BCATM-term-editor {
        max-width: none;
    }

    .BCATM-category-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .BCATM-control-group {
        flex-direction: column;
    }

    #term-search,
    .BCATM-category-select {
        width: 100%;
    }

    .nesting-helper {
        display: none; /* Hide helper text on mobile */
    }
}

/* Hierarchy controls styling for non-hierarchical taxonomies */
.BCATM-flat-category .BCATM-term-handle {
    opacity: 0.3;
    cursor: not-allowed;
}

.BCATM-flat-category .BCATM-term-handle:hover {
    background-color: transparent;
}

.BCATM-flat-category .BCATM-term-row {
    padding-left: 10px; /* Reduce indentation for flat taxonomies */
}

.BCATM-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Notification Banner System - Updated with more visibility */
.BCATM-notification-container {
    position: fixed;
    top: 50px; /* Increased to be more visible */
    right: 20px;
    z-index: 10000; /* Increased z-index to ensure it's on top */
    max-width: 400px;
}

.BCATM-notification {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); /* Enhanced shadow */
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: BCATM-slide-in 0.3s ease-out forwards;
    opacity: 0;
    transform: translateX(50px);
}

.BCATM-notification.BCATM-fadeout {
    animation: BCATM-fade-out 0.5s ease-out forwards;
}

.BCATM-notification-success {
    background-color: #dff2bf;
    color: #4F8A10;
    border-left: 4px solid #4F8A10;
    font-weight: bold; /* Made success messages more prominent */
}

.BCATM-notification-error {
    background-color: #ffbaba;
    color: #D8000C;
    border-left: 4px solid #D8000C;
}

.BCATM-notification-warning {
    background-color: #feefb3;
    color: #9F6000;
    border-left: 4px solid #9F6000;
}

.BCATM-notification-info {
    background-color: #bde5f8;
    color: #00529B;
    border-left: 4px solid #00529B;
}

.BCATM-notification-close {
    margin-left: 15px;
    cursor: pointer;
    font-size: 20px;
    line-height: 20px;
    opacity: 0.7;
}

.BCATM-notification-close:hover {
    opacity: 1;
}

.BCATM-notification-content {
    flex: 1;
}

@keyframes BCATM-slide-in {
    0% {
        opacity: 0;
        transform: translateX(50px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes BCATM-fade-out {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(50px);
    }
}

/* Loading Overlay */
.BCATM-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.BCATM-loading-overlay.hidden {
    display: none;
}

.BCATM-loading-overlay .spinner {
    float: none;
    margin: 0;
    visibility: visible;
}

/* Custom Notices */
.BCATM-notice-container {
    margin: 15px 0 20px;
}

.BCATM-notice {
    position: relative;
    border-radius: 2px !important;
    padding: 10px 40px 10px 14px;
    margin-bottom: 15px;
}

.BCATM-notice.notice-success {
    border-left-color: #46b450 !important;
}

.BCATM-notice.notice-error {
    border-left-color: #dc3232 !important;
}

.BCATM-notice p {
    margin: 0.5em 0;
    padding: 0;
    line-height: 1.5;
}

.BCATM-notice .notice-dismiss {
    position: absolute;
    top: 0;
    right: 0;
    border: none;
    margin: 0;
    padding: 9px;
    background: none;
    color: #787c82;
    cursor: pointer;
}

.BCATM-notice .notice-dismiss:before {
    background: none;
    color: #787c82;
    content: "\f153";
    display: block;
    font: normal 16px/20px dashicons;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 20px;
    text-align: center;
    width: 20px;
}

.BCATM-notice .notice-dismiss:hover:before,
.BCATM-notice .notice-dismiss:active:before,
.BCATM-notice .notice-dismiss:focus:before {
    color: #d63638;
}

/* Fix for admin page styling */
.wrap h1.wp-heading-inline {
    display: inline-block;
    margin-right: 5px;
}

/* Fix for import/export controls */
.BCATM-import-export-controls {
    display: inline-block;
    margin-left: 15px;
    vertical-align: middle;
}

@media screen and (max-width: 900px) {
    .BCATM-term-name {
        font-size: 11px;
    }
}