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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
    min-height: 100vh;
    color: #374151;
    line-height: 1.6;
}

/* Typography */
h1, h2, h3, h4 {
    color: #1e40af;
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 1rem;
}

.card-title-medium {
    font-size: 1.125rem;
    font-weight: 600;
    color: #4338ca;
    margin-bottom: 0.75rem;
}

.card-subtitle {
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.card-info {
    font-size: 0.875rem;
    color: #4338ca;
    margin-top: 0.5rem;
}

/* Navigation */
.navigation {
    background: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.75rem 1rem;
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
}

.nav-item {
    background: none;
    border: none;
    color: #374151;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0.5rem 0;
    font-size: 1rem;
}

.nav-item:hover {
    color: #2563eb;
}

/* Main layout */
.main-content {
    padding: 1rem;
}

.container {
    max-width: 72rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.card-content {
    padding: 1.5rem;
}

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

/* Grid layout */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Radio group */
.radio-group {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.radio-item input[type="radio"] {
    accent-color: #2563eb;
    width: 1.25rem;
    height: 1.25rem;
}

.radio-item label {
    font-size: 1.125rem;
    cursor: pointer;
    font-weight: 500;
}

.radio-description {
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
}

/* Code container */
.code-container {
    background: #111827;
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.code-line {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
    margin-bottom: 0.125rem;
}

.code-line.active {
    background: #eab308;
    color: black;
    font-weight: bold;
}

/* Variables display */
.variables-display {
    background: #eff6ff;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.variables-display h4 {
    color: #1e40af;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.variables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.875rem;
}

/* Comparison info */
.comparison-info {
    background: #fefce8;
    border: 1px solid #fbbf24;
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #92400e;
}

/* Array visualization */
.array-info {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
    font-weight: normal;
}

.array-indices {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.array-index {
    width: 5rem;
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
}

.array-elements {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.array-element {
    width: 5rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: bold;
    transition: all 0.3s ease;
    background: white;
    color: #374151;
    text-align: center;
    padding: 0.25rem;
    line-height: 1.2;
}

.array-element.sorted {
    background: #bbf7d0;
    border-color: #10b981;
    color: #047857;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.array-element.comparing {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-5px) scale(1.05);
}

.array-element.comparing .element-text {
    transform: scale(1.1);
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
    border: 1px solid;
}

.legend-color.sorted {
    background: #bbf7d0;
    border-color: #10b981;
}

.legend-color.comparing {
    background: #fef3c7;
    border-color: #f59e0b;
}

.legend-color.unsorted {
    background: white;
    border-color: #d1d5db;
}

/* Memory Triangle */
.memory-triangle {
    background: #faf5ff;
    border: 1px solid #c084fc;
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    animation: fadeIn 0.3s ease;
}

.memory-triangle h4 {
    color: #7c3aed;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.triangle-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.triangle-top {
    display: flex;
    justify-content: center;
}

.triangle-arrows {
    display: flex;
    gap: 2rem;
}

.arrow {
    font-size: 1.5rem;
    color: #7c3aed;
    transition: opacity 0.3s ease;
    opacity: 0.3;
}

.arrow.active {
    opacity: 1;
}

.triangle-bottom {
    display: flex;
    gap: 2rem;
}

.memory-box {
    width: 6rem;
    height: 4rem;
    border: 2px solid #7c3aed;
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    font-weight: bold;
    color: #7c3aed;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.memory-box.active {
    background: #fbbf24;
    transform: scale(1.2);
}

.box-label {
    font-size: 0.6rem;
    margin-bottom: 0.25rem;
}

.box-value {
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    word-break: break-word;
    max-width: 5rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.swap-arrow {
    position: absolute;
    top: 5rem;
    font-size: 1.5rem;
    color: #7c3aed;
    transition: all 0.3s ease;
    opacity: 0.3;
}

.swap-arrow.active {
    opacity: 1;
    transform: scale(1.2);
}

/* Comparison sequence */
.comparison-sequence {
    background: #eff6ff;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.comparison-sequence h4 {
    color: #1e40af;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

#sequence-pairs {
    font-size: 0.875rem;
    color: #1d4ed8;
}

/* Controls */
.controls-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.status-message {
    background: white;
    border: 1px solid #d1d5db;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 1.125rem;
    max-width: 100%;
    margin: 0 auto;
    word-wrap: break-word;
}

.controls-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #fef3e2;
    color: #c2410c;
    border: 1px solid #fed7aa;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #fef3e2;
    border-color: #fb923c;
}

.completion-message {
    color: #059669;
    font-weight: 600;
    font-size: 1.125rem;
    animation: fadeIn 0.5s ease;
}

.completion-hint {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: normal;
}

/* Educational content */
.educational-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.info-item {
    line-height: 1.6;
}

.sequence-list {
    margin: 0.25rem 0 0 1rem;
    font-size: 0.75rem;
}

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

.navigation-info {
    background: #fefce8;
    padding: 0.5rem;
    border-radius: 0.25rem;
    border-left: 4px solid #facc15;
    margin-top: 0.75rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse {
    animation: pulse 0.5s ease-in-out;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .array-elements {
        gap: 0.125rem;
    }
    
    .array-element {
        width: 4rem;
        font-size: 0.65rem;
    }
    
    .array-index {
        width: 4rem;
        font-size: 0.75rem;
    }
    
    .controls-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .radio-group {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    
    .triangle-bottom {
        gap: 1rem;
    }
    
    .memory-box {
        width: 5rem;
        height: 3.5rem;
        font-size: 0.65rem;
    }
}

/* Print styles */
@media print {
    .navigation {
        display: none;
    }
    
    .controls-section {
        display: none;
    }
    
    body {
        background: white;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}