/* Overlay and Modal Container */
#profile-modal.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px; /* Adiciona padding para telas pequenas */
}

#profile-modal .modal-container {
    background: #181c24;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    max-width: min(600px, calc(100vw - 40px)); /* Maior que friends modal */
    width: 100%;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    color: #fff;
    max-height: calc(100vh - 40px); /* Previne overflow vertical */
    display: flex;
    flex-direction: column;
}

#profile-modal .modal-header {
    background: #23283a;
    padding: 20px 24px 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0; /* Mantém header fixo */
}

#profile-modal .modal-title {
    font-size: 1.4rem;
    font-weight: bold;
    margin: 0;
}

#profile-modal .modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: 12px;
    transition: opacity 0.2s;
}

#profile-modal .modal-close:hover {
    opacity: 0.7;
}

#profile-modal .modal-body {
    padding: 20px 24px 0 24px;
    flex: 1;
    overflow-y: auto; /* Permite scroll no body se necessário */
    min-height: 0; /* Fix para Firefox */
}

#profile-modal .modal-footer {
    background: #23283a;
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #23283a;
    flex-shrink: 0; /* Mantém footer fixo */
}

/* Profile Container */
.profile-container {
    padding: 0;
    max-height: 65vh;
    overflow-y: auto;
}

/* Scrollbar customizada */
.profile-container::-webkit-scrollbar,
#profile-modal .modal-body::-webkit-scrollbar {
    width: 8px;
}

.profile-container::-webkit-scrollbar-track,
#profile-modal .modal-body::-webkit-scrollbar-track {
    background: #23283a;
    border-radius: 4px;
}

.profile-container::-webkit-scrollbar-thumb,
#profile-modal .modal-body::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.profile-container::-webkit-scrollbar-thumb:hover,
#profile-modal .modal-body::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Profile Header */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #23283a;
    border-radius: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Permite quebra em telas pequenas */
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #2196f3, #1976d2);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 2.5rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.profile-header-info {
    flex: 1;
    min-width: 200px;
}

.profile-display-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 0 4px 0;
    color: #fff;
}

.profile-username {
    font-size: 1rem;
    color: #94a3b8;
    margin: 0 0 12px 0;
}

.profile-level-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.level-badge {
    background: #2196f3;
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.xp-bar {
    flex: 1;
    min-width: 120px;
    height: 8px;
    background: #475569;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.xp-text {
    font-size: 0.85rem;
    color: #94a3b8;
    white-space: nowrap;
}

.profile-resources {
    display: flex;
    gap: 16px;
    align-items: center;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #2d3748;
    padding: 8px 16px;
    border-radius: 8px;
}

.resource-icon {
    font-size: 1.2rem;
}

.resource-value {
    font-weight: 600;
    font-size: 1.1rem;
}

/* Profile Tabs */
.profile-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #23283a;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #475569 #23283a;
}

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

.profile-tabs::-webkit-scrollbar-track {
    background: #23283a;
}

.profile-tabs::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 2px;
}

.tab-button {
    flex: 0 0 auto;
    min-width: fit-content;
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: #94a3b8;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-button.active {
    color: #fff;
    border-bottom: 2px solid #2196f3;
    background: rgba(33, 150, 243, 0.1);
}

.tab-button:hover:not(.active) {
    color: #cbd5e1;
}

/* Profile Content */
.profile-content {
    padding: 0 4px;
}

/* Profile Sections */
.profile-section {
    background: #23283a;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.profile-section h3 {
    font-size: 1.2rem;
    margin: 0 0 16px 0;
    color: #fff;
}

.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.info-value {
    font-size: 1rem;
    color: #fff;
    font-weight: 600;
}

.info-value.rank-diamante {
    color: #60a5fa;
}

.info-value.rank-ouro {
    color: #fbbf24;
}

.info-value.rank-prata {
    color: #e5e7eb;
}

.info-value.rank-bronze {
    color: #f59e0b;
}

.profile-bio {
    color: #cbd5e1;
    line-height: 1.6;
    margin: 0;
}

/* Quick Stats */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.stat-card {
    background: #2d3748;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: #94a3b8;
}

