﻿/* ================================
   Computer Architecture Simulator
   Custom Styles (Complements Bootstrap 5)
   ================================ */

:root {
    --bg-primary: #0f0f1e;
    --bg-secondary: #1a1a2e;
    --bg-card: #1f1f3a;
    --bg-card-hover: #2a2a4a;
    --accent-cyan: #00d4ff;
    --accent-red: #ff4444;
    --accent-yellow: #ffd700;
    --accent-green: #00ff88;
    --accent-purple: #b347d9;
    --accent-orange: #ff8800;
    --led-on: #ff3030;
    --led-off: #2a0808;
    --led-yellow-on: #ffd700;
}

/* ============ Base ============ */
html, body {
    background: var(--bg-primary);
    color: #fff;
    min-height: 100vh;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

    body[dir="rtl"] {
        font-family: 'Tajawal', 'Segoe UI', sans-serif;
    }

/* ============ Top Gradient Bar ============ */
.top-bar {
    height: 4px;
    background: linear-gradient(90deg, #ff4444, #00d4ff, #ffd700);
}

/* ============ Custom Navbar ============ */
.navbar-custom {
    background: rgba(20, 20, 40, 0.95) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}

.navbar-brand {
    color: var(--accent-cyan) !important;
    font-weight: 700;
}

.btn-cyan {
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid var(--accent-cyan);
    color: #fff;
    transition: all 0.2s;
}

    .btn-cyan:hover {
        background: rgba(0, 212, 255, 0.3);
        color: #fff;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
    }

/* ============ Hero (Main Page) ============ */
.hero-section {
    text-align: center;
    padding: 60px 20px 30px;
}

.hero-icon {
    font-size: 80px;
    animation: float 3s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

.hero-title {
    font-size: clamp(28px, 5vw, 46px);
    font-weight: 800;
    background: linear-gradient(90deg, #00d4ff, #b347d9, #ffd700);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
    animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
    0%, 100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.4);
    }
}

.hero-subtitle {
    font-size: clamp(14px, 2vw, 18px);
    color: #b8b8d4;
}

.hero-cta {
    color: #888aa8;
    font-style: italic;
    margin-top: 10px;
}

.divider-fancy {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
}

    .divider-fancy::before, .divider-fancy::after {
        content: '';
        height: 2px;
        width: min(200px, 25vw);
        background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
    }

.divider-dot {
    width: 10px;
    height: 10px;
    background: var(--accent-cyan);
    border-radius: 50%;
    margin: 0 15px;
    box-shadow: 0 0 15px var(--accent-cyan);
}

/* ============ Cards (Main Page) ============ */
.sim-card {
    background: linear-gradient(180deg, #2a2a4a, #1a1a35);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 30px 25px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    text-align: center;
    height: 100%;
    text-decoration: none;
    color: inherit;
    display: block;
}

    .sim-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 6px;
        background: var(--card-color, var(--accent-cyan));
    }

    .sim-card:hover {
        transform: translateY(-8px);
        border-color: var(--card-color, var(--accent-cyan));
        box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3);
        color: inherit;
    }

.sim-card-red {
    --card-color: #ff6464;
}

.sim-card-yellow {
    --card-color: #ffd750;
}

.sim-card-icon {
    font-size: 60px;
    margin-bottom: 15px;
}

.sim-card-title {
    color: var(--card-color, var(--accent-cyan));
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.sim-card-subtitle {
    font-family: 'Consolas', monospace;
    font-size: 13px;
    color: #888aa8;
    margin-bottom: 15px;
}

.sim-card-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 15px 0;
}

.sim-card-desc {
    color: #b8b8d4;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    min-height: 80px;
}

.sim-card-btn {
    background: var(--card-color, var(--accent-cyan));
    color: #000 !important;
    padding: 10px;
    border-radius: 6px;
    font-weight: 700;
    transition: transform 0.2s;
}

.sim-card:hover .sim-card-btn {
    transform: scale(1.05);
}

/* ============ 7-Segment Display ============ */
.seven-seg-canvas {
    background: #000;
    border: 3px solid var(--accent-green);
    border-radius: 12px;
    padding: 30px;
    display: flex;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(0, 255, 0, 0.1);
}

.voltage-controls {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
}

.voltage-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    margin-bottom: 8px;
}

    .voltage-input-row label {
        color: var(--accent-yellow);
        font-family: 'Consolas', monospace;
        font-weight: 700;
        min-width: 100px;
        margin: 0;
    }

    .voltage-input-row input {
        width: 55px;
        padding: 6px;
        background: #000;
        color: var(--accent-green);
        border: 1px solid var(--accent-green);
        border-radius: 4px;
        text-align: center;
        font-family: 'Consolas', monospace;
        font-weight: 700;
        font-size: 14px;
    }

