/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

code {
    background-color: #f1f3f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Info Section */
.info-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.description p {
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

.info-box {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.info-box strong {
    color: #856404;
}

.info-box a {
    color: #0066cc;
    text-decoration: underline;
}

/* Main Container */
.main-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    gap: 2rem;
    padding: 0 1rem;
    min-height: calc(100vh - 200px);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 2rem;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 0.5rem;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

select:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    margin: 0.25rem;
    width: 100%;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover {
    background-color: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3);
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

/* Rules List */
.rules-list {
    padding-left: 1.5rem;
}

.rules-list li {
    margin-bottom: 0.75rem;
}

.rules-list ul {
    margin-top: 0.5rem;
    padding-left: 1rem;
}

.rules-list ul li {
    margin-bottom: 0.25rem;
}

/* Selected Packages */
.selected-packages {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 1rem;
    min-height: 60px;
    font-family: monospace;
    font-size: 0.9rem;
    word-break: break-all;
}

/* Main Content */
.main-content {
    flex: 1;
}

.game-area {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Graph Section */
.graph-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
}

.graph-section h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 600;
}

#graph-container {
    width: 100%;
    height: 500px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    overflow: hidden;
}

#dependency-graph {
    width: 100%;
    height: 100%;
}

/* Package Selection */
.package-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
}

.package-section h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 600;
}

.package-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.package-btn {
    padding: 0.75rem 1rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 0.95rem;
    font-family: monospace;
}

.package-btn:hover {
    border-color: #667eea;
    background-color: #f8f9ff;
    transform: translateX(4px);
}

.package-btn.selected {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}

/* .package-btn.root {
    border-color: #dc3545;
    background-color: #f8d7da;
    color: #721c24;
} */

/* Status Section */
/* .status-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.status-section h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 600;
} */

.status-message {
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
}

.status-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.status-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.status-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 1rem;
    top: 1rem;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

/* Boolean Hints */
.clause-item {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #ddd;
}

.clause-satisfied {
    background-color: #d4edda;
    border-left-color: #28a745;
}

.clause-violated {
    background-color: #f8d7da;
    border-left-color: #dc3545;
}

.clause-formula {
    font-family: monospace;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.clause-status {
    font-weight: bold;
}

.clause-status.satisfied {
    color: #155724;
}

.clause-status.violated {
    color: #721c24;
}

/* Footer */
.footer {
    background-color: #2c3e50;
    color: #ecf0f1;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
}

.footer a {
    color: #74b9ff;
    text-decoration: underline;
    font-weight: bold;
}

.footer a:hover {
    color: #0984e3;
}

/* Graph Styles */
.node {
    stroke-width: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
    fill: #ffffff; /* White fill by default */
    fill-opacity: 0.85; /* Make nodes translucent */
    stroke: #000000; /* Black border by default */
}

.node.selected {
    fill: #28a745 !important; /* Green fill for selected nodes */
}

.node.root {
    stroke: #dc3545 !important; /* Red border for root node */
    stroke-width: 3px;
}

.node:hover {
    stroke-width: 3px;
    filter: brightness(1.1);
}

.link {
    stroke: #999;
    stroke-width: 2px;
    fill: none;
    marker-end: url(#arrowhead);
}

.link.satisfied {
    stroke: #28a745;
    stroke-width: 3px;
}

.node-label {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

.node-label-group {
    pointer-events: none;
}

/* Zoom Controls */
.zoom-controls {
    position: fixed;
    z-index: 100;
}

.zoom-button:hover rect {
    fill: #e9ecef !important;
    stroke: #adb5bd !important;
}

.zoom-button:active rect {
    fill: #dee2e6 !important;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .sidebar {
        width: 100%;
        position: static;
    }
    
    .game-area {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .main-container {
        padding: 0 0.5rem;
    }
    
    .sidebar {
        padding: 1rem;
    }
    
    .graph-section,
    .package-section {
        padding: 1rem;
    }
    
    #graph-container {
        height: 400px;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 1.5rem;
        width: 95%;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 0.5rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .info-section {
        padding: 1rem 0.5rem;
    }
    
    #graph-container {
        height: 300px;
    }
    
    .modal-content {
        margin: 5% auto;
        padding: 1rem;
        width: 98%;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 1rem;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #6c757d;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab:hover {
    color: #495057;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Success celebration */
@keyframes celebration {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    50% { transform: scale(1.2) rotate(0deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

.celebration {
    animation: celebration 0.6s ease-in-out;
}
