/**
 * Navigation buttons styles
 *
 * @package AI_Editor_Post_Switcher
 */

.ai-editor-nav-buttons {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background-color: #f0f0f0;
    border-radius: 6px;
    margin-right: 10px;
}

.ai-nav-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #007CBA;
    color: white;
    padding: 6px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
}

.ai-nav-button svg {
    width: 16px;
    height: 16px;
    display: block;
    color: white; /* SVG inherits this color */
    fill: currentColor;
}

.ai-nav-button:hover:not(:disabled) {
    background-color: #0071a8;
}

.ai-nav-button:focus {
    outline: none;
    box-shadow: 0 0 0 1px white, 0 0 0 2px #007CBA;
}

.ai-nav-button.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Search button specific styles */
.ai-search-button {
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: #333;
    border: 3px solid #007CBA;
}

.ai-search-button:hover:not(:disabled) {
    background-color: rgba(0, 124, 186, 0.1);
}

/* Popup styles */
.ai-posts-search-popup {
    position: absolute;
    display: none;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 320px;
    max-width: 90vw;
    max-height: 70vh;
    z-index: 100000;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.ai-popup-header {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #e2e4e7;
    background: #f8f9f9;
}

.ai-popup-search-input {
    flex: 1;
    border: 1px solid #8d96a0;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
}

.ai-popup-search-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
}

.ai-popup-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    margin-left: 5px;
    color: #555;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-popup-close:hover {
    background: #f0f0f0;
    color: #000;
}

.ai-popup-content {
    overflow-y: auto;
    max-height: calc(70vh - 115px); /* Adjusted for header + position indicator + status filters */
    padding: 0;
}

.ai-popup-loading, 
.ai-popup-error,
.ai-popup-no-posts,
.ai-popup-no-results,
.ai-popup-no-filter-results {
    padding: 20px;
    text-align: center;
    color: #555;
}

.ai-popup-no-filter-results {
    color: #999;
    font-style: italic;
}

.ai-popup-error {
    color: #d94f4f;
}

.ai-popup-search-info {
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e2e4e7;
    font-size: 12px;
    color: #666;
}

.ai-popup-posts-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ai-popup-position-indicator {
    padding: 0 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e2e4e7;
}

.ai-popup-post-item {
    border-bottom: 1px solid #f0f0f0;
    padding: 0;
    margin: 0;
    position: relative; /* Ensures badge is positioned relative to this item */
}

.ai-popup-post-item:last-child {
    border-bottom: none;
}

.ai-popup-post-item a {
    display: flex;
    align-items: center;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 15px; /* Default left padding */
    padding-right: 75px; /* Increased right padding to make space for the badge */
    text-decoration: none;
    color: #2c3338;
    transition: background 0.1s ease;
    position: relative;
}

.ai-popup-post-item a:hover {
    background-color: #007CBA;
    color: white;
}

/* Icon and title layout for context posts */
.ai-popup-post-with-icon a {
    padding-left: 30px; /* Space for icon, right padding is inherited (90px) */
}

.ai-popup-item-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-block;
    line-height: 0;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    padding: 3px;
    border-radius: 3px;
    background-color: #dcdcde;
}

.ai-popup-item-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.ai-popup-current-post .ai-popup-item-icon {
    background-color: #4cdcde;
}

.ai-popup-current-post .ai-popup-item-icon svg {
    fill: #ffffff;
}

.ai-popup-item-title {
    flex: 1; /* Allows title to take available space and truncate */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: .5rem; /* Space after icon, if present */
}

/* Current post highlight */
.ai-popup-current-post {
    background-color: #d0f7fc;
}

.ai-popup-current-post a {
    font-weight: 600;
    color: #007cba;
}

.ai-popup-current-post a:hover {
    color: white;
}

/* Current post without icon needs less left padding - this rule is fine as it only affects padding-left */
.ai-popup-current-post:not(.ai-popup-post-with-icon) a {
    padding-left: 15px;
}

/* Status indicator styles */
.ai-popup-post-status {
    font-size: 10px;
    border-radius: 3px;
    padding: 2px 5px;
    /* margin-right: 6px; /* Removed, not needed for absolute positioning */
    text-transform: uppercase;
    color: white;
    position: absolute;
    right: 15px; /* Positioned 15px from the right edge of .ai-popup-post-item */
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1; /* To ensure it's above link's background if needed */
}

.ai-popup-post-status:hover {
    opacity: 0.85;
    transform: translateY(-50%) scale(1.05);
}

/* WordPress standard status colors */
.ai-status-publish {
    background-color: #46b450; /* WordPress green */
}

.ai-status-draft {
    background-color: #c3c4c7; /* WordPress gray */
    color: #50575e; /* Dark text for better contrast */
}

.ai-status-pending {
    background-color: #f0b849; /* WordPress amber/orange */
    color: #50575e; /* Dark text for better contrast */
}

.ai-status-future {
    background-color: #0073aa; /* WordPress primary blue */
}

.ai-status-private {
    background-color: #50575e; /* WordPress dark gray */
}

.ai-status-active-filter {
    box-shadow: 0 0 0 2px white, 0 0 0 3px #000;
}

