/* ==========================================================================
   AI Results Panels — Candidate Ranking & Matching
   Used on job view page with AdminLTE 4 + Bootstrap 5
   ========================================================================== */

/* --------------------------------------------------------------------------
   AI Action Buttons
   -------------------------------------------------------------------------- */

.btn-ai-rank,
.btn-ai-match {
    display: none; /* shown by JS after health check */
    color: #fff;
    border: none;
    padding: 0.375rem 0.875rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.1s ease;
}

.btn-ai-rank {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
}

.btn-ai-match {
    background: linear-gradient(135deg, #20c997, #17a2b8);
}

.btn-ai-rank:hover,
.btn-ai-match:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.btn-ai-rank:active,
.btn-ai-match:active {
    transform: translateY(0);
}

.btn-ai-loading {
    cursor: wait;
    opacity: 0.75;
    pointer-events: none;
}

.btn-ai-loading::before {
    content: '';
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    margin-right: 0.4rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ai-spin 0.65s linear infinite;
    vertical-align: text-bottom;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Shared Panel Base
   -------------------------------------------------------------------------- */

.ai-panel {
    display: none; /* shown by JS */
    margin-top: 1rem;
    border-radius: 6px;
}

#ai-rank-results,
#ai-match-results {
    overflow: visible;
}

.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.ai-panel-header .ai-panel-meta {
    font-size: 0.78rem;
    font-weight: 400;
    opacity: 0.75;
    margin-left: 0.5rem;
}

.ai-panel-close {
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 3px;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    line-height: 1.4;
    opacity: 0.65;
    transition: opacity 0.15s;
}

.ai-panel-close:hover {
    opacity: 1;
}

.ai-results-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
    margin: 0;
}

.ai-results-table th {
    background: rgba(0, 0, 0, 0.04);
    padding: 0.35rem 0.6rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.ai-results-table td {
    padding: 0.35rem 0.6rem;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* --------------------------------------------------------------------------
   Score Color Coding
   -------------------------------------------------------------------------- */

.ai-score-green  { color: #155724; font-weight: 600; }
.ai-score-yellow { color: #856404; font-weight: 600; }
.ai-score-red    { color: #721c24; font-weight: 600; }

/* --------------------------------------------------------------------------
   Expandable Detail Rows
   -------------------------------------------------------------------------- */

.ai-detail-row {
    display: none;
    background: rgba(255, 255, 255, 0.6);
}

.ai-detail-row.expanded {
    display: table-row;
}

.ai-detail-row td {
    font-size: 11px;
    color: #555;
    padding: 0.4rem 1rem 0.5rem 2rem;
}

.ai-expand-arrow {
    display: inline-block;
    transition: transform 0.2s;
    cursor: pointer;
    user-select: none;
}

.ai-expand-arrow.open {
    transform: rotate(90deg);
}

/* --------------------------------------------------------------------------
   Misc Row States
   -------------------------------------------------------------------------- */

.ai-failed-row {
    opacity: 0.55;
}

.ai-top-badge {
    display: inline-block;
    background: #28a745;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* --------------------------------------------------------------------------
   AI Rank Results Panel (#ai-rank-results)
   -------------------------------------------------------------------------- */

#ai-rank-results {
    border: 2px solid #6f42c1;
    border-radius: 6px;
    background: #f8f5ff;
}

#ai-rank-results .ai-panel-header {
    background: #6f42c1;
    color: #fff;
    border-bottom: none;
}

#ai-rank-results .ai-panel-close {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.55);
}

#ai-rank-results .ai-recommendation-banner {
    background: linear-gradient(to right, #d4edda, #c3e6cb);
    border-left: 4px solid #28a745;
    padding: 0.55rem 1rem;
    font-size: 0.82rem;
    color: #155724;
}

/* --------------------------------------------------------------------------
   AI Match Results Panel (#ai-match-results)
   -------------------------------------------------------------------------- */

#ai-match-results {
    border: 2px solid #17a2b8;
    border-radius: 6px;
    background: #f0fdfa;
}

#ai-match-results .ai-panel-header {
    background: #17a2b8;
    color: #fff;
    border-bottom: none;
}

#ai-match-results .ai-panel-close {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.55);
}

.ai-skill-tag {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    font-size: 10px;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    margin: 1px 2px 1px 0;
    white-space: nowrap;
}

.ai-already-tagged-row {
    opacity: 0.5;
}

.ai-linked-status {
    color: #28a745;
    font-size: 12px;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Candidate Fit Assessment (inline in match results)
   -------------------------------------------------------------------------- */

.ai-fit-detail-row td {
    padding: 0;
    border-top: none;
}

.ai-fit-card {
    background: #fafbff;
    border: 1px solid #e0e3f0;
    border-radius: 6px;
    padding: 12px 14px;
    margin: 6px 0;
    font-size: 12px;
}

.ai-fit-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.ai-fit-score {
    font-size: 20px;
    font-weight: 700;
    min-width: 50px;
}

.ai-fit-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-left: -6px;
}

.ai-fit-experience {
    font-size: 11px;
    color: #555;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 10px;
}

.ai-fit-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
}

.ai-fit-summary {
    color: #555;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.ai-fit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ai-fit-list {
    margin: 2px 0 0;
    padding-left: 16px;
    font-size: 11px;
    color: #555;
}

.ai-fit-list li {
    margin-bottom: 2px;
}

.ai-fit-rationale {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e3f0;
    font-size: 11px;
    color: #666;
}

/* ==========================================================================
   Auto Talent Pool Match Drawer
   ========================================================================== */

.auto-match-panel {
    background: #fff;
    border: 2px solid #7c3aed;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.12);
    margin: 12px 0;
}

.auto-match-header {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.auto-match-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.auto-match-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.auto-match-dismiss {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}
.auto-match-dismiss:hover {
    background: rgba(255, 255, 255, 0.25);
}

.auto-match-hint {
    padding: 8px 16px;
    font-size: 12px;
    color: #6b7280;
    background: #faf5ff;
    border-bottom: 1px solid #ede9fe;
}

.auto-match-table-wrapper {
    overflow-x: auto;
}

.auto-match-link-btn {
    background: #7c3aed;
    color: #fff !important;
    border: none;
    padding: 4px 12px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.auto-match-link-btn:hover {
    opacity: 0.85;
}
.auto-match-link-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.auto-match-footer {
    background: #faf5ff;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #6b7280;
    border-top: 1px solid #ede9fe;
}

.auto-match-footer-dismiss {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #cbd5e1;
    padding: 4px 12px;
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}
.auto-match-footer-dismiss:hover {
    color: #64748b;
    border-color: #94a3b8;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
    .ai-panel-header {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .ai-results-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .btn-ai-rank,
    .btn-ai-match {
        display: inline-flex !important;
        justify-content: center;
        flex: 1 1 45%;
        margin-right: 0 !important;
        font-size: 0.78rem;
        padding: 0.35rem 0.5rem;
    }
}
