:root{
    --lb-overlay: rgba(0,0,0,0.75);
    --lb-bg: #fff;
    --lb-radius: 8px;
}

.challenge-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.challenge-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.challenge-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--lb-overlay);
    backdrop-filter: blur(2px);
}

.challenge-modal-content {
    position: relative;
    width: 75%;
    height: 90%;
    background: var(--lb-bg);
    border-radius: var(--lb-radius);
    z-index: 1001;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.challenge-modal-body {
    display: flex;
    height: 100%;
}

.challenge-details {
    width: 28%;
    padding: 2rem;
    border-right: 1px solid #eee;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 1.5rem;  /* Add space between flex items */
}

.challenge-description {
    flex: 1;  /* Allow description to take remaining space */
    overflow-y: auto;  /* Enable scrolling for long descriptions */
    margin: 0;  /* Remove default margins */
}

.challenge-workspace {
    width: 72%;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

#monaco-editor {
    height: 70%;
    border-bottom: 1px solid #eee;
    border-radius: 4px;  /* Optional: adds rounded corners */
    margin-bottom: 1rem;  /* Add some space between editor and output panel */
}

.output-panel {
    height: 30%;
    background: #f8f8f8;
    padding: 1rem;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.run-button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.run-button:hover {
    background: #45a049;
}

.challenge-output-panel {
    display: flex;
    flex-direction: column;
    background: #f8f8f8;
    height: 30%;  /* Keep existing height */
}

.challenge-output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 15%;  /* Take 15% of panel height */
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;  /* Prevent header from shrinking */
}

#output {
    height: 85%;
    margin: 0;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre-wrap;       /* Wrap on line breaks and spaces */
    word-wrap: break-word;       /* Break long words if needed */
    font-family: monospace;
    background: #f8f8f8;
    font-size: 0.9rem;
    line-height: 1.4;
}

.challenge-controls {
    display: flex;
    gap: .5rem;
}

.challenge-run-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
   
    background: #00bf63;
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
}

.challenge-run-button:hover {
    background: #ff6500;
}

.challenge-run-button i {
    font-size: 1rem;
    color: inherit;
}

.challenge-run-button.disabled i {
    opacity: 0.5;
}

.challenge-save-button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    
    background: #666;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.challenge-save-button:hover {
    background: #777;
}

.challenge-save-button.disabled {
    background: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

.challenge-save-button.saving {
    opacity: 0.7;
    cursor: wait;
}

.challenge-save-button.saved {
    background: #00bf63;
}

.challenge-save-button .pro-icon {
    position: absolute;
    left: -12px;        /* Move icon to the left edge */
    top: -12px;         /* Move icon to the top edge */
    color: #FFD700;
    font-size: 1.2rem;
    background: #ffffff;
    border-radius: 50%;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pro-tooltip {
    position: absolute;
    background: #2d2d2d;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 1000;
    pointer-events: none;
}

.pro-tooltip::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid #2d2d2d;
}

.challenge-modal-close {
    position: absolute;
    top: .05rem;
    right: .25rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1002;
}

.hint-button {
    margin-top: auto;  /* Push to bottom */
    margin-bottom: 4rem;  /* Add some bottom space */
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    background: #00bf63;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hint-button:hover:not(.disabled) {
    background: #ff6500;
}

.hint-button i {
    color: #fff;
}

.modal-challenge-title-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Push items to edges */
    gap: 1rem;
    width: 100%; /* Ensure full width */
}

.modal-challenge-title-wrapper h2 {
    margin: 0;
    flex: 1; /* Allow title to take remaining space */
}

.modal-challenge-points {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    background: #e0f7e0;
    color: #2c662d;
    font-weight: 500;
    white-space: nowrap;
    margin-left: auto; /* Push to the right */
}

.modal-challenge-points i {
    color: #ffd700;
}

.upgrade-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.upgrade-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.upgrade-button i {
    color: #000;
    font-size: 1.1em;
}

/* Show upgrade button only for non-pro users */
.pro .upgrade-button {
    display: none;
}

.completion-popup {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 191, 99, 0.95);
    color: white;
    padding: 1.5rem 2.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    opacity: 0;
    animation: fadeInOut 2.5s ease-in-out forwards;
}

.completion-popup i {
    font-size: 1.5rem;
}

.completion-popup .points-star {
    color: #FFD700;
    margin-left: 0.25rem;
}

.challenge-meta-tab {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f7f7f7;
    border-bottom: 1px solid #e0e0e0;
    padding: 0.5rem 1rem;
    height: 20px;
    margin-bottom: 1rem;  /* Add spacing below the meta tab */
}

.challenge-meta-tab .meta-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.challenge-meta-tab .meta-label {
    font-weight: 500;
    color: #555;
    font-size: 0.9rem;
}

#gpu-select {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

#gpu-select:hover {
    border-color: #00bf63;
}

#gpu-select:focus {
    outline: none;
    border-color: #00bf63;
    box-shadow: 0 0 0 2px rgba(0, 191, 99, 0.1);
}

.challenge-meta-tab .meta-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.challenge-meta-tab .stat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    color: #333;
}

.challenge-meta-tab .stat-item i {
    color: #00bf63;
    font-size: 1rem;
}

.challenge-meta-tab .stat-item .fa-infinity {
    color: #666; /* Gray color for infinity */
}

.challenge-meta-tab .stat-item i.fa-lightbulb {
    color: #ffd700; /* Gold color for hints */
}

.challenge-meta-tab .stat-item i.fa-code {
    color: #00bf63; /* Green color for submissions */
}

@media (max-width: 768px) {
    .challenge-meta-tab {
        flex-direction: column;
        height: auto;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }
    
    .challenge-meta-tab .meta-right {
        width: 100%;
        justify-content: flex-end;
    }
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -40%); }
    20% { opacity: 1; transform: translate(-50%, -50%); }
    80% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -60%); }
}