/* ==========================================================================
   METAGRAPH TAB STYLES
   Hero Meta Graph - Counter visualization tool
   All classes prefixed with 'mg-' to avoid conflicts
   ========================================================================== */

/* Main container */
.mg-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a2e 50%, #16213e 100%);
    overflow: hidden;
}

/* Header */
.mg-header {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border-bottom: 2px solid #c9302c;
    box-shadow: 0 2px 10px rgba(201, 48, 44, 0.3);
}

.mg-header h1 {
    color: #c9302c;
    font-size: 1.4em;
    margin-bottom: 8px;
    text-align: center;
    text-shadow: 0 0 10px rgba(201, 48, 44, 0.5);
}

.mg-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mg-control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.mg-input-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mg-compact-btn {
    padding: 6px 12px;
    background: rgba(201, 48, 44, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s ease;
}

.mg-compact-btn:hover {
    background: rgba(201, 48, 44, 1);
    transform: translateY(-1px);
}

.mg-compact-dropdown {
    min-width: 120px;
    max-width: 150px;
    padding: 6px 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    font-size: 12px;
}

.mg-compact-dropdown option {
    background: #1a1a2e;
    color: #e0e0e0;
}

.mg-compact-input {
    min-width: 100px;
    max-width: 120px;
    padding: 6px 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    font-size: 12px;
}

.mg-counters-text {
    color: #c9302c;
    font-weight: bold;
    font-size: 16px;
}

.mg-delete-btn {
    background: linear-gradient(45deg, #dc3545, #c82333) !important;
}

.mg-delete-btn:hover {
    background: linear-gradient(45deg, #c82333, #dc3545) !important;
}

/* Patch Controls */
.mg-patch-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Meta Controls */
.mg-meta-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
}

.mg-meta-toggle-btn {
    padding: 8px 16px;
    background: rgba(147, 112, 219, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.mg-meta-toggle-btn:hover {
    background: rgba(147, 112, 219, 1);
}

.mg-meta-panel {
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #9370db;
    border-radius: 8px;
    padding: 15px;
    min-width: 300px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.mg-meta-panel.hidden {
    display: none;
}

.mg-meta-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 15px;
    max-height: 250px;
    overflow-y: auto;
}

.mg-meta-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    font-size: 12px;
}

.mg-meta-checkbox-item input[type="checkbox"] {
    accent-color: #9370db;
}

.mg-meta-checkbox-item label {
    color: #e0e0e0;
    cursor: pointer;
    user-select: none;
}

.mg-meta-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    border-top: 1px solid #444;
    padding-top: 10px;
}

.mg-meta-btn {
    background: rgba(147, 112, 219, 0.8) !important;
}

.mg-meta-btn:hover {
    background: rgba(147, 112, 219, 1) !important;
}

/* Meta View Controls */
.mg-meta-view-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mg-meta-view-btn {
    padding: 6px 10px;
    background: rgba(100, 149, 237, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.mg-meta-view-btn:hover {
    background: rgba(100, 149, 237, 1.0);
    transform: translateY(-1px);
}

.mg-meta-view-btn.active {
    background: rgba(65, 105, 225, 1.0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Meta Save Controls */
.mg-meta-save-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mg-analyze-btn {
    background: rgba(255, 193, 7, 0.8) !important;
    color: #000 !important;
}

.mg-analyze-btn:hover {
    background: rgba(255, 193, 7, 1) !important;
}

/* Main Content */
.mg-main-content {
    flex: 1;
    position: relative;
    padding: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
    display: block;
}

/* Canvas Container */
.mg-canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    background: radial-gradient(circle at center, #1b1b24 0%, #0b0b12 100%);
    overflow: hidden;
}

#metagraphCanvas {
    display: block;
    background: radial-gradient(circle at center, #1a1a2e 0%, #0f0f0f 100%);
    cursor: grab;
    width: 100%;
    height: 100%;
}

#metagraphCanvas:active {
    cursor: grabbing;
}

/* Canvas Controls */
.mg-canvas-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mg-zoom-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mg-zoom-controls button {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(201, 48, 44, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.mg-zoom-controls button:hover {
    background: rgba(201, 48, 44, 1);
}

.mg-canvas-info {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: #ccc;
    text-align: center;
}

/* Analysis Modal */
.mg-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

.mg-modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 0;
    border: 2px solid #c9302c;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(201, 48, 44, 0.5);
}

.mg-modal-header {
    padding: 20px;
    border-bottom: 2px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px 10px 0 0;
}

.mg-modal-header h2 {
    color: #c9302c;
    margin: 0;
    font-size: 20px;
}

.mg-close-btn {
    background: none !important;
    border: none !important;
    color: #c9302c !important;
    font-size: 28px !important;
    cursor: pointer;
    padding: 0 !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
}

.mg-close-btn:hover {
    background: rgba(201, 48, 44, 0.2) !important;
}

.mg-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    color: #e0e0e0;
}

.mg-analysis-section {
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #c9302c;
}

.mg-analysis-section h3 {
    color: #c9302c;
    margin-bottom: 10px;
    font-size: 16px;
}

/* Responsive */
@media (max-width: 1200px) {
    .mg-control-row {
        flex-wrap: wrap;
    }

    .mg-meta-view-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .mg-header h1 {
        font-size: 1.4em;
    }

    .mg-controls {
        gap: 6px;
    }

    .mg-canvas-container {
        min-height: 400px;
    }

    .mg-meta-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 400px;
    }
}

/* ===== Issue Review Mode ===== */
.issue-review-overlay {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.review-mode-btn:hover {
    background: #059669 !important;
    transform: translateY(-2px);
    transition: all 0.2s;
}

.review-container {
    color: #e5e7eb;
}

.review-container h3 {
    color: #10b981;
    margin: 10px 0;
    font-size: 16px;
}

.detail-card {
    background: #1a1f28;
    padding: 15px;
    border-radius: 8px;
}

.detail-card p {
    margin: 5px 0;
    color: #d1d5db;
}

.review-photos img:hover {
    opacity: 0.8;
    transition: opacity 0.2s;
}

/* Ensure draft boards render correctly */
.review-draft-section .draft-board-compact {
    margin: 0 auto;
}

/* ==================== Analytics Dashboard Mobile Styles ==================== */

/* Issue Gallery - Mobile: stack everything vertically */
@media (max-width: 768px) {
    .gallery-issue-info,
    .analytics-gallery-header .gallery-issue-info {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: flex-start !important;
        padding: 0 !important;
    }

    .gallery-issue-meta {
        flex: none !important;
        width: 100% !important;
    }

    .gallery-draft-boards,
    .gallery-draft-boards-inner {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
        flex: none !important;
    }

    .gallery-draft-boards > div,
    .gallery-draft-boards-inner > div {
        width: 100% !important;
        min-width: unset !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .analytics-gallery-header {
        padding: 10px !important;
        max-height: 50vh !important;
    }

    .mistake-issue-gallery-header {
        padding: 10px !important;
        max-height: 50vh !important;
        overflow-y: auto !important;
    }
}

/* Mobile: Horizontal scrollable tabs and stacked panels */
@media (max-width: 768px) {
    /* Issues view tabs - horizontal scroll */
    .issues-view-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        padding-bottom: 8px;
        scrollbar-width: thin;
    }

    .issues-view-tabs::-webkit-scrollbar {
        height: 4px;
    }

    .issues-view-tabs::-webkit-scrollbar-thumb {
        background: #4a5568;
        border-radius: 2px;
    }

    .issues-view-tab {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 8px 14px !important;
        font-size: 13px !important;
    }
    /* Stack "By Severity" and "By Category" vertically in drill-down panel */
    .pivot-breakdown-panels {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        padding: 12px !important;
    }

    /* Player x Tournament Matrix - smaller fonts and better scrolling */
    .pivot-table-container {
        -webkit-overflow-scrolling: touch;
    }

    .pivot-table-container .detailed-pivot-table {
        font-size: 13px;
    }

    .pivot-table-container .detailed-pivot-table th,
    .pivot-table-container .detailed-pivot-table td {
        padding: 10px 12px;
        height: 44px;
        min-width: 44px;
    }

    .pivot-header-category {
        min-width: 100px;
        max-width: 120px;
        font-size: 11px;
        writing-mode: vertical-rl;
        text-orientation: mixed;
        white-space: nowrap;
        padding: 10px 6px !important;
        height: auto !important;
        max-height: 140px;
    }

    .pivot-cell {
        min-width: 44px;
        font-size: 13px;
        cursor: pointer;
        text-align: center;
        padding: 8px 6px !important;
    }

    .pivot-sticky-left {
        font-size: 12px;
        min-width: 90px !important;
        white-space: nowrap;
    }

    .pivot-sticky-right {
        font-size: 12px;
        min-width: 50px;
    }

    /* Make breakdown bars more tappable on mobile */
    .breakdown-bar-item {
        min-height: 60px;
        padding: 12px !important;
    }

    .breakdown-bar-item:active {
        background: #2d4a6f !important;
        transform: scale(0.98);
    }

    /* Pivot details box mobile adjustments */
    .pivot-details-box {
        max-height: 80vh;
        overflow-y: auto;
    }

    .pivot-details-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start !important;
    }

    .pivot-details-header h4 {
        font-size: 14px !important;
    }

    /* Issue gallery header adjustments */
    .mistake-issue-gallery-header {
        padding: 10px 12px !important;
    }

    /* Smaller navigation buttons on mobile */
    .issue-nav-btn.prev-issue,
    .issue-nav-btn.next-issue {
        width: 45px !important;
        height: 80px !important;
        font-size: 16px !important;
    }

    .issue-nav-btn.prev-issue {
        left: 50px !important;
    }

    .issue-nav-btn.next-issue {
        right: 50px !important;
    }

    /* Pivot details list items */
    .pivot-detail-item {
        padding: 12px !important;
    }

    .pivot-detail-meta {
        flex: none !important;
        width: 100% !important;
        margin-bottom: 10px;
    }

    .pivot-detail-screenshots img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Timeline Distribution - Mobile Optimizations */
    .timeline-match-label {
        width: 100px !important;
        font-size: 10px !important;
        padding: 6px 8px !important;
    }

    .timeline-match-bar {
        height: 35px !important;
    }

    .timeline-phase-label {
        font-size: 9px !important;
        padding: 2px 4px !important;
    }

    .timeline-dot {
        width: 10px !important;
        height: 10px !important;
        border-width: 1px !important;
    }

    .timeline-dot:hover {
        transform: translate(-50%, -50%) scale(2) !important;
    }

    .detailed-timeline {
        max-height: 400px;
    }

    /* Breakdowns Grid - Stack on Mobile */
    .breakdowns-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .breakdown-card {
        padding: 14px !important;
    }

    .breakdown-card h3 {
        font-size: 15px !important;
        margin-bottom: 12px !important;
    }

    /* Aggregated Bubble Timeline - Mobile */
    .aggregated-timeline-bar {
        height: 80px !important;
    }

    .aggregated-bubble {
        font-size: 10px !important;
    }

    .aggregated-bubble:hover {
        transform: translate(-50%, -50%) scale(1.4) !important;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .pivot-breakdown-panels {
        padding: 8px !important;
    }

    .pivot-header-category {
        min-width: 80px;
        max-width: 100px;
        font-size: 10px;
        max-height: 120px;
    }

    .pivot-cell {
        min-width: 40px;
        font-size: 12px;
        text-align: center;
        padding: 6px 4px !important;
    }

    .pivot-table-container .detailed-pivot-table th,
    .pivot-table-container .detailed-pivot-table td {
        padding: 8px 10px;
        height: 40px;
        min-width: 40px;
    }

    .pivot-sticky-left {
        min-width: 80px !important;
        font-size: 11px;
        white-space: nowrap;
    }

    .pivot-sticky-right {
        min-width: 40px;
        font-size: 11px;
    }

    /* Timeline - Very small screens */
    .timeline-match-label {
        width: 80px !important;
        font-size: 9px !important;
        padding: 4px 6px !important;
    }

    .timeline-match-bar {
        height: 30px !important;
    }

    .timeline-phase-label {
        font-size: 8px !important;
        padding: 1px 2px !important;
    }

    .timeline-dot {
        width: 8px !important;
        height: 8px !important;
    }

    .detailed-timeline {
        max-height: 300px;
    }

    /* Aggregated Bubble Timeline - Very small screens */
    .aggregated-timeline-bar {
        height: 70px !important;
    }

    .aggregated-bubble {
        font-size: 9px !important;
    }

    /* Hide game navigation buttons on very small screens */
    .mistake-issue-gallery-main > button[style*="Previous"][style*="Game"],
    .mistake-issue-gallery-main > button[style*="Next"][style*="Game"] {
        display: none !important;
    }

    .issue-nav-btn.prev-issue {
        left: 0 !important;
        border-radius: 0 6px 6px 0 !important;
    }

    .issue-nav-btn.next-issue {
        right: 0 !important;
        border-radius: 6px 0 0 6px !important;
    }

    .gallery-draft-boards > div > div,
    .gallery-draft-boards-inner > div {
        padding: 4px 6px !important;
    }

    /* Smaller hero images in gallery draft */
    .gallery-draft-boards img,
    .gallery-draft-boards-inner img {
        height: 36px !important;
    }
}

/* ============================================================================
   Hero No G Tab - Full Screen Layout
   ========================================================================== */

/* Hide all filters and stats when Hero No G tab or Issues tab is active */
.dashboard-container:has(#hero-no-g-tab.active) #global-filters-section,
.dashboard-container:has(#hero-no-g-tab.active) .stats-overview,
.dashboard-container:has(#issues-tab.active) #global-filters-section,
.dashboard-container:has(#issues-tab.active) .stats-overview {
    display: none !important;
}

#hero-no-g-tab {
    position: relative;
    width: 100%;
    height: 100vh;
    padding: 0;
    margin: 0;
}

#hero-no-g-tab iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}