/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.header h1 {
    color: #667eea;
    font-size: 1.8rem;
    font-weight: 700;
}

.header h1 i {
    margin-right: 0.5rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.screen {
    display: block;
}

.screen.hidden {
    display: none;
}

/* Format Selection */
.format-selection {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.format-selection h2 {
    margin-bottom: 2rem;
    color: #333;
    font-size: 2rem;
    font-weight: 600;
}

.format-options {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.format-option {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-width: 200px;
}

.format-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.format-option.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.format-preview {
    width: 120px;
    height: 120px;
    margin: 0 auto 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    background: #f8f9fa;
}

.format-preview.square {
    width: 120px;
    height: 120px;
}

.format-preview.vertical {
    width: 80px;
    height: 140px;
}

.format-option h3 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.format-option p {
    color: #666;
    font-size: 0.9rem;
}

/* Editor */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.canvas-area {
    display: flex;
    flex-direction: column;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.canvas-actions {
    display: flex;
    gap: 1rem;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
}

.canvas {
    position: relative;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.canvas.square {
    width: 400px;
    height: 400px;
}

.canvas.vertical {
    width: 300px;
    height: 533px;
}

.canvas-background {
    width: 100%;
    height: 100%;
    position: relative;
    background: #f8f9fa;
}

.upload-area {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.upload-area i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.upload-area p {
    color: #666;
    font-size: 1.1rem;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.canvas-overlay .component {
    pointer-events: auto;
}

/* Components Panel */
.components-panel {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 1.5rem;
    height: fit-content;
}

.components-panel h3 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
}

.components-list {
    margin-bottom: 2rem;
}

.component-item {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: grab;
    transition: all 0.3s ease;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.component-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.component-item:active {
    cursor: grabbing;
}

.component-item i {
    color: #667eea;
    font-size: 1.2rem;
}

.component-item span {
    font-weight: 500;
    color: #333;
}

/* Templates Section */
.templates-section {
    border-top: 1px solid #ddd;
    padding-top: 1.5rem;
}

.templates-list {
    margin-bottom: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.template-item {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #eee;
}

.template-item:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.template-item h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.template-item p {
    font-size: 0.8rem;
    color: #666;
}

/* Pieces List */
.pieces-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.pieces-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.pieces-header h2 {
    color: #333;
    font-size: 1.8rem;
    font-weight: 600;
}

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
}

.filter-group select,
.filter-group input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.pieces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.piece-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.piece-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.piece-preview {
    width: 100%;
    height: 200px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.piece-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.piece-info {
    padding: 1rem;
}

.piece-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.piece-info p {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.piece-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.piece-actions .btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #eee;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Component Styles */
.component {
    position: absolute;
    border: 2px solid transparent;
    cursor: move;
    transition: all 0.3s ease;
    min-width: 50px;
    min-height: 30px;
}

.component:hover {
    border-color: #667eea;
}

.component:hover .edit-btn {
    opacity: 1;
}

.component.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.component .resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #667eea;
    border: 1px solid white;
    border-radius: 50%;
    cursor: nw-resize;
    bottom: -4px;
    right: -4px;
}

.component .edit-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 28px;
    height: 28px;
    background: #667eea;
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
}

.component .edit-btn:hover {
    background: #5a6fd8;
    transform: scale(1.1);
}

.component.selected .edit-btn {
    opacity: 1;
}

/* Text Component */
.text-component {
    padding: 0.5rem;
    word-wrap: break-word;
    line-height: 1.4;
}

/* Seller Component */
.seller-component {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.seller-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.seller-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.seller-info p {
    font-size: 0.8rem;
    color: #666;
}

/* Tag Component */
.tag-component {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

/* Price Component */
.price-component {
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.price-component .price-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.price-component .price-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

/* Image Component */
.image-component {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.image-component img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Responsive */
@media (max-width: 768px) {
    .editor-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .components-panel {
        order: -1;
    }
    
    .canvas {
        width: 100% !important;
        height: 300px !important;
    }
    
    .format-options {
        flex-direction: column;
        align-items: center;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .pieces-grid {
        grid-template-columns: 1fr;
    }
}

/* Image Gallery */
.image-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.image-options .btn {
    width: 100%;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.gallery-item {
    border: 2px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.gallery-item p {
    padding: 0.5rem;
    font-size: 0.8rem;
    text-align: center;
    color: #666;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
