/* ============================================================
   GroupInvader By System32 | Powered by CYFARE.NET
   Main Stylesheet — Refactored for Performance & Analytics
   ============================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family:
        "Segoe UI",
        system-ui,
        -apple-system,
        sans-serif;
    background: #050a14;
    color: #e2e8f0;
    overflow-x: hidden;
}

/* ---- HEADER ---- */
.header {
    background: linear-gradient(90deg, #0a1120, #0f2744);
    padding: 10px 18px;
    border-bottom: 1px solid #1e3a5f;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.header h1 {
    font-size: 16px;
    color: #f43f5e;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.header p {
    color: #64748b;
    font-size: 10px;
}

/* ---- CONTROLS ---- */
.controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
select,
button {
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
}
select:hover,
button:hover {
    border-color: #475569;
}
button.primary {
    background: linear-gradient(135deg, #f43f5e, #be123c);
    border: none;
    font-weight: 600;
    font-size: 11px;
}
button.primary:hover {
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
}
button.secondary {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    border: none;
    font-weight: 600;
    font-size: 11px;
}
button.tertiary {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    font-weight: 600;
    font-size: 11px;
}
button:active {
    transform: scale(0.96);
}

/* ---- STATS BAR ---- */
.stats-bar {
    display: flex;
    gap: 16px;
    padding: 8px 18px;
    background: rgba(10, 17, 32, 0.95);
    border-bottom: 1px solid #1e293b;
    font-size: 11px;
    flex-wrap: wrap;
}
.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
}
.stat-value {
    font-weight: 700;
    color: #f43f5e;
    font-size: 15px;
    transition: color 0.3s;
}
.stat-label {
    color: #475569;
    font-size: 10px;
}

/* ---- SKELETON ---- */
.skeleton .stat-value {
    background: #1e293b;
    color: transparent;
    border-radius: 3px;
    animation: skeletonPulse 1.5s ease-in-out infinite;
    min-width: 20px;
    display: inline-block;
}
@keyframes skeletonPulse {
    0%,
    100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.8;
    }
}

/* ---- TAB BAR ---- */
.tab-bar {
    display: flex;
    gap: 2px;
    padding: 6px 18px 0;
    background: rgba(10, 17, 32, 0.95);
    border-bottom: 1px solid #1e293b;
    overflow-x: auto;
    scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar {
    display: none;
}
.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
    padding: 8px 14px;
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.15s;
}
.tab-btn:hover {
    color: #e2e8f0;
    background: rgba(30, 41, 59, 0.4);
}
.tab-btn.active {
    color: #f43f5e;
    border-bottom-color: #f43f5e;
    background: rgba(244, 63, 94, 0.08);
}

/* ---- TAB CONTENT ---- */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active {
    display: block;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- GRAPH CONTAINER ---- */
#graph-container,
#galaxy-container,
#surface-container {
    width: 100%;
    height: calc(100vh - 165px);
    position: relative;
    cursor: grab;
}
#graph-container:active,
#galaxy-container:active,
#surface-container:active {
    cursor: grabbing;
}
#graph-container.panning {
    cursor: row-resize;
}
#graph-container.grabbing {
    cursor: grabbing;
}
#graph,
#galaxyGraph,
#surfaceGraph {
    width: 100%;
    height: 100%;
}

/* ---- LEGEND PANEL ---- */
.legend-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(5, 10, 20, 0.92);
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 12px;
    max-width: 220px;
    backdrop-filter: blur(10px);
    z-index: 100;
    font-size: 11px;
}
.legend-title {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-line {
    width: 20px;
    height: 2px;
    opacity: 0.7;
}

/* ---- TABLE PANEL ---- */
.table-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(5, 10, 20, 0.96);
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 12px;
    width: 380px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    backdrop-filter: blur(10px);
    z-index: 100;
    font-size: 11px;
    display: none;
    transition: opacity 0.2s ease;
}
.table-panel.active {
    display: block;
}
.table-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}
.panel-title {
    font-size: 12px;
    font-weight: 700;
    color: #f43f5e;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.panel-close {
    cursor: pointer;
    color: #64748b;
    font-size: 18px;
    line-height: 1;
    transition: color 0.15s;
}
.panel-close:hover {
    color: #f43f5e;
}

/* ---- FILTERS ---- */
.filter-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.filter-row select {
    flex: 1;
    min-width: 70px;
    font-size: 10px;
    padding: 4px 6px;
}
.search-box {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #334155;
    border-radius: 5px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 11px;
    margin-bottom: 6px;
    transition: border-color 0.15s;
}
.search-box:focus {
    outline: none;
    border-color: #f43f5e;
}

