/* ========================================= */
/* === 1. Grundläggande Stilar & Layout === */
/* ========================================= */

body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: #f4f4f4;
    color: #333;
}

.container {
    max-width: 700px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

h1,
h2,
h3 {
    color: #222;
    margin-bottom: 10px;
}

hr {
    border: 0;
    height: 1px;
    background: #ddd;
    margin: 30px 0;
}

.result-container {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #eee;
    background-color: #fafafa;
    border-radius: 4px;
}

/* ========================================= */
/* === 2. Globala Komponenter & Element === */
/* ========================================= */

/* Formulär & Input */
label,
button,
select {
    margin-top: 10px;
    display: block;
}

input,
select {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Döljer upp/ner-pilarna för number-inputs */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

/* Knappar */
button {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color .3s ease;
}

button:hover {
    background-color: #0056b3;
}

/* ========================================= */
/* === 3. Sorteringsvisualisering === */
/* ========================================= */

#sort_visualization {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    padding: 10px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    margin-top: 10px;
    gap: 5px;
    flex-wrap: wrap;
}

.bar {
    width: 40px;
    height: 40px;
    background-color: #007bff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    border: 1px solid #0056b3;
    border-radius: 4px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease-in-out;
}

/* === Färger & effekter för sorteringssteg === */
.comparing {
    background-color: #ffc107;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.swapped {
    background-color: #28a745;
}

.key {
    background-color: #17a2b8;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.dividing {
    background-color: #00bcd4;
}

.merging-left {
    background-color: #ff9800;
}

.merging-right {
    background-color: #2196f3;
}

.sorted,
.pivot_final {
    background-color: #4caf50;
    color: white;
}

.min-element {
    background-color: #007bff;
}

.pivot {
    background-color: #ff5722;
}

.pointer {
    border: 2px solid #000;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
}

.heap-element {
    background-color: #3f51b5;
}

.gapped-element {
    background-color: #ff9800;
}

/* === Extra för Bogo Sort === */
.shuffled {
    background-color: #9c27b0;
    /* lila */
}

.stopped {
    background-color: #f44336;
    /* röd */
}

.done {
    background-color: #4caf50;
    /* grön */
}

/* ========================================= */
/* === 4. Stackvisualisering === */
/* ========================================= */

#stack_visualization {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    min-height: 200px;
    border: 2px solid #ccc;
    padding: 10px;
    width: 150px;
    margin: 20px auto;
    background-color: #fafafa;
    border-radius: 6px;
}

.stack-element {
    width: 100px;
    height: 30px;
    background-color: #2196f3;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #fff;
    margin-top: 5px;
    transition: transform 0.5s ease-out, background-color 0.5s ease-out;
}

.popped {
    background-color: #f44336;
}

.pushed {
    background-color: #4caf50;
}

/* ========================================= */
/* === 5. Trädvisualisering (BST) === */
/* ========================================= */

.tree-container {
    display: flex;
    justify-content: center;
    padding: 20px;
    margin: 20px auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f9f9f9;
    min-height: 100px;
    overflow-x: auto;
}

.tree-node-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 10px;
}

.tree-node {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #3f51b5;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid #283593;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    margin: 10px 0;
}

.tree-children-container {
    display: flex;
    justify-content: center;
    position: relative;
    width: 100%;
}

.tree-child-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Linjer mellan noder */
.tree-node-container .tree-children-container>.tree-child-wrapper:first-child::before,
.tree-node-container .tree-children-container>.tree-child-wrapper:last-child::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 30px;
    background-color: #777;
    top: -20px;
    z-index: 5;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    transform-origin: top;
}

.tree-node-container .tree-children-container>.tree-child-wrapper:first-child::before {
    transform: translateX(-50%) rotate(-30deg) translateY(-5px);
}

.tree-node-container .tree-children-container>.tree-child-wrapper:last-child::before {
    transform: translateX(-50%) rotate(30deg) translateY(-5px);
}

/* Pilspetsar */
.tree-node-container .tree-children-container>.tree-child-wrapper::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #777;
    z-index: 5;
    bottom: -15px;
}

.tree-node-container .tree-children-container>.tree-child-wrapper:first-child::after {
    left: 40%;
    transform: rotate(-30deg);
}

.tree-node-container .tree-children-container>.tree-child-wrapper:last-child::after {
    right: 40%;
    transform: rotate(30deg);
}

.info-text {
    margin-top: 10px;
    font-style: italic;
    color: #555;
}


/* === Navigation === */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #007bff;
    padding: 10px 20px;
    border-radius: 6px;
}

.nav-link {
    color: white;
    text-decoration: none;
    margin-right: 15px;
    font-weight: bold;
    transition: color 0.3s;
}

.nav-link:hover {
    color: #ffeb3b;
}

.language-switcher .lang-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    margin-left: 10px;
    transition: transform 0.2s;
}

.language-switcher .lang-btn:hover {
    transform: scale(1.2);
}