/* Deck Sync Page Styles */

.sync-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.sync-header {
    margin-bottom: 2rem;
}

.sync-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sync-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.sync-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.sync-controls-compact {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    justify-content: flex-end;
}

.refresh-btn-small {
    padding: 0.5rem 1rem;
    background: rgba(138, 43, 226, 0.2);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(138, 43, 226, 0.4);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn-small:hover {
    background: rgba(138, 43, 226, 0.3);
    border-color: rgba(138, 43, 226, 0.6);
    transform: translateY(-1px);
}

.refresh-btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#syncButton {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#syncButton:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

#syncButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#syncStatus {
    font-size: 0.95rem;
    color: rgba(255, 215, 0, 0.9);
}

/* Player Sync Section */
.player-sync-section {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.player-sync-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(138, 43, 226, 0.2);
}

.player-sync-header h3 {
    font-size: 1.5rem;
    color: rgba(138, 43, 226, 1);
}

.sync-stats {
    display: flex;
    gap: 0.75rem;
}

.stat-badge {
    padding: 0.4rem 0.8rem;
    background: rgba(138, 43, 226, 0.2);
    border-radius: 6px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
}

.stat-badge.match-rate {
    background: rgba(0, 255, 0, 0.2);
    color: rgba(0, 255, 0, 0.9);
    font-weight: 600;
}

/* Match Groups */
.match-group {
    margin-bottom: 1.5rem;
}

.match-group:last-child {
    margin-bottom: 0;
}

