/* 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;
    overflow: hidden;
}

#graph-container {
    display: none;
}

#graph-container svg {
    display: block;
    width: 100%;
    height: 100%;
}

#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;
}

/* Style headers and collapses */
.style-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.2s, border-color 0.2s;
}

.style-header:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.1);
}

.style-header i {
    transition: transform 0.3s ease;
}

.style-header.collapsed i {
    transform: rotate(-90deg);
}

.style-collapse {
    transition: max-height 0.3s ease-out, padding 0.3s ease;
}

/* Accordion Group Panels */
.group-header {
    user-select: none;
    transition: color 0.2s;
}

.group-header:hover {
    color: #4776E6;
}

.group-header .animate-chevron {
    transition: transform 0.3s ease;
}

.group-header.collapsed .animate-chevron {
    transform: rotate(-90deg);
}

.group-content {
    transition: max-height 0.3s ease-out, margin-top 0.3s ease;
}

/* Styled Sub-Groups (Node Settings & Edge Settings) */
.element-group {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 12px;
}

.element-group-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 6px;
    font-weight: 600;
}

/* Styling for select inputs matching dark theme */
select.control-input {
    background: rgba(33, 37, 41, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
    border-radius: 4px;
    cursor: pointer;
}

select.control-input option {
    background-color: #1a1d24 !important;
    color: #fff !important;
}

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

/* Interactive Instructions Styling */
.instructions-card {
    background: rgba(19, 23, 30, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#instructionTabs {
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 30px;
    padding: 4px;
    display: inline-flex;
    margin: 0 auto;
}

#instructionTabs .nav-item {
    margin: 0 2px;
}

#instructionTabs .nav-link {
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border-radius: 26px;
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
}

#instructionTabs .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

#instructionTabs .nav-link.active {
    color: #fff !important;
    background: linear-gradient(135deg, #4776E6 0%, #8E54E9 100%) !important;
    box-shadow: 0 4px 15px rgba(110, 68, 255, 0.3);
}

.instruction-step {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 18px 12px;
    height: 100%;
    transition: all 0.3s ease;
}

.instruction-step:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.step-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #fff;
}

.badge-blue {
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    box-shadow: 0 0 10px rgba(0, 198, 255, 0.3);
}

.badge-green {
    background: linear-gradient(135deg, #38ef7d 0%, #11998e 100%);
    box-shadow: 0 0 10px rgba(56, 239, 125, 0.3);
}

.badge-purple {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 0 10px rgba(240, 147, 251, 0.3);
}

.instruction-step h6 {
    font-size: 0.95rem;
    font-weight: 600;
}

.instruction-step p {
    font-size: 0.8rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.85) !important;
}

@media (max-width: 768px) {
    #instructionTabs {
        border-radius: 12px;
        flex-direction: column;
        width: 100%;
    }
    
    #instructionTabs .nav-link {
        border-radius: 8px;
        width: 100%;
        text-align: center;
        margin-bottom: 2px;
    }
}

/* Creation Tabs Styling */
#creationTabs {
    border: none;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 2px;
}

#creationTabs .nav-link {
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    font-size: 0.8rem;
    padding: 6px 12px;
}

#creationTabs .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

#creationTabs .nav-link.active {
    color: #fff !important;
    background: linear-gradient(135deg, #4776E6 0%, #8E54E9 100%) !important;
    box-shadow: 0 2px 8px rgba(110, 68, 255, 0.25);
}

/* Adjacency Matrix Inner Tabs */
#matrixTabs {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem !important;
}

#matrixTabs .nav-link {
    color: rgba(255, 255, 255, 0.6) !important;
    border: none !important;
    background: transparent !important;
    font-size: 0.75rem;
    padding: 6px 12px;
    border-bottom: 2px solid transparent !important;
    transition: all 0.2s ease;
}

#matrixTabs .nav-link:hover {
    color: #fff !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2) !important;
}

#matrixTabs .nav-link.active {
    color: #fff !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 2px solid #8E54E9 !important;
    font-weight: 500;
}
