* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overscroll-behavior-y: none;
    height: 100%;
    touch-action: manipulation;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 5px;
    /* Add overscroll-behavior to prevent pull-to-refresh */
   overscroll-behavior-y: none;

}

.containerX {
    max-width: 1200px;
    margin: 0px auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    min-height: 600px;
}

.design-area {
    padding: 0px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
}

.canvas-container {
    background: white;
    border-radius: 15px;
    
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    text-align: center;
}

#design-canvas {
    border: 2px solid #dee2e6;
    border-radius: 10px;
    background: white;
    max-width: 100%;
    height: auto;
}

.side-toggle {
    display: flex;
    background: white;
    border-radius: 10px;
    padding: 5px;
    margin-bottom: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.side-btn {
    padding: 10px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    flex: 1;
}

.side-btn.active {
    background: #667eea;
    color: white;
}

.canvas-controls {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 15px;
    max-height: 768px;
    
}

/* Alternative slide-up drawer style */
@media (max-width: 768px) {
    .canvas-controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-radius: 20px 20px 0 0;
        padding: 25px 20px 40px;
        margin: 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        overflow-y: auto;
        max-height: 70vh;
        
    }
    
    .canvas-controls.active {
        transform: translateY(0);
    }
    
    .canvas-controls::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
    }
    
    .controls-toggle {
        position: fixed;
        bottom: 390px;
        right: 20px;
        width: 50px;
        height: 50px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 50%;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
        z-index: 1001;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
    
    .controls-toggle span {
        display: none;
    }
    
    .controls-toggle::before {
        content: '⋮';
        font-size: 24px;
        font-weight: bold;
    }
    
    .controls-toggle.active::before {
        content: '×';
    }
}

.options-section {
    padding: 30px;
    background: white;
}

.step-content {
    display: none;
    padding: 10px;
}

.step-content.active {
    display: block;
}

.section-title {
    font-size: 1.5em;
    margin-bottom: 25px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.option-group {
    margin-bottom: 0px;
}

.option-label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-wrapper select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1em;
    background: white;
    cursor: pointer;
}

.color-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.color-option.active {
    border-color: #667eea;
    transform: scale(1.1);
}

.text-input-group {
    display: flex;
    gap: 10px;
}

.text-input-group input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1em;
}

.char-counter {
    text-align: right;
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 5px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: fit-content;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-outline {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid #e9ecef;
    gap: 15px;
}

.step-indicator {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    gap: 10px;
    align-items: center;
    padding: 0 20px;
}

.step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #dee2e6;
    transition: all 0.3s ease;
}

.step-dot.active {
    background: #667eea;
    transform: scale(1.2);
}

/* Gallery Container */
#gallery-placeholder, #preImages-placeholder {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    border: 2px dashed #ddd;
    border-radius: 12px;
    background-color: #fafafa;
    margin: 15px 0;
}

/* Empty State */
#gallery-placeholder:empty::before {
    content: "No designs yet. Upload images to see them here!";
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 40px 20px;
}

