:root {
    --primary-color: #4361ee;
    --primary-dark: #3a0ca3;
    --secondary-color: #4cc9f0;
    --accent-color: #f72585;
    --success-color: #2ecc71;
    --warning-color: #f1c40f;
    --text-color: #2b2d42;
    --text-light: #8d99ae;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --border-radius: 12px;
    --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Inter', sans-serif;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    /* Removed fixed height to allow scrolling */
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--primary-dark);
    margin-top: 0;
}

.container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    padding: 30px;
    /* Use auto height */
    height: auto;
    max-width: 1600px;
    margin: 0 auto;
}

@media (max-width: 1440px) {
    .container {
        padding: 15px;
        /* Reduced padding for laptops */
        gap: 20px;
        grid-template-columns: 300px 1fr;
        /* Slightly narrower sidebar */
    }
}

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        height: auto;
        padding: 15px;
        /* consistent small padding */
    }
}

/* Header */
header {
    background: var(--card-bg);
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Sidebar / Input Section */
aside {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: fit-content;
    max-height: 100%;
    overflow-y: auto;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

input[type="number"],
input[type="text"] {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition);
}

input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.btn-group {
    display: flex;
    flex-direction: column;
    /* Stack buttons vertically */
    gap: 10px;
}

button {
    padding: 8px 16px;
    /* Smaller padding */
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
    font-size: 0.9rem;
    /* Smaller font */
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.btn-secondary {
    background: #e9ecef;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #dee2e6;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--accent-color);
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-danger:hover {
    background: #d00060;
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* Items List Input */
.items-container {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    /* max-height removed to show all items */
    border: 1px solid #e9ecef;
}

.item-input-row {
    display: flex;
    flex-direction: column;
    /* Stack inputs vertically */
    gap: 5px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #eee;
    animation: fadeIn 0.3s ease;
}

.item-index {
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 0.8rem;
    margin-bottom: 5px;
}

/* Visualization Area */
main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    /* Height logic handled by container now */
    overflow: visible;
    /* Allow content to flow */
}

/* Allow scrolling on main visualization area for mobile */
@media (max-width: 1024px) {
    main {
        overflow-y: auto;
        height: auto;
    }
}

.visualizer-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 25px;
    /* flex: 1 removed */
    display: flex;
    flex-direction: column;
    position: relative;
    height: auto;
    /* Allow auto height */
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 15px 25px;
    background: white;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid #f1f3f5;
    flex-wrap: wrap;
    /* Allow wrapping */
    gap: 15px;
}

.stat-item {
    text-align: center;
}

@media (max-width: 600px) {
    .stats-bar {
        justify-content: center;
    }

    .stat-item {
        flex: 1 1 100%;
        /* Full width on verify small screens */
        border-bottom: 1px solid #f1f1f1;
        padding-bottom: 10px;
    }

    .stat-item:last-child {
        border-bottom: none;
    }
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Utility Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Execution Log Styles */
.log-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    margin-top: 20px;
    height: 300px;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.log-header {
    background: #f8f9fa;
    padding: 15px 25px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--primary-dark);
}

.log-badge {
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
}

.log-badge.running {
    background: #e3f2fd;
    color: var(--primary-color);
}

.log-badge.finished {
    background: #e8f5e9;
    color: var(--success-color);
}

.log-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.log-placeholder {
    color: var(--text-light);
    font-style: italic;
    text-align: center;
    margin-top: 40px;
}

.log-entry {
    padding: 8px 12px;
    margin-bottom: 5px;
    border-left: 3px solid #ddd;
    background: #fafafa;
    border-radius: 0 4px 4px 0;
    animation: fadeIn 0.3s ease;
}

.log-entry.full {
    border-left-color: var(--success-color);
    background: #f0fff4;
    border: 1px solid var(--success-color);
    /* Add full boundary */
    border-left-width: 5px;
    /* Thicker left accent */
    border-radius: 4px;
    /* Rounded all corners */
}

.log-entry.partial {
    border-left-color: var(--warning-color);
    background: #fffbef;
}

.log-entry.info {
    border-left-color: var(--primary-color);
    background: #f0f7ff;
    font-weight: bold;
}