/* Password protected indicator - tomato circle on status badge */
.ai-popup-password-indicator {
    width: 6px;
    height: 6px;
    background-color: #ff6347; /* Tomato color */
    border-radius: 50%;
    position: absolute;
    right: -2px;
    bottom: -2px;
    cursor: help;
    transition: all 0.2s ease;
    border: 1px solid white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ai-popup-password-indicator:hover {
    background-color: #ff4500; /* Darker orange-red on hover */
    transform: scale(1.3);
}

.ai-popup-status-filters {
    display: flex;
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 5px;
    border-bottom: 1px solid #e2e4e7;
    background: #f9f9f9;
    position: relative;
    z-index: 10;
}

.ai-popup-status-filter {
    font-size: 12px;
    border-radius: 12px;
    padding: 3px 12px;
    margin: 0;
    text-transform: uppercase;
    color: white;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-weight: 600;
    min-width: 36px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
    height: 24px;
}

.ai-filter-count {
    font-size: 12px;
    opacity: 1;
    margin-left: 0;
    font-weight: 600;
}

.ai-popup-status-filter-all {
    padding: 3px 12px;
    min-width: auto;
    background-color: #555;
}

.ai-popup-status-filter-all:hover {
    background-color: #444;
}

.ai-popup-status-filter-all .ai-filter-count {
    margin-left: 4px;
    opacity: 0.85;
    font-weight: 500;
}

.ai-popup-status-filter:hover:not(.ai-filter-disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-popup-status-filter.active {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.2);
}

/* Status filter buttons match WordPress colors */
.ai-popup-status-filter.ai-status-publish {
    background-color: #46b450;
}

.ai-popup-status-filter.ai-status-publish:hover:not(.ai-filter-disabled) {
    background-color: #3a9142;
}

.ai-popup-status-filter.ai-status-draft {
    background-color: #c3c4c7;
    color: #50575e; /* Dark text on light gray background */
}

.ai-popup-status-filter.ai-status-draft:hover:not(.ai-filter-disabled) {
    background-color: #b5b6ba;
}

.ai-popup-status-filter.ai-status-pending {
    background-color: #f0b849;
    color: #50575e; /* Dark text on amber background */
}

.ai-popup-status-filter.ai-status-pending:hover:not(.ai-filter-disabled) {
    background-color: #e8a73c;
}

.ai-popup-status-filter.ai-status-future {
    background-color: #0073aa;
}

.ai-popup-status-filter.ai-status-future:hover:not(.ai-filter-disabled) {
    background-color: #006291;
}

.ai-popup-status-filter.ai-status-private {
    background-color: #50575e;
}

.ai-popup-status-filter.ai-status-private:hover:not(.ai-filter-disabled) {
    background-color: #444b52;
}

/* Disabled filter button styles */
.ai-popup-status-filter.ai-filter-disabled {
    cursor: not-allowed !important;
}

.ai-popup-status-filter.ai-filter-disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Responsive adjustments */
@media (max-width: 782px) {
    .ai-editor-nav-buttons {
        margin-right: 5px;
    }
    
    .ai-nav-button {
        padding: 8px;
        width: 32px;
        height: 32px;
    }
    
    .ai-nav-button svg {
        width: 18px;
        height: 18px;
    }
    
    .ai-posts-search-popup {
        width: 280px;
    }
    
    .ai-popup-content {
        max-height: calc(60vh - 115px); /* Adjusted for mobile */
    }
    
    .ai-popup-post-item a {
        padding-top: 12px; /* Maintain consistent vertical padding */
        padding-bottom: 12px;
        /* padding-left and padding-right from base rule or .ai-popup-post-with-icon a will apply */
    }
    
    .ai-popup-post-with-icon a {
        padding-left: 35px;
    }
    
    .ai-popup-item-icon {
        left: 12px;
    }
}

.ai-rank-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    margin: 8px 0;
    color: #2c3338;
    background: #f0f0f0;
    padding: 3px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    box-shadow: none;
}

.ai-rank-current {
    color: #007CBA;
    font-weight: 700;
}

.ai-rank-separator {
    font-size: 1.1em;
    color: #b7bac1;
    margin: 0 1px;
}

.ai-rank-total {
    color: #666;
}

.ai-rank-label {
    color: #b7bac1;
    margin-left: 7px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Light translucent background for disabled status buttons - Higher specificity */
.ai-popup-status-filter.ai-status-publish.ai-filter-disabled {
  background-color: rgba(70, 180, 80, 0.2) !important;   /* #46b450 with 20% opacity */
  color: #ffffff !important;
  opacity: 1 !important; /* Override any inline opacity */
}

.ai-popup-status-filter.ai-status-pending.ai-filter-disabled {
  background-color: rgba(240, 184, 73, 0.2) !important;  /* #f0b849 with 20% opacity */
  color: #ffffff !important;
  opacity: 1 !important; /* Override any inline opacity */
}

.ai-popup-status-filter.ai-status-draft.ai-filter-disabled {
  background-color: rgba(195, 196, 199, 0.2) !important; /* #c3c4c7 with 20% opacity */
  color: #ffffff !important;
  opacity: 1 !important; /* Override any inline opacity */
}

.ai-popup-status-filter.ai-status-future.ai-filter-disabled {
  background-color: rgba(0, 115, 170, 0.2) !important;   /* #0073aa with 20% opacity */
  color: #ffffff !important;
  opacity: 1 !important; /* Override any inline opacity */
}

.ai-popup-status-filter.ai-status-private.ai-filter-disabled {
  background-color: rgba(80, 87, 94, 0.2) !important;    /* #50575e with 20% opacity */
  color: #ffffff !important;
  opacity: 1 !important; /* Override any inline opacity */
}