/* Favorite Card */
.favorite-card-display {
    background: #2d3748;
    padding: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-preview {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-icon {
    font-size: 2rem;
}

.card-name {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Stats Tab Specific */
.stats-content .stats-section {
    margin-bottom: 24px;
}

.stats-content .stats-section:last-child {
    margin-bottom: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.stat-item {
    background: #2d3748;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.stat-item .stat-label {
    display: block;
    margin-bottom: 8px;
}

.stat-item .stat-value {
    display: block;
    font-size: 1.8rem;
}

.stat-value.win {
    color: #22c55e;
}

.stat-value.loss {
    color: #ef4444;
}

.stat-value.draw {
    color: #f59e0b;
}

/* Win/Loss Chart */
.win-loss-chart {
    display: flex;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    background: #2d3748;
}

.chart-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    position: relative;
}

.chart-bar.win {
    background: #22c55e;
}

.chart-bar.loss {
    background: #ef4444;
}

.chart-bar.draw {
    background: #f59e0b;
}

.chart-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.chart-bar:hover {
    opacity: 0.9;
}

/* Performance Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.metric-item {
    background: #2d3748;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.metric-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.metric-info {
    flex: 1;
}

.metric-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
}

.metric-label {
    display: block;
    font-size: 0.85rem;
    color: #94a3b8;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.achievement-item {
    background: #2d3748;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    gap: 16px;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.achievement-item.unlocked {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.achievement-item.locked {
    opacity: 0.6;
    filter: grayscale(0.5);
}

.achievement-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.achievement-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #fff;
}

.achievement-description {
    font-size: 0.9rem;
    color: #94a3b8;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.achievement-date {
    font-size: 0.8rem;
    color: #64748b;
}

/* Match History */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.match-item {
    background: #2d3748;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.match-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.match-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 60px;
}

.result-icon {
    font-size: 1.5rem;
}

.result-text {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.match-result.win,
.match-result.victory {
    color: #22c55e;
}

.match-result.loss,
.match-result.defeat {
    color: #ef4444;
}

.match-result.draw {
    color: #f59e0b;
}

.match-details {
    flex: 1;
}

.match-opponent {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.vs-label {
    color: #64748b;
    font-size: 0.9rem;
}

.opponent-name {
    font-weight: 600;
    color: #fff;
    font-size: 1.1rem;
}

.match-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.match-score {
    text-align: center;
}

.score {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #94a3b8;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}

.empty-subtitle {
    font-size: 0.9rem;
    color: #64748b;
}

/* Error State */
.error-state {
    text-align: center;
    padding: 32px;
    color: #ef4444;
}

.error-state p {
    margin: 0 0 16px 0;
    font-size: 1.1rem;
}

.error-state button {
    padding: 10px 24px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s;
}

.error-state button:hover {
    background: #dc2626;
}

/* Modal Button */
.modal-button {
    padding: 10px 24px;
    background: #64748b;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s;
}

.modal-button:hover {
    background: #475569;
}

/* Media Queries Responsivas */
@media (max-width: 768px) {
    .profile-header {
        gap: 16px;
        padding: 16px;
    }
    
    .profile-avatar-large {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }
    
    .profile-display-name {
        font-size: 1.3rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .achievements-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    #profile-modal .modal-container {
        max-width: calc(100vw - 32px);
    }
    
    #profile-modal .modal-header,
    #profile-modal .modal-body,
    #profile-modal .modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .profile-container {
        max-height: 55vh;
    }
    
    .profile-tabs {
        gap: 0;
    }
    
    .tab-button {
        flex: 0 0 auto;
        padding: 10px 16px;
        font-size: 0.85rem;
        min-width: fit-content;
    }
    
    .profile-section {
        padding: 16px;
    }
    
    .quick-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    #profile-modal.modal-overlay {
        padding: 16px;
    }
    
    #profile-modal .modal-title {
        font-size: 1.2rem;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-resources {
        width: 100%;
        justify-content: center;
    }
    
    .profile-level-info {
        justify-content: center;
    }
    
    .xp-bar {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .achievement-item {
        flex-direction: column;
        text-align: center;
    }
    
    .match-item {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .match-details {
        width: 100%;
    }
    
    .match-opponent {
        justify-content: center;
    }
    
    .match-meta {
        justify-content: center;
    }
}

@media (max-width: 390px) {
    #profile-modal .modal-container {
        max-width: calc(100vw - 24px);
    }
    
    .profile-display-name {
        font-size: 1.1rem;
    }
    
    .profile-username {
        font-size: 0.9rem;
    }
    
    .resource-item {
        padding: 6px 12px;
    }
    
    .resource-value {
        font-size: 1rem;
    }
    
    .modal-button {
        padding: 8px 20px;
        font-size: 0.9rem;
    }
    
    .tab-button {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-width: fit-content;
    }
}

/* Landscape mode - telas pequenas */
@media (max-height: 500px) and (orientation: landscape) {
    #profile-modal.modal-overlay {
        padding: 10px;
    }
    
    #profile-modal .modal-container {
        max-height: calc(100vh - 20px);
    }
    
    .profile-container {
        max-height: 45vh;
    }
    
    #profile-modal .modal-header {
        padding-top: 12px;
        padding-bottom: 8px;
    }
    
    .profile-header {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .profile-avatar-large {
        width: 56px;
        height: 56px;
        font-size: 1.8rem;
    }
    
    .profile-display-name {
        font-size: 1.2rem;
    }
    
    .profile-section {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .profile-section h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
    
    .empty-state {
        padding: 24px;
    }
}

/* Landscape tablets */
@media (max-height: 600px) and (min-width: 768px) and (orientation: landscape) {
    .profile-container {
        max-height: 50vh;
    }
    
    .profile-header {
        flex-direction: row;
        gap: 20px;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Ultra wide screens */
@media (min-width: 1400px) {
    #profile-modal .modal-container {
        max-width: 800px;
    }
    
    .achievements-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}