@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Rajdhani:wght@300;500;700&display=swap');

:root {
    --bg-color: #0d0f11;
    --panel-bg: rgba(18, 22, 28, 0.85);
    --card-bg: rgba(255, 255, 255, 0.03);
    --accent-primary: #00f3ff;
    --accent-secondary: #ff0055;
    --accent-tertiary: #00ff55;
    --text-main: #e0e6ed;
    --text-dim: #8a94a2;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --accent-glow: 0 0 15px rgba(0, 243, 255, 0.3);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    font-family: 'Rajdhani', sans-serif;
    color: var(--text-main);
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    /* Disable default touch actions like scroll/zoom */
}

#app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    /* Prevent scrolling on mobile */
    top: 0;
    left: 0;
}

/* Sidebar Styling */
#ui-container {
    width: 360px;
    background: var(--panel-bg);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

#ui-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

#ui-scroll-area::-webkit-scrollbar {
    width: 3px;
}

#ui-scroll-area::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
}

.brand-header {
    margin-bottom: 30px;
    text-align: center;
}

.brand-header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 4px;
    margin: 0;
    color: var(--text-main);
}

.brand-header h1 span {
    color: var(--accent-primary);
}

.brand-header .version {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-top: 5px;
}

/* Card Concept */
.ui-card {
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
}

.ui-card:hover {
    border-color: rgba(0, 243, 255, 0.2);
}

.card-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    font-weight: 700;
}

/* Inputs & Buttons */
.input-with-button {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

input[type="text"] {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--accent-glow);
}

button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 10px 18px;
    border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 700;
}

button:hover {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
    box-shadow: var(--accent-glow);
}

button.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
}

button.danger:hover {
    background: var(--accent-secondary);
    color: #fff;
    border-color: var(--accent-secondary);
}

button.warning:hover {
    background: #ffaa00;
    color: #000;
    border-color: #ffaa00;
}

.btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-grid.compact {
    grid-template-columns: repeat(2, 1fr);
}

.btn-grid.mini {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.btn-grid.mini button {
    padding: 6px;
    font-size: 0.6rem;
}

.scrollable-grid {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.scrollable-grid::-webkit-scrollbar {
    width: 2px;
}

.scrollable-grid::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
}

/* Sliders */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.badge {
    background: var(--accent-primary);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--accent-glow);
}

/* File Upload Premium */
.file-upload-wrapper label {
    display: block;
    width: 100%;
    padding: 12px;
    background: rgba(0, 243, 255, 0.05);
    border: 1px dashed var(--accent-primary);
    border-radius: 8px;
    color: var(--accent-primary);
    text-align: center;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.3s;
}

.file-upload-wrapper label:hover {
    background: var(--accent-primary);
    color: #000;
    border-style: solid;
}

.file-upload-wrapper input {
    display: none;
}

/* Colors */
.color-picker-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.color-picker-row label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    background: none;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Main Simulation Area */
#canvas-container {
    flex: 1;
    position: relative;
    background: #000;
}

#simCanvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
}

#stats {
    position: absolute;
    bottom: 30px;
    right: 30px;
    color: var(--text-dim);
    font-size: 0.7rem;
    text-align: right;
    pointer-events: none;
    line-height: 1.6;
    font-family: 'Rajdhani', sans-serif;
}

/* MOBILE OVERHAUL */
#mobile-header {
    display: none;
}

@media screen and (max-width: 768px) {
    #app-container {
        flex-direction: column;
    }

    #ui-container {
        display: none;
    }

    .shortcut-overlay,
    #stats {
        display: none;
    }

    /* Show in drawer if needed, but header for live */

    #mobile-header {
        display: flex;
        flex-direction: column;
        padding: max(12px, env(safe-area-inset-top)) 16px 12px 16px;
        background: var(--panel-bg);
        -webkit-backdrop-filter: blur(25px);
        backdrop-filter: blur(25px);
        border-bottom: 1px solid var(--border-subtle);
        border-top: none;
        gap: 12px;
        z-index: 1000;
        position: relative;
    }

    .header-row {
        display: flex;
        gap: 8px;
        align-items: center;
        width: 100%;
    }

    .header-row #mobile-drop-toggle {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 10px;
        background: rgba(255, 0, 85, 0.08);
        border: 1px solid rgba(255, 0, 85, 0.4);
        color: var(--accent-secondary);
        font-weight: 800;
        font-family: 'Orbitron', sans-serif;
        font-size: 0.75rem;
        border-radius: 10px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .header-row #mobile-drop-toggle.active {
        background: var(--accent-secondary);
        color: #fff;
        border-color: var(--accent-secondary);
        box-shadow: 0 0 20px rgba(255, 0, 85, 0.4);
    }

    .header-row #mobile-drop-toggle.active span {
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    }

    .btn-icon {
        width: 16px;
        height: 16px;
    }

    .header-row .mobile-file-wrapper {
        flex: 1.5;
    }

    .mobile-file-wrapper label {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 10px;
        background: rgba(0, 243, 255, 0.08);
        border: 1px solid rgba(0, 243, 255, 0.4);
        color: var(--accent-primary);
        border-radius: 10px;
        font-size: 0.75rem;
        font-weight: 800;
        cursor: pointer;
        font-family: 'Orbitron', sans-serif;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-file-wrapper label:active {
        background: var(--accent-primary);
        color: #000;
        border-color: var(--accent-primary);
        box-shadow: 0 0 20px rgba(0, 243, 255, 0.4);
    }

    .mobile-file-wrapper input {
        display: none;
    }

    .header-row .mobile-colors {
        display: flex;
        gap: 4px;
        padding: 4px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
    }

    .header-row .mobile-colors input {
        width: 28px;
        height: 28px;
    }

    #mobile-count-control {
        flex: 1;
        display: flex;
        flex-direction: column;
        background: rgba(0, 0, 0, 0.2);
        padding: 8px 12px;
        border-radius: 8px;
    }

    #mobile-count-control .label-row {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 6px;
    }

    #mobile-count-control span:not(.badge) {
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--accent-primary);
    }

    .header-row.bottom {
        gap: 8px;
        margin-top: 4px;
    }

    select {
        flex: 1;
        min-width: 0;
        /* Prevent overflow */
        background: rgba(15, 15, 20, 0.9);
        border: 1.5px solid var(--accent-primary);
        color: var(--accent-primary);
        padding: 8px 16px 8px 8px;
        border-radius: 8px;
        outline: none;
        font-family: 'Orbitron', sans-serif;
        font-size: 0.6rem;
        font-weight: 800;
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 20 20' fill='none' stroke='%2300f3ff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 6px center;
    }

    select option {
        background: #1a1a1a;
        color: #fff;
    }

    #mobile-live-text {
        flex: 1.2;
        min-width: 0;
        /* Prevent overflow */
        background: rgba(15, 15, 20, 0.9);
        border: 1.5px solid rgba(0, 243, 255, 0.3);
        color: #fff;
        padding: 8px 10px;
        border-radius: 8px;
        font-size: 0.65rem;
        font-family: 'Orbitron', sans-serif;
        font-weight: 700;
        outline: none;
    }

    #mobile-live-text:focus {
        border-color: var(--accent-primary);
        box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
    }
}