* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #c72c60;
    --secondary-color: #094174;
    --background-light: #f7f8fa;
    --background-blue: #f7fcff;
    --text-dark: #242c31;
    --text-gray: #777;
    --white: #fff;
    --black: #000;
    --shadow: 0 4px 20px rgba(0,0,0,0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Roboto', sans-serif;
    background: var(--background-blue);
    color: var(--text-dark);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header Styles */
.main-header {
    background: var(--white);
    border-bottom: 1px solid #e1e5e9;
    padding: 0 2rem;
    height: 70px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.logo {
    font-family: 'Poppins', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex: 1;
    height: calc(100vh - 70px);
    gap: 0;
    overflow-y: auto;
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    background: var(--white);
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid #e1e5e9;
}

.right-sidebar {
    border-right: none;
    border-left: 1px solid #e1e5e9;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--secondary-color);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

/* Category List */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.category-item:hover {
    background: var(--background-light);
}

.category-item.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.category-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-light);
    border-radius: 50%;
    transition: var(--transition);
    font-size: 20px;
}

.category-item.active .category-icon {
    background: rgba(255,255,255,0.2);
}

/* Design Area */
.design-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-light);
    min-width: 0;
}

.design-toolbar {
    background: var(--white);
    padding: 1rem 2rem;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-btn {
    padding: 0.75rem 1.5rem;
    background: var(--white);
    border: 2px solid #e1e5e9;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    color: var(--text-dark);
    white-space: nowrap;
}

.tool-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Preview Container */
.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: auto;
    min-height: 0;
}

.preview-wrapper {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 100%;
    max-height: 100%;
    overflow: auto;
}

/* Dual Preview Layout */
.dual-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.preview-side {
    text-align: center;
}

.preview-side h3 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.product-preview {
    position: relative;
    width: 100%;
    max-width: 350px;
    height: 400px;
    background: var(--background-blue);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px #e1e5e9;
    margin: 0 auto;
}

.shirt-color-background {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 8px;
    z-index: 1;
    transition: background-color 0.3s ease;
}

.product-base {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 2;
}

.design-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Design Elements */
.design-element {
    position: absolute;
    cursor: move;
    user-select: none;
    max-width: 80%;
    max-height: 80%;
    transition: opacity 0.2s;
    touch-action: none;
}

.text-element {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    text-align: center;
    min-width: 50px;
    word-wrap: break-word;
    cursor: move;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.2;
    position: relative;
    z-index: 10;
}

.image-element {
    border: none;
    background: transparent;
    padding: 0;
    position: relative;
    z-index: 10;
}

.image-element img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.element-controls {
    position: absolute;
    top: -35px;
    right: -10px;
    display: none;
    background: var(--white);
    padding: 0.5rem;
    border-radius: 25px;
    box-shadow: var(--shadow);
    z-index: 1000;
    gap: 0.25rem;
}

.design-element.selected .element-controls {
    display: flex;
}

.control-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--primary-color);
    color: var(--white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
    font-weight: bold;
}

.control-btn:hover {
    transform: scale(1.1);
}

.delete-btn {
    background: #e74c3c;
}

.resize-handle {
    background: var(--secondary-color);
    cursor: nwse-resize;
}

.design-element.selected {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Control Groups */
.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--secondary-color);
}

/* Color Options */
.color-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.color-option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.color-option-item:hover {
    background: var(--background-light);
}

.color-option-item.selected {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.color-option-item input[type="radio"] {
    display: none;
}

.color-swatch {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid #ddd;
    transition: var(--transition);
}

.color-option-item.selected .color-swatch {
    border-color: var(--white);
    transform: scale(1.1);
}

/* Form Elements */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e1e5e9;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    margin-bottom: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(199, 44, 96, 0.1);
}

.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e1e5e9;
    border-radius: var(--border-radius);
    font-size: 14px;
    background: var(--white);
    margin-bottom: 1rem;
}

.text-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.text-controls select {
    flex: 1;
}

.color-input {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    padding: 0;
}

.slider {
    width: 100%;
    margin: 1rem 0;
}

.file-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed #e1e5e9;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    background: var(--background-light);
    cursor: pointer;
}