/* ---- TABLE ---- */
.members-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
}
.members-table th {
    text-align: left;
    padding: 6px 4px;
    color: #94a3b8;
    border-bottom: 1px solid #334155;
    font-weight: 600;
    position: sticky;
    top: 0;
    background: rgba(5, 10, 20, 0.95);
    z-index: 1;
}
.members-table th.sortable {
    cursor: pointer;
    user-select: none;
}
.members-table th.sortable:hover {
    color: #f43f5e;
}
.members-table td {
    padding: 5px 4px;
    border-bottom: 1px solid #1e293b;
    color: #cbd5e1;
    vertical-align: top;
}
.members-table tr:hover td {
    background: rgba(244, 63, 94, 0.08);
    cursor: pointer;
}
.members-table tr.pinned-row td {
    background: rgba(244, 63, 94, 0.12);
}
.members-table .poi-name {
    color: #f43f5e;
    font-weight: 600;
}
.members-table .poi-badge {
    background: #f43f5e;
    color: #fff;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
}
.members-table .pin-icon {
    color: #fbbf24;
    margin-left: 3px;
    font-size: 10px;
}
.members-table .ccount {
    color: #fbbf24;
    font-weight: 700;
}
.members-table .gcount {
    color: #38bdf8;
}
.members-table .countries {
    color: #64748b;
    font-size: 9px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Detail expand row */
.detail-row {
    background: rgba(15, 23, 42, 0.5);
}
.detail-row td {
    padding: 10px 12px;
}
.detail-content {
    font-size: 10px;
    color: #94a3b8;
    line-height: 1.6;
}
.detail-content strong {
    color: #e2e8f0;
}
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-bottom: 10px;
}
.detail-meta span {
    white-space: nowrap;
}
.detail-groups {
    border-top: 1px solid #1e293b;
    padding-top: 8px;
}
.detail-groups > strong {
    display: block;
    margin-bottom: 6px;
}
.groups-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}
.group-tag {
    display: block;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 0 4px 4px 0;
    color: #cbd5e1;
    font-size: 10px;
    line-height: 1.4;
    word-break: break-word;
    transition: background 0.12s;
}
.group-tag:hover {
    background: rgba(30, 41, 59, 0.8);
}
.copy-btn {
    display: inline;
    padding: 1px 6px;
    font-size: 9px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid #334155;
    border-radius: 3px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.12s;
    vertical-align: middle;
    margin-left: 4px;
}
.copy-btn:hover {
    border-color: #f43f5e;
    color: #f43f5e;
}

/* ---- GROUPS INSPECTOR ---- */
.groups-inspector {
    position: absolute;
    background: rgba(5, 10, 20, 0.95);
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 0;
    backdrop-filter: blur(10px);
    z-index: 110;
    font-size: 11px;
    display: none;
    min-width: 260px;
    max-width: 350px;
    max-height: 400px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}
.groups-inspector.visible {
    display: block;
}
.groups-inspector .gi-header {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.2), transparent);
    padding: 10px 12px;
    border-bottom: 1px solid #1e3a5f;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1;
}
.groups-inspector .gi-title {
    font-weight: 700;
    color: #f43f5e;
    font-size: 12px;
}
.groups-inspector .gi-close {
    cursor: pointer;
    color: #64748b;
    font-size: 16px;
    transition: color 0.15s;
}
.groups-inspector .gi-close:hover {
    color: #f43f5e;
}
.groups-inspector .gi-subtitle {
    padding: 6px 12px;
    color: #64748b;
    font-size: 10px;
    border-bottom: 1px solid #1e293b;
}
.groups-inspector .gi-scroll {
    max-height: 300px;
    overflow-y: auto;
    padding: 6px 0;
}
.groups-inspector .gi-group-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    transition: background 0.12s;
    cursor: default;
}
.groups-inspector .gi-group-row:hover {
    background: rgba(244, 63, 94, 0.06);
}
.groups-inspector .gi-group-row .gi-country-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.groups-inspector .gi-group-row .gi-group-name {
    flex: 1;
    color: #cbd5e1;
    font-size: 10px;
    line-height: 1.4;
    word-break: break-word;
}
.groups-inspector .gi-group-row .gi-country-tag {
    color: #64748b;
    font-size: 9px;
    white-space: nowrap;
}

/* ---- CONTEXT MENU ---- */
.context-menu {
    position: fixed;
    background: rgba(10, 17, 32, 0.97);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 6px 0;
    z-index: 200;
    display: none;
    min-width: 180px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
}
.context-menu.visible {
    display: block;
}
.context-menu .cm-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 11px;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}
.context-menu .cm-item:hover {
    background: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
}
.context-menu .cm-divider {
    height: 1px;
    background: #1e293b;
    margin: 4px 0;
}

