@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Fira+Code:wght@400;500;600&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;

body {
    font-family: 'Poppins', sans-serif;
    background: #020617; /* Deep ocean navy fallback */
    background-attachment: fixed;
    color: #e2e8f0;
}

/* Animated Ocean Mesh Background */
.ocean-bg {
    background: linear-gradient(-45deg, #020617, #082f49, #064e3b, #172554);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.font-mono {
    font-family: 'Fira Code', monospace;
}

/* Glassmorphism Panels - Ocean Theme */
.glass-panel {
    background: rgba(10, 25, 47, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(14, 165, 233, 0.15); /* Soft cyan border */
    border-top: 1px solid rgba(14, 165, 233, 0.3);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
}

/* Visualizer Container Base */
.bar-container {
    gap: clamp(1px, 0.5vw, 4px);
    padding: 10px 0;
    transition: all 0.3s ease;
}

/* Mode: Graph View */
.bar-container.graph-view {
    align-items: flex-end;
}
.graph-view .bar {
    border-radius: 6px 6px 0 0;
    font-size: clamp(0.5rem, 1.5vw, 0.9rem); /* Scaled slightly up for readability */
}

/* Mode: Container View (Boxes) */
.bar-container.container-view {
    align-items: center;
    justify-content: center;
    gap: clamp(2px, 1vw, 8px);
    flex-wrap: wrap; /* Ensure boxes wrap instead of shrinking infinitely */
}
.container-view .bar {
    flex: 0 0 auto;
    aspect-ratio: 1 / 1;
    width: clamp(15px, 5vw, 45px); /* Let width scale dynamically */
    height: clamp(15px, 5vw, 45px);
    max-width: 45px;
    max-height: 45px;
    border-radius: clamp(4px, 1.5vw, 12px);
    box-shadow: 0 4px 15px -5px rgba(0,0,0,0.6);
    font-size: clamp(0.7rem, 2.5vw, 1.5rem);
}

/* Custom UI Highlights - Ocean Glow */
.logo-glow {
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3);
}


/* Typography Glows */
.text-glow-indigo { text-shadow: 0 0 12px rgba(99, 102, 241, 0.8), 0 0 24px rgba(99, 102, 241, 0.4); }
.text-glow-emerald { text-shadow: 0 0 12px rgba(16, 185, 129, 0.8), 0 0 24px rgba(16, 185, 129, 0.4); }
.text-glow-purple { text-shadow: 0 0 12px rgba(168, 85, 247, 0.8), 0 0 24px rgba(168, 85, 247, 0.4); }
.text-glow-rose { text-shadow: 0 0 12px rgba(244, 63, 94, 0.8), 0 0 24px rgba(244, 63, 94, 0.4); }
.text-glow-amber { text-shadow: 0 0 12px rgba(245, 158, 11, 0.8), 0 0 24px rgba(245, 158, 11, 0.4); }
.text-glow-cyan { text-shadow: 0 0 12px rgba(6, 182, 212, 0.8), 0 0 24px rgba(6, 182, 212, 0.4); }

/* Individual Card/Bubble Styles */
.bar {
    transition: height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8), 0 0 8px rgba(255,255,255,0.3);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

/* State Colors with 3D Ocean/Ice Glow */
.bar-default { 
    background: linear-gradient(180deg, #38bdf8 0%, #0369a1 100%); 
}

.bar-comparing { 
    background: linear-gradient(180deg, #fde047 0%, #ca8a04 100%); 
    box-shadow: 0 0 20px rgba(253, 224, 71, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.3) !important; 
    transform: translateY(-4px); 
    z-index: 10; 
    border-color: #fef08a;
}

.bar-swapping { 
    background: linear-gradient(180deg, #f43f5e 0%, #9f1239 100%); 
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.7), inset 0 2px 4px rgba(255, 255, 255, 0.4) !important; 
    transform: translateY(-8px) scale(1.08); 
    z-index: 20; 
    border-color: #fda4af;
}

.bar-overwrite { 
    background: linear-gradient(180deg, #a855f7 0%, #6b21a8 100%); 
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.7), inset 0 2px 4px rgba(255, 255, 255, 0.4) !important; 
    transform: translateY(-6px) scale(1.05); 
    z-index: 20; 
    border-color: #d8b4fe;
}

.bar-empty {
    background: rgba(8, 145, 178, 0.1) !important;
    border: 1px dashed rgba(8, 145, 178, 0.4) !important;
    box-shadow: none !important;
    color: transparent !important;
}

.bar-pivot { 
    background: linear-gradient(180deg, #2dd4bf 0%, #0f766e 100%); 
    box-shadow: 0 0 20px rgba(45, 212, 191, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.3) !important; 
    border-color: #5eead4; 
    transform: translateY(-3px);
}

.bar-sorted { 
    background: linear-gradient(180deg, #10b981 0%, #047857 100%); 
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.2) !important; 
    border-color: #6ee7b7;
}

/* Partition Highlighting */
.has-partition .bar {
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.has-partition .bar:not(.in-partition) {
    opacity: 0.25;
    transform: scale(0.92);
    filter: grayscale(60%);
}
.graph-view.has-partition .bar:not(.in-partition) {
    transform: none; /* Keep base alignment for graph */
}
.in-partition {
    border-bottom: 4px solid #38bdf8 !important; /* bright blue line */
    box-shadow: 0 10px 20px -5px rgba(56, 189, 248, 0.4);
    z-index: 5;
}
.graph-view .in-partition {
    border-bottom: 1px solid rgba(255,255,255,0.15) !important;
    border-top: 4px solid #38bdf8 !important; /* line on top for graph */
}

/* Divider Lines Between Subarrays */
.partition-divider {
    width: 4px;
    border-radius: 9999px;
    z-index: 10;
    background-color: #38bdf8;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.8), 0 0 5px rgba(255,255,255,0.8);
    margin: 0 6px;
    transition: height 0.3s ease;
}
.container-view .partition-divider {
    height: clamp(35px, 6vw, 80px);
}
.graph-view .partition-divider {
    height: 100%;
    width: 2px;
    margin: 0 2px;
    background-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}
.partition-start {
    border-left: 3px solid #38bdf8 !important;
}
.partition-end {
    border-right: 3px solid #38bdf8 !important;
}

/* Custom range slider */
input[type=range] {
    -webkit-appearance: none;
    background: transparent;
    width: 100%;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px; width: 18px;
    border-radius: 50%;
    background: #22d3ee;
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.6);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.9);
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 4px;
    cursor: pointer;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

/* Scrollbar for pseudocode */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.02);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

/* Distinct Solid Buttons */
.btn-glass {
    background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
    border-radius: 0.75rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #ffffff;
    font-weight: 600;
}
.btn-glass:hover:not(:disabled) {
    background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 100%);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-glass:active:not(:disabled) {
    transform: translateY(0);
    background: #0369a1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Mobile Responsiveness Rules */
@media (max-width: 640px) {
    body {
        padding: 0.5rem;
    }
    
    .glass-panel {
        padding: 1rem;
    }

    #visualizer {
        min-height: 120px !important;
    }
    
    #auxVisualizer {
        min-height: 60px !important;
    }
    
    .partition-divider {
        margin: 0 2px !important;
    }

    /* Reduce sizes for algorithm title */
    #algoName {
        font-size: 1.5rem;
    }

    /* Wrap badges tightly */
    .flex-wrap.gap-6 {
        gap: 1rem !important;
    }
}



button:focus, select:focus, input:focus { outline: none !important; }