.match-title {
    font-size: 1.1rem;
    color: rgba(255, 215, 0, 1);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.match-title.warning {
    color: rgba(255, 165, 0, 1);
}

/* Match Items */
.match-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.match-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(138, 43, 226, 0.1);
    border: 1px solid rgba(138, 43, 226, 0.2);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.match-item:hover {
    background: rgba(138, 43, 226, 0.15);
    border-color: rgba(138, 43, 226, 0.4);
}

.match-item.unmatched {
    background: rgba(255, 165, 0, 0.1);
    border-color: rgba(255, 165, 0, 0.2);
}

.match-item.unmatched:hover {
    background: rgba(255, 165, 0, 0.15);
    border-color: rgba(255, 165, 0, 0.4);
}

.match-info {
    flex: 1;
}

.commander-name {
    font-weight: 600;
    font-size: 1rem;
    color: rgba(255, 215, 0, 1);
    margin-bottom: 0.25rem;
}

.deck-name {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.commander-hint {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    margin-top: 0.25rem;
}

.deck-link {
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.deck-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Commander Chips */
.commander-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.commander-chip {
    padding: 0.5rem 1rem;
    background: rgba(138, 43, 226, 0.2);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 20px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Deck Actions */
.deck-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.show-cards-btn {
    padding: 0.5rem 1rem;
    background: rgba(138, 43, 226, 0.3);
    color: white;
    border: 1px solid rgba(138, 43, 226, 0.5);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.show-cards-btn:hover {
    background: rgba(138, 43, 226, 0.5);
    transform: translateY(-2px);
}

/* Deck Cards Display */
.deck-cards-container {
    margin: 0.75rem 0 0 0;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(138, 43, 226, 0.2);
    border-radius: 8px;
}

.deck-cards-header h5 {
    color: rgba(255, 215, 0, 1);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.cards-loading, .cards-error {
    padding: 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

.cards-error {
    color: rgba(255, 100, 100, 1);
}

/* Card Stack Container */
.card-stack-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1rem 0;
    margin: 0 -1rem;
    padding: 1rem;
}

.card-stack {
    position: relative;
    display: flex;
    height: 200px;
    min-width: min-content;
    padding-left: 20px;
}

.stacked-card {
    position: absolute;
    height: 200px;
    width: auto;
    border-radius: 8px;
    border: 2px solid rgba(138, 43, 226, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
    left: calc(var(--card-index) * 12px);
    z-index: var(--card-index);
}

.stacked-card:hover {
    transform: translateY(-30px) scale(1.15);
    z-index: 9999 !important;
    border-color: rgba(255, 215, 0, 0.8);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
    .sync-container {
        padding: 1rem;
    }
    
    .player-sync-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .sync-stats {
        flex-wrap: wrap;
    }
    
    .match-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .deck-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .show-cards-btn,
    .deck-link {
        align-self: stretch;
        text-align: center;
        width: 100%;
    }
    
    .stacked-card {
        height: 150px;
        left: calc(var(--card-index) * 8px);
    }
    
    .card-stack {
        height: 150px;
    }
}

/* Analysis Section */
.analysis-section {
    border-top: 2px solid rgba(138, 43, 226, 0.3);
    padding-top: 2rem;
}

#analyzeButton {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#analyzeButton:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(245, 87, 108, 0.4);
}

#analyzeButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#analysisStatus {
    font-size: 0.95rem;
    color: rgba(255, 215, 0, 0.9);
}

/* Analysis Tabs */
.analysis-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid rgba(138, 43, 226, 0.3);
}

.analysis-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.analysis-tab:hover {
    color: rgba(255, 255, 255, 0.9);
}

.analysis-tab.active {
    color: #f5576c;
    border-bottom-color: #f5576c;
}

/* Deck Rankings */
.deck-rankings {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.deck-rank-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.deck-rank-item:hover {
    border-color: rgba(245, 87, 108, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(245, 87, 108, 0.2);
}

.deck-rank-card-image {
    flex-shrink: 0;
    width: 120px;
    height: 167px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    position: relative;
}

.deck-rank-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.deck-owner-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.9) 100%);
    color: #fff;
    padding: 8px 6px 6px 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    border-radius: 0 0 8px 8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.deck-rank-info {
    flex: 1;
}

.deck-rank-name {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.deck-rank-name strong {
    font-size: 1.1rem;
    color: #f5576c;
}

.deck-subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.deck-rank-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stat-pill {
    padding: 0.35rem 0.75rem;
    background: rgba(138, 43, 226, 0.2);
    border-radius: 20px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
}

.deck-link {
    padding: 0.5rem 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.deck-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Player Staples */
.player-staples-section {
    margin-bottom: 2rem;
}

.player-staples-section h4 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #f5576c;
}

.staples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

.staple-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.staple-card:hover {
    border-color: rgba(245, 87, 108, 0.5);
    transform: translateY(-2px);
}

.staple-name {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.25rem;
}

.staple-count {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

/* Update Analysis Button */
#updateAnalysisButton {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#updateAnalysisButton:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

#updateAnalysisButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Analysis Summary */
.analysis-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-stat {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: #f5576c;
    margin-bottom: 0.5rem;
}

.summary-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

/* Mana Curve Mini */
.mana-curve-mini {
    display: flex;
    gap: 4px;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(138, 43, 226, 0.2);
}

.curve-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 60px;
    justify-content: flex-end;
}

.curve-fill {
    width: 100%;
    min-height: 3px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px 2px 0 0;
    transition: height 0.3s ease;
}

.curve-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Staples with Card Images */
.staples-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.staple-card-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.card-stack-wrapper {
    position: relative;
    width: 160px;
    height: 220px;
}

.staple-card-img {
    position: absolute;
    width: 160px;
    height: 220px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    left: calc(var(--stack-index) * 8px);
    top: calc(var(--stack-index) * 8px);
    z-index: calc(10 - var(--stack-index));
}

.staple-card-item:hover .staple-card-img {
    transform: translateY(-8px) rotate(calc(var(--stack-index) * 3deg));
}

.staple-info {
    text-align: center;
}

.staple-info .staple-name {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.25rem;
}

.staple-info .staple-count {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

/* Meta Insights */
.meta-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.meta-card-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(138, 43, 226, 0.2);
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.meta-card-item:hover {
    border-color: rgba(102, 126, 234, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.meta-card-image-wrapper {
    width: 100%;
    aspect-ratio: 5 / 7;
    overflow: hidden;
    border-radius: 8px;
}

.meta-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.meta-card-item:hover .meta-card-img {
    transform: scale(1.05);
}

.meta-card-info {
    text-align: center;
    width: 100%;
}

.meta-card-name {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.meta-card-count {
    color: #f5576c;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Player Averages */
.player-averages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.avg-stat {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

/* Commander Names on Cards */
.staple-commanders {
    color: rgba(255, 215, 0, 0.8);
    font-size: 0.75rem;
    margin-top: 0.5rem;
    line-height: 1.4;
    max-width: 200px;
    text-align: center;
}

/* Common Staples Section */
.common-staples-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(138, 43, 226, 0.2);
}

.common-staples-section h5 {
    color: rgba(255, 215, 0, 0.8);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.common-staples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
}

.common-staple-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.common-staple-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.common-staple-img {
    width: 60px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.common-staple-info {
    text-align: center;
}

.common-staple-name {
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.15rem;
}

.common-staple-count {
    font-size: 0.65rem;
    color: rgba(255, 215, 0, 0.7);
}

/* Player Averages Styling */
.others-avg {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.5);
    font-weight: normal;
}

/* Elimination Method Highlighting */
.kill-card {
    position: relative;
    border: 2px solid rgba(255, 50, 50, 0.6) !important;
    box-shadow: 0 0 15px rgba(255, 50, 50, 0.4);
}

.kill-card:hover {
    border-color: rgba(255, 50, 50, 0.9) !important;
    box-shadow: 0 0 20px rgba(255, 50, 50, 0.6);
}

.kill-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 50, 50, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Analysis responsive */
@media (max-width: 768px) {
    .deck-rank-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .deck-rank-card-image {
        width: 100%;
        height: auto;
        max-width: 200px;
        align-self: center;
    }
    
    .deck-link {
        align-self: stretch;
        text-align: center;
    }
    
    .staples-grid {
        grid-template-columns: 1fr;
    }
    
    .staples-grid-cards {
        grid-template-columns: 1fr;
    }
    
    .meta-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    .analysis-summary {
        grid-template-columns: 1fr;
    }
    
    .common-staples-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .player-averages {
        flex-direction: column;
    }
}

/* Category Card Tooltip */
.category-tooltip {
    display: none;
    position: fixed;
    z-index: 10000;
    background: rgba(20, 20, 20, 0.98);
    border: 2px solid rgba(184, 134, 11, 0.6);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    max-width: 400px;
    max-height: 500px;
    overflow-y: auto;
}

.category-tooltip.active {
    display: block;
}

.category-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(184, 134, 11, 0.3);
}

.category-tooltip-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(184, 134, 11, 1);
}

.category-tooltip-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.category-tooltip-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.category-tooltip-cards {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-tooltip-card-item {
    padding: 0.5rem 0.75rem;
    margin: 0.25rem 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.category-tooltip-card-item:hover {
    background: rgba(184, 134, 11, 0.2);
    transform: translateX(3px);
}

.stat-pill.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.stat-pill.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(184, 134, 11, 0.3);
}
