/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1f2937;
    background: linear-gradient(to bottom right, #eff6ff, #e0e7ff);
    min-height: 100vh;
}

/* Container */
.app-container {
    padding: 1.5rem;
    min-height: 100vh;
}

.max-width-container {
    max-width: 1280px;
    margin: 0 auto;
}

/* Navigation Bar */
.nav-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #374151;
    background-color: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.875rem;
    font-family: inherit;
}

.nav-button:hover {
    background-color: #f3f4f6;
}

.nav-button svg {
    flex-shrink: 0;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.main-title {
    font-size: 2rem;
    font-weight: 700;
    color: #1e3a8a;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1rem;
    color: #4b5563;
}

/* Exercise Selector */
.exercise-selector {
    margin-bottom: 2rem;
}

.exercise-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.exercise-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.exercise-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

.exercise-card.selected {
    background: #dbeafe;
    border-color: #2563eb;
}

.exercise-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.exercise-number {
    background: #3b82f6;
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.exercise-card.selected .exercise-number {
    background: #1e40af;
}

.exercise-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    flex: 1;
}

.exercise-description {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
}

/* Animation Controls */
.animation-controls {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.controls-left {
    display: flex;
    gap: 0.5rem;
}

.controls-center {
    flex: 1;
    text-align: center;
}

.controls-right {
    display: flex;
    align-items: center;
}

.btn-control {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #374151;
}

.btn-control:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

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

.btn-primary {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.step-indicator {
    font-size: 0.9rem;
    color: #4b5563;
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

.speed-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #4b5563;
}

.speed-select {
    padding: 0.375rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
}

.speed-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Content Grid */
.main-content {
    margin-top: 2rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

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

/* Code Viewer */
.code-viewer,
.array-visualizer {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 1rem;
}

.code-description {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    color: #92400e;
}

.code-container {
    background: #1e293b;
    border-radius: 0.375rem;
    overflow: auto;
    flex: 1;
    max-height: 600px;
}

.code-display {
    padding: 1rem;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #e2e8f0;
}

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

.code-line.active {
    background: #fbbf24;
    color: #1e293b;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

/* Syntax Highlighting for ΓΛΩΣΣΑ */
.keyword {
    color: #60a5fa;
    font-weight: 600;
}

.variable {
    color: #a78bfa;
}

.string {
    color: #34d399;
}

.number {
    color: #fbbf24;
}

.operator {
    color: #f472b6;
}

.comment {
    color: #94a3b8;
    font-style: italic;
}

/* Array Visualizer */
.array-display {
    overflow: auto;
    flex: 1;
    max-height: 600px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 16rem;
    color: #9ca3af;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

/* 1D Array */
.array-1d {
    margin-bottom: 1.5rem;
}

.array-name {
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 0.75rem;
    font-family: 'Courier New', monospace;
}

.array-1d-container {
    overflow-x: auto;
}

.array-1d-wrapper {
    display: inline-flex;
    flex-direction: column;
    gap: 0.25rem;
}

.array-1d-indices,
.array-1d-values {
    display: flex;
    gap: 0.25rem;
}

.array-1d-index {
    width: 4rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #6b7280;
    font-family: 'Courier New', monospace;
}

.array-1d-cell {
    width: 4rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e5e7eb;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
    background: #f9fafb;
    color: #9ca3af;
}

.array-1d-cell.filled {
    border-color: #93c5fd;
    background: #dbeafe;
    color: #1e3a8a;
}

.array-1d-cell.highlighted {
    border-color: #22c55e;
    background: #dcfce7;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    transform: scale(1.1);
}

/* 2D Array */
.array-2d {
    margin-bottom: 1.5rem;
}

.array-2d-container {
    overflow: auto;
}

.array-2d-table {
    border-collapse: collapse;
    display: inline-table;
}

.array-2d-header {
    background: transparent;
}

.array-2d-col-header {
    width: 3.5rem;
    height: 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: #6b7280;
    font-family: 'Courier New', monospace;
}

.array-2d-row {
    transition: background-color 0.3s ease;
}

.array-2d-row.active-row {
    background: #fef3c7;
}

.array-2d-row-header {
    width: 3rem;
    height: 2.5rem;
    text-align: right;
    padding-right: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

.array-2d-row.active-row .array-2d-row-header {
    color: #d97706;
    font-weight: 600;
}

.array-2d-row-indicator {
    display: inline-block;
    margin-left: 0.25rem;
    color: #d97706;
}

.array-2d-cell-wrapper {
    padding: 0.125rem;
}

.array-2d-cell {
    width: 3.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e5e7eb;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
    background: #f9fafb;
    color: #9ca3af;
}

.array-2d-cell.filled {
    border-color: #93c5fd;
    background: #dbeafe;
    color: #1e3a8a;
}

.array-2d-cell.highlighted {
    border-color: #22c55e;
    background: #dcfce7;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    transform: scale(1.1);
}

/* Legend */
.legend {
    background: white;
    border-radius: 0.5rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.legend-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.75rem;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #4b5563;
}

.legend-box {
    width: 2rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    border: 2px solid;
    flex-shrink: 0;
}

.legend-box-highlighted {
    border-color: #22c55e;
    background: #dcfce7;
}

.legend-box-filled {
    border-color: #93c5fd;
    background: #dbeafe;
}

.legend-box-empty {
    border-color: #e5e7eb;
    background: #f9fafb;
}

.legend-line {
    width: 2rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

.legend-line-active {
    background: #fbbf24;
}

.legend-row-indicator {
    width: 2rem;
    height: 1.5rem;
    background: #fef3c7;
    border-left: 3px solid #d97706;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

/* Welcome Message */
.welcome-message {
    margin-top: 3rem;
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.welcome-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.welcome-text {
    font-size: 1rem;
    color: #6b7280;
}

/* Footer */
.footer {
    margin-top: 3rem;
    text-align: center;
    color: #4b5563;
    font-size: 0.875rem;
    padding-bottom: 2rem;
}

.footer-secondary {
    margin-top: 0.25rem;
    color: #6b7280;
}

/* Responsive */
@media (max-width: 768px) {
    .main-title {
        font-size: 1.5rem;
    }
    
    .exercise-grid {
        grid-template-columns: 1fr;
    }
    
    .animation-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-left,
    .controls-center,
    .controls-right {
        justify-content: center;
    }
    
    .legend-grid {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-content {
    animation: fadeIn 0.5s ease;
}

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

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}