/* 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, #f0fdf4 0%, #dbeafe 100%);
    min-height: 100vh;
    color: #374151;
    line-height: 1.6;
}

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

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

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

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

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

.input-description {
    font-size: 0.875rem;
    color: #6b7280;
}

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

/* Input section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.input-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.input-label {
    font-size: 0.875rem;
    text-align: center;
    color: #374151;
    font-weight: 500;
}

.input-field {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    text-align: center;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.input-field:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

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

/* Buttons */
.btn-primary {
    background: #10b981;
    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: #059669;
}

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

.btn-secondary {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    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: #bfdbfe;
    border-color: #3b82f6;
}

/* 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: #f0fdf4;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.variables-display h4 {
    color: #166534;
    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;
}

/* Info sections */
.check-info {
    background: #fefce8;
    border: 1px solid #fbbf24;
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #92400e;
    margin-top: 0.5rem;
}

.output-info {
    background: #eff6ff;
    border: 1px solid #3b82f6;
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #1d4ed8;
    margin-top: 0.5rem;
}

/* Array visualization */
.array-section {
    margin-bottom: 1.5rem;
}

.array-title {
    text-align: center;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

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

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

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

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

.array-element.grade {
    font-size: 1rem;
}

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

.array-element.highlighted {
    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.even {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.array-element.empty {
    background: #f9fafb;
    border: 2px dashed #d1d5db;
    color: #9ca3af;
}

.array-element.active {
    background: #86efac;
    border-color: #10b981;
    color: #047857;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-5px) 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.processed {
    background: #bbf7d0;
    border-color: #10b981;
}

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

.legend-color.even {
    background: #dbeafe;
    border-color: #3b82f6;
}

.legend-color.empty {
    background: #f9fafb;
    border: 2px dashed #d1d5db;
}

/* Computer Screen */
.computer-screen {
    margin-top: 1.5rem;
    animation: fadeInUp 0.5s ease;
}

.screen-card {
    background: #374151;
    border: 1px solid #4b5563;
}

.screen-header {
    background: #1f2937;
    border-bottom: 1px solid #4b5563;
    padding: 1rem;
}

.screen-title {
    color: #10b981;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.screen-indicator {
    width: 0.75rem;
    height: 0.75rem;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.screen-content {
    background: #000000;
    padding: 1rem;
    min-height: 7.5rem;
}

.terminal {
    font-family: 'Courier New', monospace;
    color: #10b981;
    font-size: 0.875rem;
}

.terminal-line {
    margin-bottom: 0.25rem;
}

.terminal-line.system {
    color: #6b7280;
}

.terminal-line.success {
    color: #10b981;
}

.terminal-results {
    margin-left: 0.5rem;
    margin-bottom: 0.5rem;
}

.terminal-result {
    color: white;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
    animation: fadeInLeft 0.3s ease;
}

.terminal-footer {
    margin-top: 0.5rem;
}

/* Controls */
.controls-wrapper {
    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;
}

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

.completion-message.error {
    color: #dc2626;
}

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

.success-info {
    background: #f0fdf4;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border-left: 4px solid #10b981;
    margin-top: 0.75rem;
    line-height: 1.6;
}

.tips-info {
    background: #fefce8;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border-left: 4px solid #facc15;
    margin-top: 0.75rem;
    line-height: 1.6;
}

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

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .input-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.25rem;
    }
    
    .array-elements {
        gap: 0.125rem;
    }
    
    .array-element {
        width: 3rem;
        height: 3rem;
        font-size: 0.75rem;
    }
    
    .array-index {
        width: 3rem;
        font-size: 0.65rem;
    }
    
    .controls-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .input-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .legend {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .variables-grid {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .input-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .array-element {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 0.65rem;
    }
    
    .array-index {
        width: 2.5rem;
        font-size: 0.6rem;
    }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    .array-element.highlighted {
        background: #ffff00;
        color: #000000;
    }
    
    .array-element.processed {
        background: #00ff00;
        color: #000000;
    }
    
    .array-element.active {
        background: #00ff7f;
        color: #000000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .array-element {
        transition: none;
    }
    
    .code-line {
        transition: none;
    }
    
    .screen-indicator {
        animation: none;
    }
    
    .terminal-result {
        animation: none;
    }
}