/* Color Theme Variables */
:root {
    /* Background layers (elevation) */
    --color-base: #151621;
    --color-surface-1: #1f2031;
    --color-surface-2: #292a3e;
    --color-surface-3: #33344b;
    --color-overlay-dim: rgba(21, 22, 33, 0.85);

    /* Text */
    --color-text-primary: #f5f5f7;
    --color-text-secondary: #a8aab8;
    --color-text-tertiary: #6b6d7f;

    /* Borders/dividers */
    --color-border-subtle: #23253a;
    --color-border-default: #2f3041;
    --color-border-strong: #3f4058;
    --color-border-hover: #4f5068;

    /* Typography - Font families */
    --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;

    /* Typography - Font sizes */
    --font-xs: 11px;
    --font-sm: 12px;
    --font-base: 13px;
    --font-md: 14px;
    --font-lg: 16px;
    --font-xl: 18px;
    --font-2xl: 20px;
    --font-3xl: 24px;
    --font-4xl: 28px;
    --font-5xl: 32px;

    /* Typography - Font weights */
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    /* Typography - Line heights */
    --leading-tight: 1.2;
    --leading-normal: 1.5;
    --leading-relaxed: 1.8;

    /* Typography - Letter spacing */
    --tracking-tight: -0.01em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;
}

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

/* Base styles */
body {
    font-family: var(--font-system);
    font-size: var(--font-base);
    font-weight: var(--weight-regular);
    line-height: var(--leading-normal);
    background: var(--color-base);
    overflow-x: hidden;
    color: var(--color-text-secondary);
}

/* Container */
#container {
    position: relative;
    width: 100%;
    max-width: calc(800px + 32px);
    margin: 0 auto;
    min-height: 100vh;
    padding: 16px;
    padding-bottom: 100px;
}

/* Widget base styles */
.widget {
    position: absolute;
    background: var(--color-surface-1);
    border: 1px solid var(--color-border-default);
    border-radius: 8px;
    user-select: none;
    transition: box-shadow 0.2s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.widget:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: var(--color-border-strong);
}

.widget.dragging {
    opacity: 0.5;
    z-index: 1000;
}

.widget-title {
    flex: 1;
}

.widget-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.widget-action {
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.widget-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

.drag-handle {
    cursor: grab;
    font-size: var(--font-md);
    user-select: none;
   
}

.drag-handle:active {
    cursor: grabbing;
}

.widget-content {
    padding: 16px;
    color: var(--color-text-secondary);
    font-size: var(--font-base);
    display: none;
}

.widget-header {
    border-bottom: 1px solid var(--color-border-default);
    padding: 12px 16px;
    font-weight: var(--weight-semibold);
    font-size: var(--font-md);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text-primary);
    flex-shrink: 0;
}

.widget-body {
    padding: 16px;
    color: var(--color-text-secondary);
    font-size: var(--font-base);
    line-height: var(--leading-normal);
}

/* Widget type specific */
.widget-type-moonphase {
    border-color: var(--color-border-strong);
}

.widget-type-moonphase:hover {
    border-color: var(--color-border-hover);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay-dim);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.modal-content {
    background: var(--color-surface-3);
    border: 1px solid var(--color-border-strong);
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border-strong);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: var(--weight-semibold);
    font-size: var(--font-lg);
    color: var(--color-text-primary);
}

.modal-close {
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
    color: var(--color-text-secondary);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

.modal-body {
    padding: 24px;
    color: var(--color-text-secondary);
}

/* Toolbar */
#toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface-1);
    border: 1px solid var(--color-border-default);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    display: flex;
    gap: 12px;
    z-index: 100;
}

#toolbar button {
    padding: 10px 20px;
    border: 1px solid var(--color-border-default);
    background: var(--color-surface-2);
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--font-md);
    font-weight: var(--weight-medium);
    transition: all 0.2s;
    color: var(--color-text-primary);
}

#toolbar button:hover {
    background: var(--color-surface-3);
    border-color: var(--color-border-strong);
}

#toolbar button:active {
    transform: scale(0.95);
}

/* Grid lines */
.grid-lines {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    bottom: 16px;
    pointer-events: none;
    z-index: 0;
}

.grid-line {
    position: absolute;
    background: #e0e0e0;
    pointer-events: none;
}

.grid-line.vertical {
    width: 1px;
    height: 100%;
}

/* Drop placeholder */
.drop-placeholder {
    position: absolute;
    left: 16px;
    right: 16px;
    max-width: 800px;
    height: 2px;
    background: var(--color-text-primary);
    opacity: 0;
    pointer-events: none;
    z-index: 1001;
    transition: opacity 0.15s ease;
}

.drop-placeholder.visible {
    opacity: 0.5;
}

/* Playground specific styles */
.playground-container {
    padding: 40px 16px;
}

.playground-container #container {
    padding: 0;
}

.playground-container .widget {
    position: relative;
    margin-bottom: 20px;
}

.playground-container h1 {
    color: var(--color-text-primary);
    margin-bottom: 30px;
    text-align: center;
    font-size: var(--font-4xl);
}
