/* Market Detail Modal Styles */

.market-detail-modal-content {
    background: rgba(20, 20, 28, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 1.5rem;
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    color: var(--txt);
    position: relative;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal:not(.hidden) .market-detail-modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Header Section */
.md-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.md-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.md-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.md-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.md-title-group {
    display: flex;
    flex-direction: column;
}

.md-name {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 0.1rem;
    background: linear-gradient(to right, #fff, #ccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.md-symbol {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.md-close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--muted);
    width: 32px;
    height: 32px;
    min-width: 32px;
    /* Prevent shrinking */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: none;
    /* Prevent growing/shrinking from global button styles */
    padding: 0;
    /* Reset padding */
    line-height: 1;
}

.md-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: rotate(90deg);
}

/* Price Section */
.md-price-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.md-price-group {
    display: flex;
    flex-direction: column;
}

.md-price {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
    color: #fff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
}

.md-change {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.3rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.md-change.positive {
    color: #34D399;
}

.md-change.negative {
    color: #F87171;
}

/* Timeframe Controls */
.md-controls {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.timeframe-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeframe-btn:hover {
    color: var(--txt);
}

.timeframe-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Chart Container */
.md-chart-container {
    height: 240px;
    width: 100%;
    position: relative;
    margin-bottom: 1.5rem;
    mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
}

/* Stats Grid */
.md-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.md-stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.md-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.md-stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--txt);
    font-variant-numeric: tabular-nums;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .market-detail-modal-content {
        padding: 1.5rem;
        /* Padding top for safe area/notch protection */
        padding-top: max(1.5rem, env(safe-area-inset-top));

        width: 92%;
        /* Little gap on sides */
        height: auto;
        max-height: 80vh;
        /* Don't be too tall */

        /* Reset positioning to be centered by flex parent */
        position: relative;
        bottom: auto;
        border-radius: 24px;
        /* Fully rounded again */
        max-width: none;
        margin: auto;
        /* Help centering */

        /* Better scrolling */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Center alignment for mobile */
    .modal:not(.hidden) {
        align-items: center;
        /* Center vertically */
        padding: 1rem;
        /* Gap from screen edges */
    }

    .md-header {
        margin-bottom: 1.5rem;
        /* Sticky header nice to have but optional if height is constrained */
        position: sticky;
        top: -1.5rem;
        /* Negative offset to stick at very top including padding */
        padding-top: 1.5rem;
        /* Matches container padding */
        background: rgba(20, 20, 28, 0.95);
        /* Opaque bg to hide content behind */
        z-index: 10;
        margin-top: -1.5rem;
        /* Pull back up */
        padding-bottom: 0.5rem;
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .md-price {
        font-size: 2rem;
    }

    .md-price-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .md-controls {
        width: 100%;
        justify-content: space-between;
    }

    .timeframe-btn {
        flex: 1;
    }

    .md-chart-container {
        height: 200px;
    }

    .md-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}