/* Gallery Items */
.gallery-item {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: white;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Gallery Images */
.gallery-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* Image Overlay Effect */
.gallery-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(0, 123, 255, 0.1), rgba(0, 123, 255, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gallery-item:hover::after {
    opacity: 1;
}

/* Selection Indicator */
.gallery-item.selected {
    border: 3px solid #007bff;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.gallery-item.selected::before {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    background: #007bff;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
}

/* Scrollbar Styling */
#gallery-placeholder::-webkit-scrollbar {
    width: 8px;
}

#gallery-placeholder::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#gallery-placeholder::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#gallery-placeholder::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Section Header */
.gallery-section {
    margin: 25px 0;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
    flex-wrap: wrap;
    gap: 10px;
}

.gallery-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.gallery-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Action Buttons */
.btn-gallery {
    padding: 6px 12px;
    border: 1px solid #007bff;
    background: white;
    color: #007bff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    white-space: nowrap;
}

.btn-gallery:hover {
    background: #007bff;
    color: white;
}

.btn-gallery.delete {
    border-color: #dc3545;
    color: #dc3545;
}

.btn-gallery.delete:hover {
    background: #dc3545;
    color: white;
}

/* ========== RESPONSIVE DESIGN ========== */

/* Large Tablets and Small Laptops (1024px and down) */
@media (max-width: 1024px) {
    .container {
        margin: 10px;
        border-radius: 15px;
    }
    
    .main-content {
        grid-template-columns: 1fr 350px;
    }
    
    .header {
        padding: 25px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .design-area, .options-section {
        padding: 10px;
    }
}

/* Tablets (768px and down) */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        margin: 5px;
        border-radius: 12px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        min-height: auto;
    }
    
    .design-area {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        padding: 20px;
    }
    
    .options-section {
        padding: 20px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.6em;
    }
    
    .header p {
        font-size: 0.9em;
    }
    
    .canvas-container {
        padding: 15px;
    }
    
    #design-canvas {
        max-width: 100%;
        height: 400px;
    }
    
    .side-toggle {
        flex-direction: row;
        gap: 5px;
    }
    
    .side-btn {
        text-align: center;
    }
    
    .canvas-controls {
        flex-direction: row;
        align-items: stretch;
    }
    
    .canvas-controls .btn {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .section-title {
        font-size: 1.3em;
        margin-bottom: 10px;
    }
    
    .option-group {
        margin-bottom: 5px;
        display: flex;
        width: 100%;
        gap: 10px;
    }
    
    .text-input-group {
        flex-direction: column;
    }
    
    
    .navigation .btn {
        width: 100%;
    }
    
    .step-indicator {
        margin: 15px 0;
    }
    
    /* Gallery responsive */
    #gallery-placeholder {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
        padding: 15px;
        max-height: 300px;
    }
    
    .gallery-item img {
        height: 80px;
    }
    
    .gallery-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .gallery-actions {
        justify-content: center;
    }
}

/* Mobile Phones (480px and down) */
@media (max-width: 480px) {
    body {
        padding: 0px;
    }
    
    .container {
        margin: 0;
        border-radius: 10px;
    }
    
    .header {
        padding: 20px 15px;
    }
    
    .header h1 {
        font-size: 1.4em;
    }
    
    .design-area, .options-section {
        padding: 0px;
    }
    
    .canvas-container {
        padding: 5px;
    }
    
    .canvas-controls {
        flex-direction: row;
        justify-content: left;
        
        overflow: auto;
        margin: 10px;
        gap: 2px;
    }
    
    #design-canvas {
        height: 350px;
    }
    
    .section-title {
        font-size: 1.2em;
        margin-bottom: 5px;
        
        gap: 5px;
    }
    
    .option-label {
        font-size: 0.9em;
    }
    
    .select-wrapper select,
    .text-input-group input {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .color-options {
        justify-content: center;
    }
    
    .color-option {
        width: 35px;
        height: 35px;
    }
    
    .btn {
        padding: 10px;
        font-size: 1em;
    }
    
    /* Gallery responsive */
    #gallery-placeholder {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
        padding: 10px;
        max-height: 250px;
    }
    
    .gallery-item img {
        height: 70px;
    }
    
    .gallery-title {
        font-size: 1.1rem;
    }
    .step-content{
        padding:20px;
        width: 400px;
    }
    .step-content.active{
        padding: 20px;
        width: 400px;
    }
    
    .gallery-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-gallery {
        width: 100%;
        text-align: center;
    }
}

/* Small Mobile Phones (360px and down) */
@media (max-width: 360px) {
    .header {
        padding: 15px 10px;
    }
    
    .header h1 {
        font-size: 1.2em;
    }
    
    .design-area, .options-section {
        padding: 10px;
    }
    
    #design-canvas {
        height: 300px;
    }
    
    .section-title {
        font-size: 1.1em;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    #gallery-placeholder {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 6px;
        padding: 8px;
    }
    
    .gallery-item img {
        height: 60px;
    }
}