/* Text Settings */
.text-settings {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.setting-group {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-group label {
    min-width: 80px;
    font-weight: normal;
    color: #555;
    margin-bottom: 0;
}

#font-size {
    flex: 1;
}

#font-size-value {
    min-width: 40px;
    text-align: center;
    font-weight: bold;
}

/* Side Selection */
.side-selection {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.side-selection label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.3s;
    background: var(--background-light);
}

.side-selection label:hover {
    background: #e9ecef;
}

.side-selection input[type="radio"] {
    margin: 0;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: #b52550;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(199, 44, 96, 0.3);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: #07315d;
    transform: translateY(-2px);
}

.export-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem auto;
}

.export-btn:hover {
    background: #219a52;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.3);
}

.export-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.add-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    width: 100%;
    margin-top: 1rem;
}

.add-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.full-width {
    width: 100%;
}

/* Download Section */
.download-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-top: 20px;
    text-align: center;
}

.download-section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

/* Mobile Responsive */
@media (max-width: 1200px) {
    .sidebar {
        width: 280px;
    }
    
    .dual-preview {
        gap: 1.5rem;
    }
    
    .product-preview {
        height: 350px;
        max-width: 300px;
    }
}

@media (max-width: 1024px) {
    .designer-container {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        max-height: 400px;
        overflow-x: auto;
    }
    
    .left-sidebar {
        order: 2;
    }
    
    .design-area {
        order: 1;
    }
    
    .right-sidebar {
        order: 3;
    }
    
    .dual-preview {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .category-list {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 1rem;
    }
    
    .category-item {
        min-width: 150px;
        flex-shrink: 0;
    }
}

@media (max-width: 768px) {
    .main-header {
        padding: 0 1rem;
        height: auto;
        min-height: 70px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 0;
    }
    
    .design-toolbar {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .toolbar-group {
        width: 100%;
        justify-content: center;
    }
    
    .preview-container {
        padding: 0.5rem;
    }
    
    .preview-wrapper {
        padding: 1rem;
    }
    
    .product-preview {
        height: 300px;
        max-width: 280px;
    }
    
    .color-options {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .side-selection {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .sidebar {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .dual-preview {
        gap: 1rem;
    }
    
    .product-preview {
        height: 250px;
        max-width: 220px;
    }
    
    .tool-btn {
        padding: 0.6rem 1rem;
        font-size: 13px;
    }
    
    .color-options {
        grid-template-columns: 1fr 1fr;
    }
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading-spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.design-element {
    animation: fadeInUp 0.3s ease-out;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--background-light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b52550;
}

/* Element Selection */
.design-element {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Drag and Drop Improvements */
.design-element.dragging {
    opacity: 0.8;
    z-index: 1000;
}

.design-element.resizing {
    z-index: 1000;
}


/* Category Icons with Images */
.category-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-light);
    border-radius: 50%;
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

.category-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.category-fallback {
    font-size: 20px;
    color: var(--text-gray);
}

.category-item.active .category-icon {
    background: rgba(255,255,255,0.2);
}

.category-item.active .category-fallback {
    color: var(--white);
}

/* File Upload Area */
.file-upload-area {
    border: 2px dashed #e1e5e9;
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--background-light);
    margin-bottom: 1rem;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: var(--background-blue);
}

.upload-placeholder span {
    display: block;
    font-size: 16px;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.upload-placeholder small {
    color: var(--text-gray);
    font-size: 12px;
}

/* Remove extra icons from buttons */
.tool-btn, .add-btn, .export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Clean up button styles */
.tool-btn::before,
.add-btn::before,
.export-btn::before {
    display: none;
}

/* Loading states */
.loading-spinner {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Current side indicator */
.current-side {
    color: var(--text-dark);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.current-side strong {
    color: var(--primary-color);
}

/* Export status */
#export-status {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 500;
}

/* Mobile responsive improvements */
@media (max-width: 768px) {
    .category-icon {
        width: 40px;
        height: 40px;
    }
    
    .category-icon img {
        padding: 6px;
    }
    
    .category-fallback {
        font-size: 16px;
    }
    
    .file-upload-area {
        padding: 1.5rem;
    }
}