:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.main-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.main-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.main-header p {
    color: var(--text-secondary);
}

.configurator-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    flex: 1;
    min-height: 0; /* Important for scrolling */
}

/* Sidebar Controls */
.sidebar-controls {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    border: 1px solid var(--border-color);
}

.control-group h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.input-wrapper {
    margin-bottom: 1rem;
}

.input-wrapper label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

select, input[type="text"] {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select:disabled {
    background-color: #f1f5f9;
    cursor: not-allowed;
    opacity: 0.7;
}

.model-info {
    background-color: #f8fafc;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-top: 1rem;
}

.model-info.hidden {
    display: none;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-row .label {
    color: var(--text-secondary);
}

.info-row .value {
    font-weight: 600;
}

/* Text Lines */
.text-line-input {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.line-input-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.text-line-input input {
    flex: 1;
}

.line-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.mini-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    min-width: 80px;
}

.mini-input {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 50px;
    text-align: center;
}

.style-btn {
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.style-btn:hover {
    background-color: #f1f5f9;
}

.style-btn.active {
    background-color: #eff6ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.remove-line-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto; /* Push to right */
}

.remove-line-btn:hover {
    background-color: #fee2e2;
}

.btn-secondary {
    width: 100%;
    padding: 0.625rem;
    background-color: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

/* Alignment Buttons */
.align-buttons {
    display: flex;
    gap: 0.5rem;
}

.align-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
}

.align-btn.active {
    background-color: #eff6ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Action Area */
.action-area {
    margin-top: auto;
    padding-top: 1rem;
}

.download-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-primary {
    width: 100%;
    padding: 0.875rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-primary:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

/* Preview Area */
.preview-area {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.preview-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8fafc;
}

.preview-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.zoom-controls button {
    width: 24px;
    height: 24px;
    border: none;
    background: #f1f5f9;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-secondary);
}

.zoom-controls button:hover {
    background: #e2e8f0;
}

.zoom-controls span {
    font-size: 0.8rem;
    min-width: 40px;
    text-align: center;
}

.canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
        linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    overflow: auto;
    padding: 2rem;
}

.placeholder-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
}

/* SVG Styles */
svg {
    box-shadow: var(--shadow-lg);
    background: white;
    max-width: 100%;
    max-height: 100%;
}

@media (max-width: 1024px) {
    .configurator-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar-controls {
        max-height: 400px;
    }
}