/* ---- PINNED LIST ---- */
.pinned-list {
    margin-top: 10px;
    border-top: 1px solid #1e293b;
    padding-top: 8px;
    display: none;
}
.pinned-list.has-pins {
    display: block;
}
.pinned-list .pinned-header {
    font-size: 10px;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    font-weight: 700;
}
.pinned-list .pinned-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    font-size: 10px;
    color: #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s;
}
.pinned-list .pinned-item:hover {
    background: rgba(244, 63, 94, 0.1);
}
.pinned-list .pinned-item .unpin-btn {
    color: #64748b;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.12s;
}
.pinned-list .pinned-item .unpin-btn:hover {
    color: #f43f5e;
}

/* ---- ANALYTICS GRID ---- */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 14px;
    padding: 14px;
}
.chart-card {
    background: rgba(10, 17, 32, 0.7);
    border: 1px solid #1e293b;
    border-radius: 10px;
    overflow: hidden;
    backdrop-filter: blur(6px);
    transition: border-color 0.2s;
}
.chart-card:hover {
    border-color: #334155;
}
.chart-card.wide {
    grid-column: span 2;
}
.chart-card.full {
    grid-column: 1 / -1;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid #1e293b;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.chart-area {
    padding: 10px;
    min-height: 280px;
}
.export-btn {
    background: transparent;
    border: 1px solid #334155;
    color: #64748b;
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.export-btn:hover {
    border-color: #0ea5e9;
    color: #0ea5e9;
}
.table-wrap {
    padding: 0;
}

/* ---- POI EXPLORER ---- */
.poi-explorer {
    padding: 14px;
}
.explorer-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.explorer-toolbar .search-box {
    margin: 0;
    flex: 1;
    min-width: 180px;
}

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    padding: 14px;
    flex-wrap: wrap;
}
.pagination button {
    min-width: 32px;
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 5px;
    background: #0f172a;
    border: 1px solid #334155;
    color: #94a3b8;
}
.pagination button:hover {
    border-color: #475569;
    color: #e2e8f0;
}
.pagination button.active {
    background: linear-gradient(135deg, #f43f5e, #be123c);
    border-color: #f43f5e;
    color: #fff;
    font-weight: 700;
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination .page-info {
    color: #64748b;
    font-size: 11px;
    padding: 0 8px;
}

/* ---- MODAL ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}
.modal.show {
    display: flex;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: rgba(10, 17, 32, 0.98);
    border: 1px solid #334155;
    border-radius: 12px;
    width: 90%;
    max-width: 560px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.modal-header input {
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 14px;
    padding: 4px 0;
    outline: none;
    width: 100%;
}
.modal-header input::placeholder {
    color: #475569;
}
.modal-hint {
    font-size: 10px;
    color: #475569;
}
.modal-results {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
}
.modal-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid rgba(30, 41, 59, 0.4);
}
.modal-result-item:hover {
    background: rgba(244, 63, 94, 0.1);
}
.modal-result-item .r-name {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
}
.modal-result-item .r-meta {
    font-size: 10px;
    color: #64748b;
}
.modal-result-item .r-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(244, 63, 94, 0.2);
    color: #f43f5e;
    font-weight: 700;
}

/* ---- TOAST ---- */
#toastContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 600;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: rgba(10, 17, 32, 0.96);
    border: 1px solid #334155;
    border-left: 3px solid #0ea5e9;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 12px;
    color: #e2e8f0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.3s ease;
    max-width: 320px;
    backdrop-filter: blur(8px);
}
.toast.success {
    border-left-color: #10b981;
}
.toast.error {
    border-left-color: #f43f5e;
}
.toast.warning {
    border-left-color: #fbbf24;
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ---- CHART LOADING OVERLAYS ---- */
.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    gap: 14px;
    color: #64748b;
    font-size: 12px;
    animation: fadeIn 0.3s ease;
}
.chart-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #1e293b;
    border-top-color: #f43f5e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .table-panel {
        width: 92%;
        left: 4%;
        top: 6px;
    }
    .header h1 {
        font-size: 13px;
    }
    .stats-bar {
        gap: 10px;
        font-size: 10px;
    }
    .stat-value {
        font-size: 12px;
    }
    .analytics-grid {
        grid-template-columns: 1fr;
        padding: 8px;
    }
    .chart-card.wide,
    .chart-card.full {
        grid-column: span 1;
    }
    .explorer-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .explorer-toolbar .search-box {
        width: 100%;
    }
    .tab-btn {
        padding: 6px 10px;
        font-size: 10px;
    }
    .legend-panel {
        max-width: 160px;
        padding: 8px;
        font-size: 9px;
        top: 8px;
        right: 8px;
    }
}
