/* Playground-specific styles */

.playground-flex-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Fill the main container */
    min-height: 0;
}

/* New Two-Column Layout */
.playground-flex-container .row {
    flex-grow: 1;
    min-height: 0; /* Prevents overflow issues in flex children */
}

.col-lg-9 {
    display: flex;
    flex-direction: column;
}

.graph-panel {
    flex-grow: 1; /* Make graph panel fill vertical space */
    position: relative;
    height: 600px;
    background-color: #1b2735;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#refresh-layout-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
}

#cy, #graph-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

#graph-container {
    display: none;
}

#cy.active, #graph-container.active {
    display: block !important;
}

/* General Control Panel Styling */
.control-panel {
    background-color: rgba(27, 39, 53, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.control-panel h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

/* Control rows and inputs */
.control-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.control-label {
    font-weight: 500;
    flex-basis: 80px; /* Consistent label width */
}

.control-input {
    flex-grow: 1;
    background: rgba(33, 37, 41, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    width: auto;
}

.control-input:focus {
    outline: none;
    border-color: rgba(71, 118, 230, 0.8);
    box-shadow: 0 0 0 2px rgba(71, 118, 230, 0.3);
}

.btn-group .btn,
.control-row .btn {
    flex-grow: 1;
}

/* Override some old styles */
#saveGraphModal .form-check-label {
    padding-left: 0.5em;
    line-height: 1.2em;
}

/* Mobile-specific layout ordering */
@media (max-width: 991px) {
    .playground-flex-container .row {
        display: flex;
        flex-direction: column;
        align-items: center; /* Center all children horizontally */
        gap: 1rem; /* Consistent spacing between all sections */
    }
    
    /* Left column controls container - will be split */
    .col-lg-3 {
        display: contents; /* Remove wrapper, let children participate in parent flex */
    }
    
    /* Right column - graph visualization */
    .col-lg-9 {
        order: 2; /* Graph appears second */
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        margin-bottom: 0; /* Remove bottom margin, handled by gap */
    }
    
    /* Graph Elements - order 1 (at top) */
    .col-lg-3 > .control-panel:nth-child(1) {
        order: 1;
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
    }
    
    /* Algorithms - order 3 (after graph visualization) */
    .col-lg-3 > .control-panel:nth-child(2) {
        order: 3;
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
    }
    
    /* Save & Load - order 4 (at bottom) */
    .col-lg-3 > .control-panel:nth-child(3) {
        order: 4;
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
    }
    
    /* Force Graph Controls - order 5 (after Save & Load when visible) */
    .col-lg-3 > .control-panel:nth-child(4) {
        order: 5;
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
    }
    
    /* Ensure control panels don't have individual margins on mobile */
    .control-panel {
        margin-bottom: 0 !important; /* Remove individual margins, handled by parent gap */
    }
    
    /* Graph panel should still have full width */
    .graph-panel {
        width: 100%;
    }
}

/* Extra small mobile devices - tighter layout */
@media (max-width: 576px) {
    .col-lg-3 {
        max-width: 100%; /* Use full width on small phones */
        padding: 0 0.5rem; /* Add small horizontal padding */
    }
    
    .playground-flex-container .row {
        gap: 0.75rem; /* Slightly reduce gap on very small screens */
    }
    
    .col-lg-3 {
        gap: 0.75rem; /* Match parent gap */
    }
}

/* Instruction Cards Styling */
.card {
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    border-radius: 12px;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15) !important;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #f0f0f0;
}

.card-body ul {
    padding-left: 1.25rem;
}

.card-body ul li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.card-body ul li strong {
    font-weight: 600;
}

/* Adjacency Matrix Styling */
#adjacency-matrix-text,
#incidence-matrix-text,
#edge-list-text {
    background-color: #f8f9fa !important;
    color: #000000 !important;
    border: 2px solid #dee2e6 !important;
    resize: vertical;
    padding: 1rem !important;
    line-height: 1.6 !important;
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 0.95rem !important;
    font-weight: 500 !important;
}
