/* CSS 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: #333;
    background: linear-gradient(135deg, #f8f4ff 0%, #e6f3ff 100%);
    min-height: 100vh;
}

/* Utility Classes */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-red { color: #dc2626; }
.text-green { color: #16a34a; }

/* Layout */
.app {
    min-height: 100vh;
    padding-bottom: 2rem;
}

.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Navigation */
.navbar {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    gap: 1.5rem;
}

.nav-btn {
    background: none;
    border: none;
    color: #374151;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

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

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

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

.card-content {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #7c3aed;
    margin-bottom: 0.5rem;
}

/* Header Styles */
.title {
    font-size: 2rem;
    font-weight: 700;
    color: #7c3aed;
    margin-bottom: 0.5rem;
}

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

.badges {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    border: 1px solid;
}

.badge-red {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fca5a5;
}

.badge-green {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #86efac;
}

/* Info Boxes */
.scenario-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-box {
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid;
}

.info-blue {
    background: #eff6ff;
    border-color: #3b82f6;
}

.info-amber {
    background: #fffbeb;
    border-color: #f59e0b;
}

.info-gray {
    background: #f9fafb;
    border-color: #9ca3af;
}

.info-box h4 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.info-box ol {
    margin-left: 1.5rem;
}

.info-box ol li {
    margin-bottom: 0.25rem;
}

/* Students Grid */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    font-size: 0.875rem;
}

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

.student-number {
    font-weight: 600;
}

/* Method Selection */
.methods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.method-card {
    border: 2px solid;
    border-radius: 0.5rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.method-card:hover {
    transform: scale(1.02);
}

.method-card:active {
    transform: scale(0.98);
}

.method-red {
    background: #fef2f2;
    border-color: #fca5a5;
}

.method-green {
    background: #f0fdf4;
    border-color: #86efac;
}

.method-card h3 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.method-red h3 {
    color: #dc2626;
}

.method-green h3 {
    color: #16a34a;
}

.method-card p {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.method-red p {
    color: #b91c1c;
}

.method-green p {
    color: #15803d;
}

.method-info {
    font-size: 0.75rem;
    margin-bottom: 1rem;
}

.method-info div {
    margin-bottom: 0.25rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    width: 100%;
}

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

.btn-red {
    background: #dc2626;
    color: white;
}

.btn-red:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-green {
    background: #16a34a;
    color: white;
}

.btn-green:hover:not(:disabled) {
    background: #15803d;
}

.btn-blue {
    background: #2563eb;
    color: white;
}

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

.btn-purple {
    background: #7c3aed;
    color: white;
}

.btn-purple:hover:not(:disabled) {
    background: #6d28d9;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Progress */
.progress-section {
    margin-bottom: 1rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.progress-bar {
    width: 100%;
    height: 0.5rem;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 9999px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Input Section */
.input-section {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease;
}

.input-section.variables {
    background: #fef2f2;
    border-color: #fca5a5;
}

.input-section.arrays {
    background: #f0fdf4;
    border-color: #86efac;
}

.variable-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.variable-name {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border: 2px solid;
    border-radius: 0.375rem;
    animation: pulse 1.5s infinite;
}

.variable-name.variables {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.variable-name.arrays {
    background: #dcfce7;
    color: #16a34a;
    border-color: #86efac;
}

.student-name {
    font-size: 0.875rem;
    color: #6b7280;
}

.warning-box {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 0.375rem;
    padding: 0.5rem;
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    animation: fadeIn 0.3s ease;
}

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

.input-controls input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
}

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

/* Memory Visualization */
.memory-section {
    background: #f9fafb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.memory-section h4 {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
}

.memory-variables {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.memory-cell {
    width: 5rem;
    height: 2rem;
    border: 2px solid;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

.memory-red {
    background: #fecaca;
    border-color: #f87171;
}

.memory-blue {
    background: #bfdbfe;
    border-color: #60a5fa;
}

.memory-warning {
    font-size: 0.75rem;
    color: #dc2626;
    animation: blink 2s infinite;
}

.memory-arrays {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.array-label {
    font-size: 0.75rem;
    color: #6b7280;
}

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

.array-cell {
    width: 4rem;
    height: 2rem;
    border: 2px solid;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 0.625rem;
    line-height: 1;
    text-align: center;
}

.array-cell.entered {
    background: #bbf7d0;
    border-color: #86efac;
}

.array-cell.current {
    background: #fde68a;
    border-color: #f59e0b;
    animation: arrayPulse 1.5s infinite;
}

.array-cell.empty {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Code Section */
.code-section {
    margin-bottom: 1rem;
}

.code-section h4 {
    font-weight: 600;
    color: #7c3aed;
    margin-bottom: 0.5rem;
}

.code-block {
    background: #1f2937;
    color: white;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
}

.code-block pre {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    margin: 0;
}

/* Results Display */
.results-display {
    background: #eff6ff;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    text-align: center;
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-label {
    color: #1e40af;
    font-weight: 500;
}

.result-value {
    font-size: 3rem;
    font-weight: 700;
    color: #2563eb;
    animation: scaleIn 0.5s ease;
}

/* Search Info */
.search-info {
    background: #fff7ed;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.search-info h4 {
    font-weight: 600;
    color: #ea580c;
    margin-bottom: 0.5rem;
}

.search-info p {
    font-size: 0.875rem;
    color: #c2410c;
    margin-bottom: 0.75rem;
}

.problem-box {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 0.375rem;
    padding: 0.75rem;
}

.problem-box p {
    font-size: 0.875rem;
    color: #b91c1c;
    margin: 0;
}

/* Results Info */
.results-info {
    background: #f0fdf4;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.results-info h4 {
    font-weight: 600;
    color: #16a34a;
    margin-bottom: 0.75rem;
}

.students-results {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.student-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #bbf7d0;
    animation: slideInLeft 0.3s ease forwards;
    opacity: 0;
    transform: translateX(-20px);
}

.student-result.show {
    opacity: 1;
    transform: translateX(0);
}

.student-name-result {
    font-weight: 500;
}

.student-score {
    background: #dcfce7;
    color: #16a34a;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #86efac;
    font-size: 0.875rem;
}

.explanation-box {
    background: #eff6ff;
    border-radius: 0.5rem;
    padding: 1rem;
}

.explanation-box h4 {
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 0.5rem;
}

.explanation-box p {
    font-size: 0.875rem;
    color: #1d4ed8;
}

.explanation-box code {
    background: #e5e7eb;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
}

/* Comparison */
.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.comparison-card {
    border: 2px solid;
    border-radius: 0.5rem;
    padding: 1rem;
    animation: borderPulse 3s infinite;
}

.comparison-red {
    background: #fef2f2;
    border-color: #fca5a5;
}

.comparison-green {
    background: #f0fdf4;
    border-color: #86efac;
}

.comparison-card h3 {
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.comparison-red h3 {
    color: #dc2626;
}

.comparison-green h3 {
    color: #16a34a;
}

.comparison-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.comparison-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.badge-success {
    background: #dcfce7;
    color: #16a34a;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #86efac;
    font-size: 0.75rem;
}

.badge-error {
    background: #fee2e2;
    color: #dc2626;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #fca5a5;
    font-size: 0.75rem;
}

.comparison-reason {
    background: white;
    border-radius: 0.375rem;
    padding: 0.5rem;
    font-size: 0.75rem;
}

.comparison-red .comparison-reason {
    color: #b91c1c;
}

.comparison-green .comparison-reason {
    color: #15803d;
}

/* Conclusion */
.conclusion-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.highlight-box {
    background: #f3f4f6;
    border-left: 4px solid #7c3aed;
    border-radius: 0.5rem;
    padding: 1rem;
}

.highlight-box h4 {
    font-weight: 600;
    color: #7c3aed;
    margin-bottom: 0.5rem;
}

.highlight-box p {
    font-size: 0.875rem;
    color: #6d28d9;
}

.pros-cons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.pros-cons-card {
    border-left: 4px solid;
    border-radius: 0.5rem;
    padding: 1rem;
}

.pros-cons-red {
    background: #fef2f2;
    border-color: #f87171;
}

.pros-cons-green {
    background: #f0fdf4;
    border-color: #86efac;
}

.pros-cons-card h4 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.pros-cons-red h4 {
    color: #dc2626;
}

.pros-cons-green h4 {
    color: #16a34a;
}

.pros-cons-card ul {
    font-size: 0.875rem;
    list-style: none;
}

.pros-cons-red ul {
    color: #b91c1c;
}

.pros-cons-green ul {
    color: #15803d;
}

.pros-cons-card li {
    margin-bottom: 0.25rem;
}

.when-to-use-box {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 0.5rem;
    padding: 1rem;
}

.when-to-use-box h4 {
    font-weight: 600;
    color: #d97706;
    margin-bottom: 0.5rem;
}

.when-to-use-box p {
    font-size: 0.875rem;
    color: #92400e;
}

/* Tabs */
.tabs {
    width: 100%;
}

.tab-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #e5e7eb;
}

.tab-button {
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-button.active {
    border-bottom-color: #7c3aed;
    background: #f8fafc;
}

.tab-content {
    display: none;
    padding: 1rem 0;
}

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

.code-comparison-red {
    background: #fef2f2;
    border-radius: 0.5rem;
    padding: 1rem;
}

.code-comparison-green {
    background: #f0fdf4;
    border-radius: 0.5rem;
    padding: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    max-width: 32rem;
    width: 100%;
    animation: modalSlideIn 0.3s ease, modalShake 3s infinite;
}

.modal-body {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-icon {
    font-size: 4rem;
    animation: spin 3s infinite;
}

.modal-body h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #dc2626;
}

.problem-explanation {
    background: #fef2f2;
    border: 2px solid #fca5a5;
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: left;
}

.problem-explanation h3 {
    font-weight: 600;
    color: #dc2626;
    margin-bottom: 0.5rem;
}

.problem-explanation p {
    color: #b91c1c;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.code-example {
    background: white;
    border: 1px solid #fca5a5;
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

.code-example div {
    margin-bottom: 0.25rem;
}

.result-explanation {
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: left;
}

.result-explanation h3 {
    font-weight: 600;
    color: #d97706;
    margin-bottom: 0.5rem;
}

.result-explanation p {
    color: #92400e;
    font-size: 0.875rem;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.modal-buttons .btn {
    width: auto;
    padding: 0.5rem 1rem;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes arrayPulse {
    0%, 100% { 
        transform: scale(1);
        border-color: #f59e0b;
    }
    50% { 
        transform: scale(1.1);
        border-color: #eab308;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

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

@keyframes borderPulse {
    0%, 100% { border-color: inherit; }
    50% { border-color: #6b7280; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes modalShake {
    0%, 100% { transform: rotateY(0deg); }
    25% { transform: rotateY(10deg); }
    75% { transform: rotateY(-10deg); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .content {
        padding: 0.5rem;
        gap: 1rem;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .badges {
        flex-direction: column;
        align-items: center;
    }
    
    .methods-grid {
        grid-template-columns: 1fr;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
    }
    
    .pros-cons-grid {
        grid-template-columns: 1fr;
    }
    
    .results-display {
        grid-template-columns: 1fr;
    }
    
    .input-controls {
        flex-direction: column;
    }
    
    .array-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .array-cell {
        width: 3rem;
        height: 1.5rem;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .tab-buttons {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.5rem;
    }
    
    .result-value {
        font-size: 2rem;
    }
    
    .modal-content {
        margin: 0.5rem;
        padding: 1rem;
    }
    
    .modal-icon {
        font-size: 3rem;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .modal,
    button {
        display: none !important;
    }
    
    .app {
        background: white;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}