:root {
    --primary: #22d3ee;
    --primary-glow: rgba(34, 211, 238, 0.3);
    --bg-dark: #060b13;
    --card-bg: #0f172a;
    --node-bg: #1e293b;
    --text-muted: #94a3b8;
}

body {
    background-color: var(--bg-dark);
    color: white;
    font-family: 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    line-height: 1.6;
}

.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header Section */
.theory-header {
    text-align: center;
    margin-bottom: 40px;
    width: 100%;
}

.theory-header h1 {
    font-size: 2.5rem;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
    margin-bottom: 10px;
}

/* Action Row (Inputs & Buttons) */
.action-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(34, 211, 238, 0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

input[type="number"] {
    background: var(--bg-dark);
    border: 1px solid #334155;
    color: white;
    padding: 12px;
    border-radius: 8px;
    outline: none;
    transition: 0.3s;
    width: 150px;
}

input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.btn-main, .btn-reset, .view-logic-btn {
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-main {
    background: var(--primary);
    border: none;
    color: #000;
}

.btn-main:hover {
    box-shadow: 0 0 20px var(--primary);
    transform: translateY(-2px);
}

.btn-reset {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
}

.btn-reset:hover {
    background: #ef4444;
    color: white;
}

/* Hash Table Visualization Layout */
#hash-table-container {
    width: 100%;
    margin-top: 40px;
}

.bucket-row {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    margin-bottom: 15px;
    border-radius: 10px;
    padding: 0 20px;
    height: 70px;
    border: 1px solid rgba(255,255,255,0.05);
}

.bucket-id {
    min-width: 100px;
    font-family: 'Consolas', monospace;
    font-size: 1.1rem;
    color: var(--primary);
    border-right: 2px solid rgba(34, 211, 238, 0.3);
    height: 100%;
    display: flex;
    align-items: center;
}

.chain-container {
    display: flex;
    align-items: center;
    gap: 35px; /* مسافة كافية للأسهم */
    padding-left: 20px;
    overflow-x: auto;
}

/* Data Nodes & Arrows */
.data-node {
    background: var(--node-bg);
    color: var(--primary);
    padding: 10px 20px;
    border-radius: 6px;
    border: 1px solid var(--primary);
    font-weight: bold;
    position: relative;
    white-space: nowrap;
    animation: nodeEntry 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* سهم الربط بين النودز */
.data-node:not(:last-child)::after {
    content: "➔";
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}

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

.back-link {
    position: fixed; /* يفضل ثابت حتى لو عملت سكرول */
    top: 20px;
    left: 20px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 1px;
    z-index: 1000; /* عشان يفضل فوق أي عناصر تانية */
    transition: 0.3s;
    text-transform: uppercase;
}

.back-link:hover {
    color: white;
    text-shadow: 0 0 10px var(--primary);
}