:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --tile-bg: rgba(59, 130, 246, 0.2);
    --tile-border: rgba(59, 130, 246, 0.5);
    --tile-hover: rgba(59, 130, 246, 0.3);
    --tile-selected: rgba(16, 185, 129, 0.3);
    --tile-selected-border: rgba(16, 185, 129, 0.8);
    --monitor-bg: #000000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.15), transparent 25%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Typography & Utilities */
h2, h3 { font-weight: 600; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* Glassmorphism utility */
.glass {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-bar {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
    border-bottom: 1px solid var(--panel-border);
    z-index: 10;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Reset the gradient text-fill so the version reads in plain muted text */
.logo .version {
    -webkit-text-fill-color: var(--text-muted);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    vertical-align: middle;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    z-index: 5;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--panel-border);
}

.sidebar-header h2 {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-item {
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-item.selected {
    background: var(--tile-selected);
    border-color: var(--tile-selected-border);
}

.sidebar-item-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.sidebar-item-dims {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Workspace */
.workspace {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.toolbar {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 24px;
    border-bottom: 1px solid var(--panel-border);
    z-index: 5;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.setting-group input {
    width: 70px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.setting-group input:focus {
    border-color: var(--accent);
}

.setting-group select {
    max-width: 200px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.setting-group select:focus {
    border-color: var(--accent);
}

.setting-group select option {
    background: var(--bg-color);
    color: var(--text-main);
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.9rem;
}

.file-input {
    display: block;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.aspect-ratio {
    font-size: 0.8rem;
    background: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

/* Canvas */
.canvas-container {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* Sized to the SCALED monitor dimensions (set from JS), so the layout box
   matches what is visually rendered and the container never overflows. */
.monitor-wrapper {
    flex-shrink: 0;
}

.virtual-monitor {
    background-color: var(--monitor-bg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 2px solid #334155;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    transform-origin: top left;
}

.taskbar-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(8px);
    pointer-events: none;
    z-index: 50;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.taskbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 20px;
    height: 100%;
    opacity: 0.5; /* skeleton look */
}

.taskbar-start {
    width: 24px;
    height: 24px;
    background-color: #38bdf8;
    border-radius: 4px;
}

.taskbar-icons {
    display: flex;
    gap: 12px;
}

.taskbar-icon {
    width: 24px;
    height: 24px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
}

.taskbar-time {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* Tiles */
.tile {
    position: absolute;
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    backdrop-filter: blur(4px);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.tile:hover {
    background: var(--tile-hover);
    z-index: 10;
}

.tile.selected {
    background: var(--tile-selected);
    border-color: var(--tile-selected-border);
    z-index: 20;
}

/* Labels are sized in px and multiplied by --label-scale (= 1 / monitor scale,
   set from JS) so they render at a constant on-screen size and stay readable
   no matter the monitor resolution. */
.tile-label {
    font-weight: 600;
    font-size: calc(14px * var(--label-scale, 1));
    pointer-events: none;
    white-space: nowrap;
}

.tile-dims {
    font-size: calc(11px * var(--label-scale, 1));
    color: rgba(255, 255, 255, 0.7);
    font-family: monospace;
    pointer-events: none;
    margin-top: calc(4px * var(--label-scale, 1));
    white-space: nowrap;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline:hover {
    background: rgba(59, 130, 246, 0.1);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.actions { display: flex; gap: 12px; }

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    padding: 24px;
    border-radius: 12px;
    z-index: 101;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal h3 {
    margin-bottom: 8px;
    font-size: 1.25rem;
}

.modal-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.modal-note {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: rgba(59, 130, 246, 0.08);
    border-left: 2px solid var(--accent);
    border-radius: 4px;
}

.modal-note strong { color: var(--text-main); }

.modal-note code {
    font-family: monospace;
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.35);
    padding: 1px 5px;
    border-radius: 3px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-row label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-row input {
    width: 120px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-family: monospace;
    outline: none;
}
.form-row input:focus { border-color: var(--accent); }

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.split-actions {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--panel-border);
    justify-content: space-between;
}

textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    resize: vertical;
    outline: none;
    margin-bottom: 16px;
}

textarea:focus { border-color: var(--accent); }
