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

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

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

.card-title-medium {
    font-size: 1.125rem;
    font-weight: 600;
    color: #8b5cf6;
    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;
    }
}

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

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

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

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

.progress-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.progress-label {
    display: flex;
    justify-between;
    font-size: 0.875rem;
}

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

.progress-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 0.5rem;
}

.progress-input {
    background: #15803d;
}

.progress-initialize {
    background: #dc2626;
}

.progress-calculate {
    background: #ea580c;
}

.progress-output {
    background: #7c3aed;
}

/* Input section */
.input-section {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    animation: fadeInUp 0.3s ease;
}

.input-section h4 {
    color: #92400e;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

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

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

.data-input:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

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

/* Buttons */
.btn-primary {
    background: #7c3aed;
    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;
    flex: 1;
}

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

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

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

.btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Dice section */
.dice-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.dice-animation {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: diceRoll 0.5s ease;
}

.dice-label {
    font-size: 0.875rem;
    color: #6b7280;
}

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

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

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

.array-cell {
    width: 2rem;
    height: 2rem;
    border-radius: 0.25rem;
    border: 2px solid;
    text-align: center;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

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

.array-cell.filled {
    background: #dcfce7;
    border-color: #10b981;
    color: #047857;
}

.array-cell.current {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
    transform: scale(1.1);
}

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

/* Frequency section */
.frequency-section {
    margin-bottom: 1.5rem;
}

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

.frequency-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.frequency-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    border-radius: 0.375rem;
    border: 2px solid #d1d5db;
    background: #f9fafb;
    transition: all 0.3s ease;
}

.frequency-item.active {
    border-color: #f59e0b;
    background: #fef3c7;
    transform: scale(1.02);
}

.frequency-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.frequency-dice {
    font-size: 1.5rem;
}

.frequency-label {
    font-weight: 600;
}

.frequency-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.frequency-value {
    font-weight: bold;
    font-size: 1.125rem;
}

.frequency-bars {
    display: flex;
    gap: 0.125rem;
}

.frequency-bar {
    width: 0.5rem;
    height: 1rem;
    background: #7c3aed;
    border-radius: 0.125rem;
}

/* Statistics section */
.statistics-section {
    background: #f9fafb;
    padding: 0.75rem;
    border-radius: 0.5rem;
}

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

.statistics-content {
    font-size: 0.875rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.statistics-detail {
    margin-left: 0.5rem;
}

/* Status section */
.status-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;
    word-wrap: break-word;
}

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

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

/* Fixed controls */
.fixed-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

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

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

.controls-buttons .btn-primary,
.controls-buttons .btn-secondary {
    max-width: 18rem;
}

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

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

.technique-info {
    background: #faf5ff;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border-left: 4px solid #7c3aed;
    margin-top: 0.75rem;
    line-height: 1.6;
}

.applications-info {
    background: #eff6ff;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border-left: 4px solid #2563eb;
    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 diceRoll {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

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

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

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

@media (max-width: 480px) {
    .array-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .frequency-right {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.25rem;
    }
    
    .frequency-bars {
        max-width: 3rem;
        flex-wrap: wrap;
    }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    .array-cell.current {
        background: #ffff00;
        color: #000000;
    }
    
    .array-cell.filled {
        background: #00ff00;
        color: #000000;
    }
    
    .frequency-item.active {
        background: #ffff00;
        color: #000000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .array-cell,
    .frequency-item,
    .dice-animation {
        transition: none;
        animation: none;
    }
    
    .code-line {
        transition: none;
    }
    
    .progress-fill {
        transition: none;
    }
}