/**
 * UNIFIED DIRECTORY PANEL
 * Modern design inspired by Economy Hub & Social Hub
 * Tab-based navigation for Players, Companions, Bots, and All
 */

/* ==================== PANEL CONTAINER ==================== */

.directory-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 1400px;
    height: 85vh;
    max-height: 900px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 12px;
    box-shadow:
        0 20px 80px rgba(0, 0, 0, 0.9),
        0 0 40px rgba(212, 175, 55, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: directoryFadeIn 0.3s ease-out;
    backdrop-filter: blur(20px);
}

@keyframes directoryFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ==================== HEADER ==================== */

.directory-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(0deg, rgba(30, 41, 59, 0.95), rgba(51, 65, 85, 0.98));
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    backdrop-filter: blur(10px);
    cursor: move; /* For dragging */
}

.directory-panel-title {
    margin: 0;
    font-family: 'RemiliaMincho', serif;
    color: #baa674;
    font-size: 20px;
    font-weight: 400;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.5px;
}

.directory-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.directory-refresh-btn,
.directory-panel-close {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.9) 0%, rgba(51, 65, 85, 0.95) 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: rgba(186, 166, 116, 0.8);
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.8);
}

.directory-refresh-btn:hover {
    background: linear-gradient(180deg, rgba(51, 65, 85, 0.9) 0%, rgba(30, 41, 59, 0.95) 100%);
    border-color: rgba(212, 175, 55, 0.5);
    color: rgba(212, 175, 55, 0.9);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
    transform: scale(1.05);
}

.directory-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.directory-panel-close:hover {
    background: linear-gradient(180deg, rgba(51, 65, 85, 0.9) 0%, rgba(30, 41, 59, 0.95) 100%);
    border-color: rgba(239, 68, 68, 0.5);
    color: rgba(239, 68, 68, 0.9);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
    transform: scale(1.05);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==================== TAB NAVIGATION ==================== */

.directory-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.15) 0%, rgba(51, 65, 85, 0.2) 100%);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    backdrop-filter: blur(4px);
}

.directory-tab {
    flex: 1;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.6) 0%, rgba(51, 65, 85, 0.8) 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    padding: 10px 16px;
    color: rgba(186, 166, 116, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.8);
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.directory-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.1), transparent);
    transition: left 0.3s ease;
}

.directory-tab:hover {
    background: linear-gradient(180deg, rgba(51, 65, 85, 0.8) 0%, rgba(30, 41, 59, 0.9) 100%);
    border-color: rgba(212, 175, 55, 0.5);
    color: rgba(212, 175, 55, 0.9);
    transform: translateY(-2px);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.3),
        0 0 8px rgba(212, 175, 55, 0.2);
}

.directory-tab:hover::before {
    left: 100%;
}

.directory-tab.active {
    background: linear-gradient(180deg, rgba(51, 65, 85, 0.9) 0%, rgba(30, 41, 59, 0.95) 100%);
    border-color: rgba(212, 175, 55, 0.6);
    color: rgba(212, 175, 55, 1);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tab-icon {
    font-size: 16px;
}

.tab-text {
    font-family: 'RemiliaMincho', serif;
    font-size: 11px;
}

/* ==================== CONTENT LAYOUT ==================== */

.directory-panel-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 20px;
    padding: 20px;
}

/* ==================== SIDEBAR (FILTERS) ==================== */

.directory-sidebar {
    width: 260px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.3) 0%, rgba(51, 65, 85, 0.5) 100%);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 8px;
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

.directory-sidebar::-webkit-scrollbar {
    width: 8px;
}

.directory-sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.directory-sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.4) 0%, rgba(186, 166, 116, 0.6) 100%);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.directory-sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.6) 0%, rgba(186, 166, 116, 0.8) 100%);
}

.filter-section {
    margin-bottom: 20px;
}

.filter-section-title {
    color: #baa674;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-search-input,
.filter-select,
.filter-range-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    color: #baa674;
    font-size: 13px;
    font-family: 'RemiliaMincho', serif;
    transition: all 0.15s ease;
}

.filter-search-input:focus,
.filter-select:focus,
.filter-range-input:focus {
    outline: none;
    border-color: rgba(212, 175, 55, 0.6);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.2);
    background: rgba(0, 0, 0, 0.5);
}

.filter-range-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.filter-range-label {
    color: rgba(186, 166, 116, 0.6);
    font-size: 11px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(186, 166, 116, 0.8);
    font-size: 14px;
    margin-bottom: 8px;
    cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.filter-clear-btn {
    width: 100%;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 8px;
    padding: 10px;
    color: #fca5a5;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
}

.filter-clear-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* ==================== MAIN CONTENT AREA ==================== */

.directory-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================== TOOLBAR ==================== */

.directory-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    margin-bottom: 16px;
}

.directory-results-info {
    color: rgba(186, 166, 116, 0.8);
    font-size: 14px;
}

.directory-results-count {
    color: #8b5cf6;
    font-weight: 700;
    font-size: 16px;
}

.directory-sort-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.directory-sort-label {
    color: rgba(186, 166, 116, 0.7);
    font-size: 13px;
}