/* Landscape Mobile Optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .main-content {
        min-height: auto;
    }
    
    #design-canvas {
        height: 250px;
    }
    
    #gallery-placeholder {
        max-height: 200px;
    }
}

/* High Resolution Screens */
@media (min-resolution: 192dpi) {
    .btn {
        /*background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);*/
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .container {
        box-shadow: none;
        margin: 0;
    }
    
    body {
        background: white !important;
        padding: 0;
    }
}

#undo-btn, #redo-btn {
    padding: 8px 12px;
    margin: 2px;
    border: 1px solid #ccc;
    background: #f8f9fa;
    cursor: pointer;
    border-radius: 4px;
}

#undo-btn:hover, #redo-btn:hover {
    background: #e9ecef;
}

#undo-btn:disabled, #redo-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#undo-btn:disabled:hover, #redo-btn:disabled:hover {
    background: #f8f9fa;
}

.spacing-control {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.spacing-slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.spacing-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.spacing-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.spacing-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.spacing-slider::-webkit-slider-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #007bff, #007bff) no-repeat, #ddd;
    background-size: var(--slider-progress, 0%) 100%;
}

.spacing-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}

.spacing-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.spacing-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
    margin-left: 5px;
}

.reset-btn:hover {
    background: #5a6268;
    border-color: #545b62;
}

.spacing-value {
    float: right;
    font-weight: 600;
    color: #007bff;
    background: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    border: 1px solid #e9ecef;
}

/* Responsive design */
@media (max-width: 768px) {
    .spacing-slider-container {
        gap: 8px;
    }
    
    .spacing-btn {
        padding: 6px 10px;
        min-width: 35px;
    }
}

  /* Overlay Background */
        .overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.1);
            display: none;
            z-index: 999;
        }
        
        .overlay.active {
            display: block;
        }

/* Bottom Pop-up */
        .bottom-popup {
            position: fixed;
            bottom: -50%;
            left: 0;
            margin: 0 auto;
            height: 40%;
            background: white;
            border-radius: 20px 20px 0 0;
            box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.2);
            z-index: 1000;
            transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            padding: 20px;
        }
        
        .bottom-popup.active {
            bottom: 0;
        }
        
        .shape-selector {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #f9f9f9;
}

.shape-selector h3 {
    margin-top: 0;
    margin-bottom: 15px;
}

.shape-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.shape-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.shape-option:hover {
    background: #e8f4ff;
    border-color: #007bff;
}

.shape-option.active {
    background: #d4edda;
    border-color: #28a745;
}

.shape-preview {
    width: 40px;
    height: 40px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Shape preview visuals */
.rectangle {
    background: #ff0000;
    border: 2px solid #000;
}

.circle {
    background: #ff0000;
    border: 2px solid #000;
    border-radius: 50%;
}

.triangle {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 30px solid #ff0000;
    background: transparent !important;
}

.line {
    width: 30px;
    height: 4px;
    background: #ff0000;
    transform: rotate(45deg);
}

.arrow {
    position: relative;
    width: 30px;
    height: 4px;
    background: #ff0000;
}

.arrow:after {
    content: '';
    position: absolute;
    right: -8px;
    top: -6px;
    border-left: 8px solid #ff0000;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.star {
    background: #ff0000;
    clip-path: polygon(
        50% 0%, 61% 35%, 98% 35%, 68% 57%, 
        79% 91%, 50% 70%, 21% 91%, 32% 57%, 
        2% 35%, 39% 35%
    );
}

.heart {
    background: #ff0000;
    clip-path: path("M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z");
}

.shape-color-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shape-color-picker label {
    font-weight: bold;
}

.shape-color-picker input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

       .quote-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  max-height: 300px; /* Fixed height */
  overflow-y: auto; /* Vertical scroll */
  padding-right: 5px; /* Space for scrollbar */
  scrollbar-width: thin; /* For Firefox */
  scrollbar-color: #5e35b1 #f5f5f5; /* For Firefox */
}

/* Scrollbar styling for Webkit browsers */
.quote-list::-webkit-scrollbar {
  width: 6px;
}

.quote-list::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 3px;
}

.quote-list::-webkit-scrollbar-thumb {
  background: #5e35b1;
  border-radius: 3px;
}

.quote-option {
  padding: 0.8rem;
  background: var(--light-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quote-option:hover {
  background: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}