/* Custom Styles for Sorting Algorithm Visualizer */

/* Base Styles */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #8b5cf6;
    --success-color: #22c55e;
    --warning-color: #eab308;
    --danger-color: #ef4444;
    --light-bg: #f9fafb;
    --card-light-bg: #ffffff;
}

body {
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    font-size: 14px;
}

/* Custom Range Input Styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 5px;
    outline: none;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
}

/* Array Bar Styling */
.array-bar {
    background: linear-gradient(to top, var(--primary-color), var(--primary-light));
    margin: 0 1px;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
    transition: height 0.3s ease-in-out, background-color 0.3s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
    display: inline-block;
    position: relative;
    bottom: 0;
    min-width: 4px;
}

#visualizationContainer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1.5rem 0.5rem 0.5rem;
    min-height: 200px;
    background-image: 
        linear-gradient(rgba(99, 102, 241, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center center;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.array-bar.comparing {
    background: linear-gradient(to top, var(--warning-color), #fcd34d);
    animation: pulse-comparing 0.5s infinite alternate;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.5);
    z-index: 10;
}

.array-bar.swapping {
    background: linear-gradient(to top, var(--danger-color), #f87171);
    animation: pulse-swapping 0.5s infinite alternate;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    z-index: 20;
}

.array-bar.sorted {
    background: linear-gradient(to top, var(--success-color), #4ade80);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pulse-comparing {
    0% {
        transform: scaleY(1);
    }
    100% {
        transform: scaleY(1.03);
    }
}

@keyframes pulse-swapping {
    0% {
        transform: scaleY(1);
    }
    100% {
        transform: scaleY(1.05);
    }
}

.pulse {
    animation: pulse 1s infinite;
}

/* Button Hover Effects */
button {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px -2px rgba(0, 0, 0, 0.15), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

button:active:not(:disabled) {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Button Ripple Effect */
button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0) translate(-50%, -50%);
        opacity: 0.5;
    }
    100% {
        transform: scale(20, 20) translate(-50%, -50%);
        opacity: 0;
    }
}

/* Responsive Layout Improvements */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr !important;
    }
    
    .flex-col-mobile {
        flex-direction: column !important;
    }
    
    .space-y-mobile > * + * {
        margin-top: 0.5rem !important;
    }
    
    .w-full-mobile {
        width: 100% !important;
    }
    
    .mb-4-mobile {
        margin-bottom: 0.5rem !important;
    }
    
    .text-center-mobile {
        text-align: center !important;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, var(--primary-dark), var(--secondary-color));
}

/* Card Hover Effects */
.bg-white {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.bg-white:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.1), 0 6px 10px -5px rgba(0, 0, 0, 0.05);
}

/* Tooltip Styles */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 100px;
    background-color: #1f2937;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 3px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -50px;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(10px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    font-size: 10px;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1f2937 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* Glass Morphism Effect */
.backdrop-blur-sm {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Select Dropdown Styling */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236366f1'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.8rem;
    padding-right: 2rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Input Focus Styles */
input:focus, select:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-block;
}

/* Improved Card Styling */
.rounded-xl {
    border-radius: 0.75rem;
}

/* Add value labels to array bars */
.array-bar::after {
    content: attr(data-value);
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.array-bar:hover::after {
    opacity: 1;
}

/* Beginner-friendly explanation section */
.algorithm-explanation {
    background-color: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--primary-color);
    padding: 0.5rem;
    margin: 0.5rem 0;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    line-height: 1.4;
}

/* Step indicator for visualization */
.step-indicator {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.9);
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 30;
}

/* Improved chart container */
.chart-container {
    position: relative;
    width: 100%;
    background-color: white;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: background-color 0.3s ease;
    padding: 0.5rem;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
}

/* Compact layout styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

section {
    margin-bottom: 0.75rem;
}

.py-4 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.p-4 {
    padding: 0.75rem;
}

h1, h2, h3 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 0.75rem;
}

.gap-4 {
    gap: 0.75rem;
} 