.quick-num-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 15px;
}

.quick-num-btn {
    width: 45px;
    height: 45px;
    background: #444;
    color: #fff;
    border: 1px solid #666;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.15s;
}

    .quick-num-btn:hover {
        background: var(--accent-cyan);
        color: #000;
        transform: scale(1.1);
    }

.binary-readout {
    background: #000;
    border: 1px solid var(--accent-cyan);
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    margin-top: 15px;
}

    .binary-readout .label {
        color: var(--accent-yellow);
        font-family: 'Consolas', monospace;
    }

    .binary-readout .value {
        color: var(--accent-cyan);
        font-family: 'Consolas', monospace;
        font-size: 18px;
        font-weight: 700;
        letter-spacing: 4px;
    }

/* ============ Dot Matrix Display ============ */
.dot-display-screen {
    background: #051005;
    border: 3px solid var(--accent-green);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    box-shadow: inset 0 0 30px rgba(0, 255, 0, 0.1);
    overflow-x: auto;
}

.dot-digit {
    display: grid;
    grid-template-columns: repeat(5, 12px);
    grid-template-rows: repeat(7, 12px);
    gap: 2px;
    flex-shrink: 0;
}

.dot-led {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--led-off);
    border: 1px solid #333;
    transition: all 0.15s;
}

    .dot-led.on {
        background: var(--led-on);
        box-shadow: 0 0 5px var(--led-on);
    }

@media (min-width: 992px) {
    .dot-digit {
        grid-template-columns: repeat(5, 14px);
        grid-template-rows: repeat(7, 14px);
    }

    .dot-led {
        width: 14px;
        height: 14px;
    }
}

