/* ===========================================
   SVG Layout Preview Generator - Styles
   =========================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --sidebar-width: 280px;
    --header-height: 56px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-100);
    overflow: hidden;
}

/* ===========================================
   App Layout
   =========================================== */

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

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    background: var(--gray-800);
    color: white;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.logo i {
    font-size: 20px;
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

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

/* ===========================================
   Sidebar
   =========================================== */

.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--gray-200);
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}
.preset-title {
    margin-bottom: .4rem;
}
.mb-4 {
    margin-bottom: 1rem;
}
/* ===========================================
   Panel
   =========================================== */

.panel {
    border-bottom: 1px solid var(--gray-200);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    background: var(--gray-50);
}

.panel-header i {
    font-size: 14px;
}

.panel-body {
    padding: 12px 16px;
}

/* ===========================================
   Form Elements
   =========================================== */

.form-row {
    margin-bottom: 12px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row select {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: white;
    color: var(--gray-800);
    transition: all 0.15s;
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row input[type="range"] {
    width: calc(100% - 45px);
    vertical-align: middle;
}

.form-row input[type="range"] + span {
    display: inline-block;
    width: 40px;
    text-align: right;
    font-size: 12px;
    color: var(--gray-500);
}

/* Color Input */
.color-input {
    display: flex;
    gap: 8px;
}

.color-input input[type="color"] {
    width: 36px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
}

.color-input input[type="text"] {
    flex: 1;
    font-family: monospace;
    font-size: 12px;
}

/* Checkbox Row */
.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 0;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.checkbox-row span {
    font-size: 13px;
    font-weight: normal;
    color: var(--gray-700);
}

/* ===========================================
   Buttons
   =========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

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

.btn-danger:hover {
    background: #dc2626;
}

/* Actions Row */
.form-row.actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.form-row.actions .btn {
    flex: 1;
}

/* ===========================================
   Presets
   =========================================== */

.preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 0.3fr);
    gap: 10px;
}

.preset-btn {
    aspect-ratio: 4/3;
    padding: 3px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

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

.preset-btn svg {
    width: 100%;
    height: 100%;
}

/* ===========================================
   Shape Buttons
   =========================================== */

.shape-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.shape-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

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

.shape-btn i {
    font-size: 18px;
}

.shape-btn span {
    font-size: 10px;
    font-weight: 500;
}
.mb-4 {
    margin-bottom: 1rem;
}
/* ===========================================
   Canvas Area
   =========================================== */

.canvas-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--gray-200);
    background-image: 
        radial-gradient(circle, var(--gray-300) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: auto;
}

.canvas-container {
    position: relative;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

#svg-canvas {
    display: block;
    width: 500px;
    height: auto;
}

/* Grid Overlay */
.canvas-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0.3;
    z-index: 1;
}

.canvas-grid.hidden {
    display: none;
}

/* Selection Handles */
.selection-handles {
    position: absolute;
    border: 2px solid var(--primary);
    pointer-events: none;
    z-index: 10;
}

.selection-handles.hidden {
    display: none;
}

.selection-handles::before,
.selection-handles::after,
.selection-handles .handle {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 2px;
}

/* Canvas Info */
.canvas-info {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    padding: 8px 16px;
    background: white;
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--gray-500);
    box-shadow: var(--shadow-sm);
}

.canvas-info span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===========================================
   Layers List
   =========================================== */

.layers-list {
    max-height: 200px;
    overflow-y: auto;
}

.no-layers,
.no-selection {
    text-align: center;
    padding: 20px;
    color: var(--gray-400);
    font-size: 13px;
}

.no-selection i {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    background: var(--gray-50);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.layer-item:hover {
    background: var(--gray-100);
}

.layer-item.active {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary);
}

.layer-item .layer-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--gray-300);
}

.layer-item .layer-name {
    flex: 1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-item .layer-actions {
    display: none;
    gap: 4px;
    opacity: 0;
}

.layer-item:hover .layer-actions {
    opacity: 1;
}

.layer-item .layer-actions button {
    padding: 2px 6px;
    font-size: 11px;
    background: transparent;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: 3px;
}

.layer-item .layer-actions button:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* ===========================================
   Color Swatches
   =========================================== */

.color-swatches {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.swatch {
    width: 100%;
    aspect-ratio: 1;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.1s;
}

.swatch:hover {
    transform: scale(1.15);
}

/* ===========================================
   Shape Properties
   =========================================== */

.shape-props.hidden {
    display: none;
}

.no-selection:not(.hidden) + .shape-props {
    display: none;
}

.flex-wrapper {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.flex-wrapper .form-row {
    width: 100%;
}

/* ===========================================
   Modal
   =========================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: transparent;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.hidden {
    display: none;
}
/* Export Preview */
.export-preview {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.export-preview svg {
    max-width: 300px;
    height: auto;
    box-shadow: var(--shadow);
}

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.export-code {
    position: relative;
}

.export-code label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.export-code textarea {
    width: 100%;
    height: 120px;
    padding: 12px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    line-height: 1.6;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--gray-900);
    color: #e5e7eb;
    resize: none;
}

.export-code .btn {
    position: absolute;
    top: 24px;
    right: 8px;
}

/* ===========================================
   Toast
   =========================================== */

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--gray-800);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s;
    z-index: 200;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.hidden {
    display: none;
}

.toast i {
    color: var(--success);
}

/* ===========================================
   SVG Shape Styles
   =========================================== */

#svg-canvas .shape {
    cursor: move;
    transition: filter 0.15s;
}

#svg-canvas .shape:hover {
    filter: brightness(0.95);
}

#svg-canvas .shape.selected {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* ===========================================
   Responsive
   =========================================== */

.flex-wrapper .form-row.w-50 {
    width: 48%;
}

@media (max-width: 1200px) {
    .sidebar {
        width: 220px;
    }
    .flex-wrapper .form-row.w-50 {
        width: 100%;
    }
}

@media (max-width: 992px) {
    .sidebar-right {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar-left {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar-left.open {
        transform: translateX(0);
    }
    
    #svg-canvas {
        width: 100%;
        max-width: 400px;
    }
}
