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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
    line-height: 1.6;
}

/* App layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 80px;
    background: #2c3e50;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.logo {
    width: 40px;
    height: 40px;
    background: #3498db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-bottom: 30px;
    font-size: 18px;
}

.sidebar-btn {
    width: 50px;
    height: 50px;
    background: transparent;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    margin: 5px 0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-weight: 500;
}

.sidebar-btn:hover, .sidebar-btn.active {
    background: #34495e;
    color: #3498db;
    transform: translateY(-1px);
}

.sidebar-btn svg {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

/* Main content */
.main-content {
    flex: 1;
    position: relative;
    display: flex;
}

.viewer-container {
    flex: 1;
    position: relative;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 100%);
}

#viewer {
    width: 100%;
    height: 100%;
}

/* Top toolbar */
.top-toolbar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.toolbar-left, .toolbar-right {
    display: flex;
    gap: 10px;
}

.toolbar-btn {
    background: white;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-weight: 500;
}

.toolbar-btn:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.toolbar-btn.active, .view-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* Configuration panel */
.config-panel {
    width: 400px;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 50;
    height: 100vh;
}

.config-panel.open {
    transform: translateX(0);
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #7f8c8d;
    padding: 5px;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.panel-content {
    padding: 20px;
}

/* Form elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-control select {
    cursor: pointer;
}

/* Slider controls */
.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider {
    flex: 1;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: #2980b9;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider-value {
    min-width: 50px;
    text-align: right;
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
}

/* Checkbox groups */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #3498db;
    cursor: pointer;
}

.checkbox-group label {
    cursor: pointer;
    user-select: none;
}

/* Bay configuration */
.bay-config {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    background: #f9f9f9;
}

.bay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.bay-number {
    font-weight: 600;
    color: #2c3e50;
}

.remove-bay {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-bay:hover {
    background: #c0392b;
}

.add-bay {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.add-bay:hover {
    background: #229954;
}

/* Extras grid */
.extras-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.extra-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    text-align: center;
}

.extra-item:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.extra-item.selected {
    border-color: #3498db;
    background: #f8f9fa;
}

.extra-icon {
    width: 40px;
    height: 40px;
    background: #ecf0f1;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #7f8c8d;
}

.extra-item.selected .extra-icon {
    background: #3498db;
    color: white;
}

.extra-label {
    font-size: 12px;
    color: #2c3e50;
    font-weight: 500;
}

/* Color picker */
.color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.color-option {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.color-option:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.color-option.selected {
    border-color: #3498db;
    transform: scale(1.1);
}

.color-option::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.color-option.selected::after {
    opacity: 1;
}

/* Template modal */
.template-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.template-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(1);
    transition: transform 0.3s ease;
}

.template-modal.hidden .modal-content {
    transform: scale(0.9);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.template-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}

.template-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #7f8c8d;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.template-tab:hover {
    color: #3498db;
}

.template-tab.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.template-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border: 2px solid #ecf0f1;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.template-item:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.template-preview {
    width: 120px;
    height: 80px;
    background: #ecf0f1;
    border-radius: 8px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    border: 1px solid #ddd;
}

.template-shape {
    position: absolute;
    background: #95a5a6;
    border-radius: 2px;
}

.template-name {
    font-weight: 500;
    color: #2c3e50;
    text-align: center;
}

/* Loading */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #27ae60;
    color: white;
    padding: 15px 20px;
    border-radius: 6px;
    z-index: 1002;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.toast.hidden {
    transform: translateX(100%);
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: #e74c3c;
}

/* Dimension labels */
.dimensions-display {
    position: absolute;
    color: #2c3e50;
    font-size: 12px;
    font-weight: bold;
    background: rgba(255,255,255,0.9);
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Quote section */
.quote-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.quote-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.quote-item:last-child {
    border-bottom: none;
    font-weight: 600;
    font-size: 16px;
}

.quote-label {
    color: #2c3e50;
}

.quote-value {
    color: #27ae60;
    font-weight: 500;
}

.quote-total {
    background: #27ae60;
    color: white;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    margin-top: 20px;
}

/* Responsive design */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    
    .sidebar-btn {
        width: 40px;
        height: 40px;
        font-size: 8px;
    }
    
    .sidebar-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .config-panel {
        width: 100%;
    }
    
    .templates-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .extras-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .color-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}