/* ============ Binary Pattern Table ============ */
.pattern-table {
    background: var(--bg-card);
    border: 2px solid var(--accent-cyan);
    border-radius: 10px;
    padding: 20px;
}

    .pattern-table h5 {
        color: var(--accent-cyan);
        margin-bottom: 5px;
    }

    .pattern-table .current-char {
        color: var(--accent-yellow);
        font-family: 'Consolas', monospace;
        font-weight: 700;
        margin-bottom: 15px;
    }

    .pattern-table table {
        width: 100%;
        color: #fff;
    }

    .pattern-table th {
        color: var(--accent-yellow);
        text-align: center;
        border-bottom: 1px solid var(--accent-cyan);
        padding: 8px;
        font-family: 'Consolas', monospace;
        font-size: 13px;
    }

    .pattern-table td {
        text-align: center;
        padding: 6px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .pattern-table .row-num {
        font-family: 'Consolas', monospace;
        font-weight: 700;
        font-size: 14px;
    }

    .pattern-table .binary-val {
        color: var(--accent-green);
        font-family: 'Consolas', monospace;
        font-weight: 700;
        font-size: 16px;
        letter-spacing: 2px;
    }

.mini-led-row {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.mini-led {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #555;
    background: var(--led-off);
    transition: all 0.2s;
}

    .mini-led.on {
        background: var(--led-on);
        box-shadow: 0 0 8px var(--led-on);
    }

.pattern-note {
    margin-top: 15px;
    color: var(--accent-cyan);
    font-style: italic;
    font-size: 12px;
    text-align: center;
}

/* ============ CPU + RAM ============ */
.cpu-box {
    background: linear-gradient(180deg, #4a1a5a, #2d0d3a);
    border: 2px solid #fff;
    border-radius: 10px;
    padding: 18px;
    height: 100%;
}

.ram-box {
    background: linear-gradient(180deg, #1a4050, #0d2030);
    border: 2px solid #fff;
    border-radius: 10px;
    padding: 18px;
    height: 100%;
}

.box-title {
    color: #fff;
    font-weight: 700;
    margin-bottom: 12px;
    font-size: 15px;
}

.register-label {
    color: #fff;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    font-weight: 700;
    margin: 12px 0 5px;
}

.bit-row {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.bit-cell {
    width: 22px;
    height: 24px;
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    font-weight: 700;
    transition: all 0.3s;
}

    .bit-cell.active-cyan {
        background: var(--accent-cyan);
        color: #000;
        box-shadow: 0 0 8px var(--accent-cyan);
    }

    .bit-cell.active-yellow {
        background: var(--accent-yellow);
        color: #000;
        box-shadow: 0 0 8px var(--accent-yellow);
    }

    .bit-cell.active-green {
        background: var(--accent-green);
        color: #000;
    }

.alu-box {
    background: #555;
    padding: 10px;
    border-radius: 4px;
    margin: 5px 0;
    text-align: center;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    color: #fff;
    transition: all 0.3s;
}

    .alu-box.active {
        background: var(--accent-orange);
        color: #000;
        box-shadow: 0 0 20px var(--accent-orange);
        transform: scale(1.02);
    }

.compact-display {
    display: grid;
    grid-template-columns: repeat(5, 9px);
    grid-template-rows: repeat(7, 9px);
    gap: 1px;
    margin-top: 5px;
}

.compact-cell {
    background: #2a2a2a;
    transition: all 0.2s;
    border-radius: 1px;
}

    .compact-cell.on {
        background: var(--accent-yellow);
        box-shadow: 0 0 3px var(--accent-yellow);
    }

.ram-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: #fff;
    font-family: 'Consolas', monospace;
    font-size: 12px;
}

    .ram-row .index {
        min-width: 28px;
        font-weight: 700;
        color: #ccc;
    }

/* ============ Status Bar ============ */
.status-bar {
    background: rgba(40, 40, 70, 0.9);
    border: 2px solid var(--accent-cyan);
    border-radius: 8px;
    padding: 14px 20px;
    color: var(--accent-yellow);
    font-family: 'Consolas', monospace;
    font-size: 14px;
    font-weight: 700;
    margin: 20px 0;
    min-height: 50px;
    display: flex;
    align-items: center;
    transition: all 0.3s;
}

    .status-bar.flash {
        background: rgba(255, 215, 0, 0.2);
        box-shadow: 0 0 15px var(--accent-yellow);
    }

/* ============ Animated Bus Lines ============ */
.bus-container {
    position: relative;
    height: 30px;
    margin: 15px 0;
}

.bus-line {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

    .bus-line.active {
        background: rgba(255, 255, 255, 0.15);
    }

        .bus-line.active::before {
            content: '';
            position: absolute;
            top: 0;
            left: -30%;
            width: 30%;
            height: 100%;
            background: var(--bus-color, var(--accent-cyan));
            box-shadow: 0 0 10px var(--bus-color, var(--accent-cyan));
            animation: busFlow 1.2s linear infinite;
        }

@keyframes busFlow {
    0% {
        left: -30%;
    }

    100% {
        left: 100%;
    }
}

.bus-label {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--bus-color, var(--accent-cyan));
    font-family: 'Consolas', monospace;
    font-size: 11px;
    font-weight: 700;
    background: var(--bg-primary);
    padding: 0 8px;
}

.bus-data {
    --bus-color: var(--accent-cyan);
}

.bus-address {
    --bus-color: var(--accent-green);
}

.bus-output {
    --bus-color: var(--accent-yellow);
}

/* ============ Keyboard ============ */
.keyboard-section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 15px;
    overflow-x: auto;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    min-width: 600px;
}

.kbd-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.kbd-key {
    width: 48px;
    height: 48px;
    background: #2a2a44;
    color: #fff;
    border: 1px solid var(--accent-cyan);
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.1s;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .kbd-key:hover {
        background: rgba(0, 212, 255, 0.3);
        transform: translateY(-2px);
    }

    .kbd-key:active, .kbd-key.pressed {
        background: var(--accent-cyan);
        color: #000;
        transform: translateY(0);
    }

    .kbd-key.special {
        background: rgba(40, 40, 60, 0.5);
        color: #aaa;
        cursor: not-allowed;
        font-size: 11px;
        border-color: rgba(80, 80, 100, 0.5);
    }

    .kbd-key.wide-1 {
        width: 70px;
    }

    .kbd-key.wide-2 {
        width: 90px;
    }

    .kbd-key.wide-3 {
        width: 110px;
    }

    .kbd-key.space {
        width: 280px;
    }

@media (max-width: 768px) {
    .keyboard {
        min-width: 500px;
    }

    .kbd-key {
        width: 38px;
        height: 38px;
        font-size: 12px;
    }

        .kbd-key.wide-1 {
            width: 50px;
        }

        .kbd-key.wide-2 {
            width: 65px;
        }

        .kbd-key.wide-3 {
            width: 80px;
        }

        .kbd-key.space {
            width: 200px;
        }
}

/* ============ Animations ============ */
.flash-effect {
    animation: flashAnim 0.4s;
}

@keyframes flashAnim {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.04);
        filter: brightness(1.4);
    }
}

.pulse-once {
    animation: pulseOnce 0.5s;
}

@keyframes pulseOnce {
    0%, 100% {
        box-shadow: 0 0 0 transparent;
    }

    50% {
        box-shadow: 0 0 20px currentColor;
    }
}

/* ============ Footer ============ */
.app-footer {
    text-align: center;
    padding: 25px;
    color: #888aa8;
    font-size: 13px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 40px;
}

/* ============ RTL Adjustments ============ */
body[dir="rtl"] .voltage-input-row label {
    text-align: right;
}

/* ============ Scrollbar ============ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.3);
    border-radius: 5px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--accent-cyan);
    }
