/* Calligram Creator Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    overflow: hidden;
    touch-action: none;
}

#container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    position: relative;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 16px 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

header p {
    font-size: 14px;
    opacity: 0.9;
    margin: 4px 0 0 0;
}

#canvas {
    flex: 1;
    min-height: 0;
    width: 100%;
    background: #fff;
    cursor: crosshair;
    touch-action: none;
    display: block;
}

.toggle-btn {
    position: absolute;
    top: 80px;
    left: 10px;
    z-index: 1000;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    transform: scale(1.05);
}

.toggle-btn:active {
    transform: scale(0.95);
}

#controls {
    position: fixed;
    left: 0;
    top: 72px;
    bottom: 0;
    background: #fff;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 4px 0 12px rgba(0,0,0,0.08);
    overflow-y: auto;
    width: 300px;
    z-index: 999;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#controls.hidden {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.control-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Size and color row - keep them side by side */
.control-row:has(input[type="number"]) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
}

.control-row:has(input[type="number"]) > label {
    grid-column: 1 / -1;
}

.control-row:has(input[type="number"]) > label:nth-of-type(2) {
    grid-column: auto;
}

.control-row:has(input[type="number"]) > input,
.control-row:has(input[type="number"]) > label:not(:first-child) {
    margin: 0;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    color: #333;
    font-size: 16px;
    transition: border-color 0.2s, background 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
}

input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    color: #333;
    font-size: 16px;
    transition: border-color 0.2s;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
}

input[type="color"] {
    width: 100%;
    height: 44px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    background: #fafafa;
}

button {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

button:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.3);
}

button.danger {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

button.danger:hover {
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
}

button.secondary {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

button.secondary:hover {
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.button-row {
    display: flex;
    gap: 10px;
}

.button-row button {
    flex: 1;
}

/* Color Palette */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.color-swatch.active {
    transform: scale(1.2);
    box-shadow: 0 0 0 3px #667eea, 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Hide number input spinners on mobile */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #controls {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
        padding: 16px;
        gap: 12px;
    }

    #controls.hidden {
        transform: translateY(100%);
    }

    .toggle-btn {
        top: auto;
        bottom: 10px;
        right: 10px;
        left: auto;
    }

    header h1 {
        font-size: 20px;
    }

    header p {
        font-size: 12px;
    }

    label {
        font-size: 13px;
    }

    button {
        padding: 12px 16px;
        font-size: 15px;
    }

    .color-swatch {
        width: 28px;
        height: 28px;
    }

    .color-palette {
        gap: 6px;
    }
}