.directory-sort-select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    color: #baa674;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.directory-sort-select:hover {
    border-color: #8b5cf6;
}

/* ==================== GRID CONTAINER ==================== */

.directory-grid-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.directory-grid-container::-webkit-scrollbar {
    width: 8px;
}

.directory-grid-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.directory-grid-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.5);
    border-radius: 4px;
}

.directory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 4px;
}

/* ==================== ENTITY CARDS ==================== */

.directory-card {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.4) 0%, rgba(51, 65, 85, 0.6) 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.directory-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.08), transparent);
    transition: left 0.5s ease;
    z-index: 1;
}

.directory-card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 16px rgba(212, 175, 55, 0.2);
    border-color: rgba(212, 175, 55, 0.6);
}

.directory-card:hover::before {
    left: 100%;
}

.card-type-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
}

.card-type-badge.player {
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.5);
}

.card-type-badge.companion {
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.5);
}

.card-type-badge.bot {
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.5);
}

.official-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.5), rgba(0, 0, 0, 0.7));
    position: relative;
    z-index: 2;
}

.card-content {
    padding: 12px;
    position: relative;
    z-index: 2;
}

.card-header {
    margin-bottom: 8px;
}

.card-name {
    color: #baa674;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-stage,
.card-rank {
    color: rgba(186, 166, 116, 0.6);
    font-size: 12px;
}

.card-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 8px;
    display: inline-block;
    margin-top: 4px;
}

.card-status.online {
    color: #34d399;
    background: rgba(52, 211, 153, 0.2);
}

.card-status.offline {
    color: rgba(186, 166, 116, 0.5);
    background: rgba(0, 0, 0, 0.3);
}

.card-info {
    font-size: 12px;
    color: rgba(186, 166, 116, 0.7);
    margin-top: 8px;
}

.card-stat {
    margin-bottom: 4px;
}

.stat-value {
    color: #8b5cf6;
    font-weight: 700;
}

.card-prime {
    margin: 8px 0;
}

.prime-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prime-badge.trace { background: rgba(147, 51, 234, 0.3); color: #c084fc; }
.prime-badge.pulse { background: rgba(220, 38, 38, 0.3); color: #fca5a5; }
.prime-badge.fade { background: rgba(100, 116, 139, 0.3); color: #cbd5e1; }
.prime-badge.branch { background: rgba(22, 163, 74, 0.3); color: #86efac; }
.prime-badge.echo { background: rgba(14, 165, 233, 0.3); color: #7dd3fc; }
.prime-badge.null { background: rgba(0, 0, 0, 0.5); color: #9ca3af; }

.card-care {
    font-size: 12px;
    margin: 8px 0;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
}

.card-care.optimal { color: #10b981; background: rgba(16, 185, 129, 0.2); }
.card-care.stable { color: #3b82f6; background: rgba(59, 130, 246, 0.2); }
.card-care.anxious { color: #f59e0b; background: rgba(245, 158, 11, 0.2); }
.card-care.rusty { color: #ef4444; background: rgba(239, 68, 68, 0.2); }

.card-owner {
    font-size: 11px;
    color: rgba(186, 166, 116, 0.6);
    margin-top: 8px;
}

.owner-name {
    color: #8b5cf6;
    font-weight: 600;
}

.card-platforms {
    font-size: 16px;
    margin-bottom: 4px;
}

.card-capabilities {
    color: rgba(186, 166, 116, 0.6);
    font-size: 11px;
}

/* ==================== PAGINATION ==================== */

.directory-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-top: 16px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
}

.pagination-btn {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 8px;
    padding: 10px 20px;
    color: #baa674;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-info {
    color: rgba(186, 166, 116, 0.8);
    font-size: 14px;
}

.pagination-page-number {
    color: #8b5cf6;
    font-weight: 700;
    font-size: 16px;
}

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

.directory-empty,
.directory-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    grid-column: 1 / -1;
    gap: 16px;
}

.empty-icon {
    font-size: 64px;
    opacity: 0.5;
}

.empty-text {
    color: #baa674;
    font-size: 20px;
    font-weight: 600;
}

.empty-subtext {
    color: rgba(186, 166, 116, 0.6);
    font-size: 14px;
}

.loading-spinner {
    font-size: 48px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.loading-text {
    color: #baa674;
    font-size: 16px;
}

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

@media (max-width: 1200px) {
    .directory-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .directory-sidebar {
        width: 220px;
    }
}

@media (max-width: 992px) {
    .directory-panel {
        width: 95vw;
        height: 90vh;
    }

    .directory-panel-content {
        flex-direction: column;
    }

    .directory-sidebar {
        width: 100%;
        max-height: 200px;
    }

    .directory-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .directory-tabs {
        flex-wrap: wrap;
    }

    .directory-tab {
        flex: 1 1 45%;
    }
}

@media (max-width: 768px) {
    .directory-panel-title {
        font-size: 22px;
    }

    .directory-toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .directory-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .card-image {
        height: 140px;
    }

    .tab-text {
        display: none;
    }

    .directory-tab {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .directory-panel {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        max-width: none;
        max-height: none;
    }

    .directory-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}
