/**
 * AnswerRails Knowledge Management Admin Styles
 * 
 * Professional, modern styling for the knowledge management interface
 * Compatible with WordPress admin theme and accessible design
 */

/* === BASE STYLES === */

.answerrails-admin {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.answerrails-header {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 20px 0;
    margin: 0 0 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.answerrails-title {
    font-size: 24px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.answerrails-logo {
    color: #0073aa;
    font-weight: 600;
}

.answerrails-separator {
    color: #ddd;
    font-weight: 300;
}

.answerrails-page-title {
    color: #444;
    font-weight: 400;
}

.answerrails-description {
    color: #666;
    margin: 5px 0 0 0;
    font-size: 14px;
}

/* === NAVIGATION TABS === */

.answerrails-nav-tabs {
    margin-bottom: 20px;
}

.nav-tab-wrapper .nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    border: 1px solid #ddd;
    border-bottom: none;
    background: #f9f9f9;
    color: #555;
    padding: 8px 14px;
    margin-right: 2px;
    border-radius: 4px 4px 0 0;
    transition: all 0.2s ease;
}

.nav-tab-wrapper .nav-tab:hover {
    background: #fff;
    color: #0073aa;
}

.nav-tab-wrapper .nav-tab.nav-tab-active {
    background: #fff;
    color: #333;
    border-bottom: 1px solid #fff;
    margin-bottom: -1px;
}

.nav-tab-wrapper .nav-tab .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ⚠ No PRO-badge or PRO-tab rule here: the free build renders neither
   (#174). */
/* === SETTINGS SECTIONS === */

.answerrails-settings-section {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 20px;
    padding: 20px;
}

.answerrails-settings-section h2 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 18px;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 5px;
    display: inline-block;
}

.answerrails-settings-section .description {
    margin-bottom: 15px;
    color: #666;
    font-style: italic;
}

/* ⚠ The LIVE add-form surfaces are #knowledge-type-selector,
   .knowledge-form and .answerrails-knowledge-form, all styled below — no
   other type-selector markup is rendered (#139). */
/* === FORM SECTIONS === */

.answerrails-knowledge-form .form-table th {
    width: 180px;
    padding: 15px 10px 15px 0;
    vertical-align: top;
}

.answerrails-knowledge-form .form-table td {
    padding: 15px 0;
}

.answerrails-knowledge-form .required {
    color: #d63638;
}

.answerrails-knowledge-form .error {
    border-color: #d63638 !important;
    box-shadow: 0 0 0 1px #d63638;
}

/* === KNOWLEDGE LIST TABLE === */

.answerrails-knowledge-list {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.answerrails-knowledge-list .widefat {
    border: none;
    border-radius: 0;
}

.answerrails-knowledge-list .widefat thead th {
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
    padding: 12px 8px;
    font-weight: 600;
    color: #333;
}

.answerrails-knowledge-list .widefat tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.answerrails-knowledge-list .widefat tbody tr:hover {
    background: #f0f8ff;
}

.answerrails-knowledge-list .widefat tbody td {
    padding: 12px 8px;
    vertical-align: middle;
}
/* === STATUS INDICATORS === */
.answerrails-status-active {
    color: #00a32a;
    font-weight: 600;
}
.answerrails-status-error {
    color: #d63638;
    font-weight: 600;
}

.answerrails-status-manual {
    color: #dba617;
    font-weight: 600;
}

/* #92 local mode: completed local-only sync — neutral/positive, not an error */
.answerrails-status-local {
    color: #2271b1;
    font-weight: 600;
}

/* #138 D6: source unavailable, grace lag running — amber warning */
.answerrails-status-warning {
    color: #996800;
    font-weight: 600;
}

/* #138 D6: withdrawn from retrieval — red, but recoverable */
.answerrails-status-withdrawn {
    color: #d63638;
    font-weight: 600;
}

.answerrails-never-synced {
    color: #999;
    font-style: italic;
}

/* === VECTOR STORE STATUS === */

.answerrails-vector-store-status {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.answerrails-vector-store-status h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.answerrails-vector-store-status p {
    margin: 0;
}

/* === MODAL STYLES === */

.answerrails-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.answerrails-modal {
    background: white;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.answerrails-modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
}

.answerrails-modal-header h3 {
    margin: 0;
    color: #333;
}

.answerrails-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.answerrails-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.answerrails-modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.answerrails-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    background: #f9f9f9;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* === RESPONSIVE DESIGN === */

@media screen and (max-width: 782px) {
    .answerrails-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    

    .answerrails-modal {
        margin: 10px;
        max-height: 90vh;
    }
}

@media screen and (max-width: 600px) {
    
    .nav-tab-wrapper .nav-tab {
        padding: 6px 10px;
        font-size: 13px;
    }
}

/* === LOADING STATES === */

.answerrails-loading {
    position: relative;
}

.answerrails-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: answerrails-spin 1s linear infinite;
}

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

@keyframes answerrails-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.removing {
    opacity: 0.5;
    pointer-events: none;
}

/* === NO ITEMS STATE === */

.answerrails-no-items {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.answerrails-no-items-icon {
    margin-bottom: 20px;
}

.answerrails-no-items-icon .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: #ddd;
}

.answerrails-no-items h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 18px;
}

.answerrails-no-items p {
    margin: 0 0 20px 0;
    line-height: 1.5;
}

/* === TEMPORARY NOTICE === */

.answerrails-temp-notice {
    position: fixed;
    top: 32px;
    right: 20px;
    z-index: 999999;
    max-width: 400px;
}

.answerrails-temp-notice .notice {
    margin: 5px 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .button,
    .nav-tab-wrapper .nav-tab {
        transition: none;
    }
.answerrails-loading::after{
        animation: none;
    }
}

/* === FOCUS STATES === */

.button:focus,
.nav-tab-wrapper .nav-tab:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.answerrails-modal-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 1px;
}

/* === DARK MODE SUPPORT === */

@media (prefers-color-scheme: dark) {
    .answerrails-admin {
        color-scheme: dark;
    }
}

/* === PRINT STYLES === */

@media print {
.answerrails-header-actions,
.nav-tab-wrapper,
.button,
.answerrails-modal-overlay{
        display: none !important;
    }
    
    .answerrails-settings-section,
    .answerrails-knowledge-list {
        border: 1px solid #000;
        break-inside: avoid;
    }
}

.answerrails-modal-overlay {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
}

/* ------------------------------------------------------------------ */
/* #132 W5: former inline <style> block, moved from admin/views/knowledge.php. */
/* ------------------------------------------------------------------ */

.answerrails-status-active {
    color: #00a32a;
    font-weight: bold;
}

.answerrails-status-error {
    color: #d63638;
    font-weight: bold;
}

.answerrails-status-local {
    color: #2271b1;
    font-weight: bold;
}

.answerrails-status-manual {
    color: #dba617;
    font-weight: bold;
}

.answerrails-vector-store-status {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

/* #73: Site Content picker (bulk onboarding) */
.answerrails-site-picker .answerrails-site-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 12px 0;
}
.answerrails-site-picker #answerrails-site-search {
    min-width: 220px;
}
.answerrails-site-table th.check-column,
.answerrails-site-table td.check-column {
    width: 2.2em;
    padding: 8px 0 8px 3px;
}
.answerrails-site-paging {
    margin: 10px 0;
    display: flex;
    gap: 10px;
    align-items: center;
}
.answerrails-site-selection {
    margin: 8px 0 4px;
}
.answerrails-in-kb-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11px;
    background: #f0f0f1;
    color: #50575e;
    border: 1px solid #c3c4c7;
}
/* ⚠ The picker renders registered types only, so it needs no badge or
   note rule for an unavailable one (#174). */
.answerrails-progress-track {
    height: 10px;
    background: #f0f0f1;
    border: 1px solid #c3c4c7;
    border-radius: 5px;
    overflow: hidden;
    margin: 10px 0 6px;
}
.answerrails-progress-fill {
    height: 100%;
    background: #2271b1;
    transition: width 0.2s ease;
}
#answerrails-site-results-log .answerrails-result-added { color: #007a33; }
#answerrails-site-results-log .answerrails-result-skipped { color: #996800; }
#answerrails-site-results-log .answerrails-result-failed { color: #d63638; }

/* #73 D6: bulk sync-mode control grouping */
.answerrails-bulk-mode {
    margin-left: 10px;
    white-space: nowrap;
}

/* #142 visibility amendment (2026-08-06): cross-reference badge in the
   knowledge list Type column (PHP + JS twin renderers). */
.answerrails-xref-chip {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 6px;
    border-radius: 3px;
    background: #eef4fb;
    border: 1px solid #c5d9ef;
    color: #1d4f8f;
    font-size: 11px;
    line-height: 1.6;
    white-space: nowrap;
}
