* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.app-header h1 {
    color: #2d3436;
    font-size: 24px;
    font-weight: 600;
}

.app-header h1 i {
    color: #667eea;
    margin-right: 10px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.btn-danger {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(45deg, #ff5252, #e53935);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebars */
.sidebar, .properties-sidebar {
    width: 340px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.properties-sidebar {
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

.tool-section {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid #eee;
}

.tool-section:last-child {
    border-bottom: none;
}

.tool-section h3 {
    color: #2d3436;
    font-size: 16px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-section h3 i {
    color: #667eea;
}

/* Background Options */
.background-options > div {
    margin-bottom: 15px;
}

.color-picker input, .font-color input {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.gradient-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.gradient-btn {
    padding: 8px;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: transform 0.2s;
}

.gradient-btn:hover {
    transform: scale(1.05);
}

.image-bg-option {
    margin-top: 15px;
}

/* Text Tools */
.text-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
}

.text-properties {
    margin-top: 15px;
}

.text-properties label {
    display: block;
    margin-top: 10px;
    color: #495057;
    font-size: 14px;
}

.text-properties input[type="range"] {
    width: 100%;
    margin: 5px 0;
}

.font-family select {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-top: 5px;
}
.searchinput{
      width: 100%;
  padding: 12px;
  margin: 10px 0;
  box-sizing: border-box;
}

.text-align {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.align-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.align-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Elements Library */
.elements-library {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.element-item {
    padding: 15px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
}

.element-item:hover {
    border-color: #667eea;
    background: #f8f9fa;
    transform: translateY(-2px);
}

.element-item i {
    display: block;
    font-size: 24px;
    margin-bottom: 5px;
    color: #667eea;
}

/* Upload Area */
.upload-area {
    border: 3px dashed #dee2e6;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f8f9fa;
}

.upload-area i {
    color: #667eea;
    margin-bottom: 15px;
}

.upload-hint {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}

/* Canvas Container */
/* Canvas Area with White Background */
.canvas-container {
    flex: 1;
    padding: 25px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
}

.canvas-wrapper {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    width: fit-content;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.canvas-size select {
    padding: 10px 20px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    color: #495057;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.canvas-size select:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

/* Canvas with White Background */
.canvas {
    position: relative;
    background: white;
    border: 2px solid #f0f0f0;
    overflow: hidden;
    cursor: crosshair;
    border-radius: 12px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.02);
}

.canvas-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: white !important; /* Default white background */
}

.elements-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.canvas-footer {
    margin-top: 15px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
}


.canvas-footer {
    margin-top: 15px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

.canvas-footer i {
    color: #667eea;
    margin-right: 8px;
}

/* Element Styles */
.canvas-element {
    position: absolute;
    cursor: move;
    z-index: 10;
    user-select: none;
}

.canvas-element.selected {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.element-text {
    padding: 10px;
    min-width: 100px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.element-shape {
    background: rgba(52, 152, 219, 0.8);
}

.element-image {
    background-size: cover;
    background-position: center;
}

.element-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #f1c40f;
}

/* Properties Sidebar */
.properties-content {
    padding: 10px 0;
}

.property-group {
    margin-bottom: 20px;
}

.property-group label {
    display: block;
    margin-bottom: 8px;
    color: #495057;
    font-size: 14px;
    font-weight: 500;
}

.position-controls, .size-controls {
    display: flex;
    gap: 10px;
}

.pos-input, .size-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
}

#noSelection {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

#noSelection i {
    color: #667eea;
    margin-bottom: 15px;
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    background: #667eea;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    font-size: 28px;
    cursor: pointer;
    transition: transform 0.2s;
}

.close-modal:hover {
    transform: scale(1.2);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.image-grid img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s;
}

.image-grid img:hover {
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 1200px) {
    .sidebar, .properties-sidebar {
        width: 400px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        display: none;
    }
    
    .properties-sidebar {
        position: fixed;
        right: -300px;
        transition: right 0.3s;
    }
    
    .properties-sidebar.active {
        right: 0;
    }
}
/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 2px;
    z-index: 100;
    pointer-events: all;
}

.resize-handle.nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.resize-handle.n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle.s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle.e {
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    cursor: e-resize;
}

.resize-handle.w {
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    cursor: w-resize;
}

/* Rotation Handle */
.rotate-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 101;
}

.rotate-handle i {
    font-size: 12px;
}

/* Element Selection State */
.canvas-element.selected {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.canvas-element.resizing {
    outline: 2px dashed #667eea;
    outline-offset: 2px;
}

.canvas-element.rotating {
    cursor: grabbing;
}

/* Resize Controls */
.resize-controls {
    margin-top: 15px;
}

.resize-options, .snap-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.grid-size {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    background: #e9ecef;
    border-radius: 6px;
}

.grid-size input {
    width: 60px;
    padding: 5px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Guides */
.guide {
    position: absolute;
    background: rgba(102, 126, 234, 0.5);
    z-index: 999;
}

.horizontal-guide {
    width: 100%;
    height: 1px;
    left: 0;
}

.vertical-guide {
    height: 100%;
    width: 1px;
    top: 0;
}

/* Corner Point (Alternative to handles) */
.corner-point {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #667eea;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 100;
    pointer-events: all;
}

.corner-point.nw {
    top: -8px;
    left: -8px;
    cursor: nw-resize;
}

.corner-point.ne {
    top: -8px;
    right: -8px;
    cursor: ne-resize;
}

.corner-point.sw {
    bottom: -8px;
    left: -8px;
    cursor: sw-resize;
}

.corner-point.se {
    bottom: -8px;
    right: -8px;
    cursor: se-resize;
}

/* Bounding Box */
.bounding-box {
    position: absolute;
    border: 1px dashed #667eea;
    pointer-events: none;
    z-index: 99;
}

/* Alternative: Simple Corner Points */
.canvas-element.selected::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #667eea;
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: all;
}

.canvas-element.selected::after {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.canvas-element.selected::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #667eea;
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: all;
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}/* Layer System */
.layer-controls {
    margin-top: 10px;
}

.layer-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.layer-preview {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.layer-preview h4 {
    margin-bottom: 10px;
    font-size: 14px;
    color: #495057;
}

.layer-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.layer-item {
    padding: 8px 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.layer-item:hover {
    background: #e9ecef;
}

.layer-item.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.layer-item i {
    width: 16px;
    text-align: center;
}

.layer-name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-visible {
    color: #28a745;
    cursor: pointer;
}

.layer-hidden {
    color: #dc3545;
    cursor: pointer;
}

.layer-actions {
    display: flex;
    gap: 5px;
}

/* Text Formatting */
.font-style-controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.font-style-group, .text-transform-group {
    display: flex;
    gap: 5px;
}

.font-style-btn, .text-transform-btn {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.font-style-btn:hover, .text-transform-btn:hover {
    background: #e9ecef;
}

.font-style-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.text-transform-btn {
    font-size: 12px;
    font-weight: bold;
}

.text-transform-btn.active {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

/* Enhanced Font Controls */
.font-control-group {
    margin-bottom: 15px;
}

.font-control-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #495057;
    font-weight: 500;
}

.font-size-control, .color-control, .z-index-control, .opacity-control {
    display: flex;
    gap: 8px;
    align-items: center;
}

.font-size-control input[type="range"],
.line-height-control input[type="range"],
.letter-spacing-control input[type="range"] {
    flex: 1;
}

.font-size-control input[type="number"],
.color-control input[type="text"],
.z-index-control input[type="number"],
.opacity-control input[type="number"] {
    width: 70px;
    padding: 6px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
}

.color-control input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.color-control input[type="text"] {
    flex: 1;
}

/* Text Alignment Enhanced */
.text-align {
    display: flex;
    gap: 5px;
}

.text-align button {
    flex: 1;
    padding: 8px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.text-align button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Line Height & Letter Spacing */
.line-height-control, .letter-spacing-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.line-height-control span, .letter-spacing-control span {
    min-width: 40px;
    text-align: right;
    font-size: 13px;
    color: #6c757d;
}

/* Text Shadow Controls */
.text-shadow-controls {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
}

.shadow-control-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.shadow-control-row input {
    flex: 1;
    padding: 6px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
}

.shadow-control-row input[type="color"] {
    width: 40px;
    padding: 2px;
}

/* Text Background & Border */
.text-bg-control, .text-border-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.text-bg-control input[type="color"] {
    width: 40px;
    height: 40px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
}

.text-border-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 8px;
}

.text-border-controls input,
.text-border-controls select {
    padding: 6px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
}

.text-border-controls input[type="color"] {
    padding: 2px;
}

/* Z-Index Controls */
.z-index-buttons {
    display: flex;
    gap: 5px;
}

.z-index-buttons .btn-small {
    padding: 4px 8px;
}

/* Blend Mode */
#blendMode {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    font-size: 13px;
}

/* Element Type Indicators */
.element-type {
    font-size: 10px;
    background: #6c757d;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

/* Dropdown Enhancements */
select {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    cursor: pointer;
}

/* Layer Visibility Toggle */
.visibility-toggle {
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.visibility-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Element Preview in Layers */
.element-preview {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.element-preview.text {
    background: #3498db;
    color: white;
}

.element-preview.shape {
    background: #e74c3c;
}

.element-preview.image {
    background: #2ecc71;
}

.element-preview.icon {
    background: #f39c12;
}

/* Filter Effects */
.filter-controls {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.filter-slider {
    margin-bottom: 10px;
}

.filter-slider label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
}

.filter-slider input[type="range"] {
    width: 100%;
}

/* Smart Guides */
.guide-line {
    position: absolute;
    background: rgba(102, 126, 234, 0.6);
    z-index: 9998;
}

.guide-line.horizontal {
    width: 100%;
    height: 1px;
    left: 0;
}

.guide-line.vertical {
    height: 100%;
    width: 1px;
    top: 0;
}

.guide-label {
    position: absolute;
    background: #667eea;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    z-index: 9999;
    pointer-events: none;
}

/* Element Transform Origin */
.transform-origin-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 10px;
}

.transform-origin-btn {
    padding: 6px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    text-align: center;
}

.transform-origin-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Animation Controls */
.animation-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.animation-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 10px;
}

.animation-preset {
    padding: 6px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    text-align: center;
    transition: all 0.2s ease;
}

.animation-preset:hover {
    background: #f8f9fa;
}

.animation-preset.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}/* Undo/Redo & Group Buttons in Header */
.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-actions .btn {
    padding: 8px 15px;
}

.header-actions .btn i {
    margin-right: 5px;
}

/* Templates Library */
.templates-library {
    margin-top: 10px;
}

.template-category {
    margin-bottom: 20px;
}

.template-category h4 {
    font-size: 14px;
    color: #495057;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #dee2e6;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.template-item {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.template-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.template-preview {
    width: 100%;
    height: 80px;
    border-radius: 4px;
    margin-bottom: 5px;
}

.template-item span {
    display: block;
    text-align: center;
    font-size: 11px;
    color: #6c757d;
}

/* Template Preview Designs */
.youtube-template1 {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    position: relative;
}

.youtube-template1::after {
    content: '🎮';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.youtube-template2 {
    background: linear-gradient(45deg, #3498db, #2980b9);
    position: relative;
}

.youtube-template2::after {
    content: '💻';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.youtube-template3 {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    position: relative;
}

.youtube-template3::after {
    content: '📚';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.youtube-template4 {
    background: linear-gradient(45deg, #9b59b6, #8e44ad);
    position: relative;
}

.youtube-template4::after {
    content: '🎥';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.instagram-template1 {
    background: linear-gradient(45deg, #e84393, #fd79a8);
    position: relative;
}

.instagram-template1::after {
    content: '💬';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.instagram-template2 {
    background: linear-gradient(45deg, #fdcb6e, #e17055);
    position: relative;
}

.instagram-template2::after {
    content: '🔥';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.facebook-template1 {
    background: linear-gradient(45deg, #4267B2, #3b5998);
    position: relative;
}

.facebook-template1::after {
    content: '📅';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.twitter-template1 {
    background: linear-gradient(45deg, #1DA1F2, #0d8bd9);
    position: relative;
}

.twitter-template1::after {
    content: '📢';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.template-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.template-actions .btn-small {
    flex: 1;
}

/* Enhanced Shapes Library */
.shapes-library {
    margin-top: 10px;
}

.shapes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.shape-item {
    padding: 12px 8px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    font-size: 12px;
}

.shape-item:hover {
    border-color: #667eea;
    background: #f8f9fa;
    transform: translateY(-2px);
}

.shape-item i {
    display: block;
    font-size: 18px;
    margin-bottom: 5px;
    color: #667eea;
}

.shape-properties {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.shape-properties > div {
    margin-bottom: 10px;
}

.shape-properties label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #495057;
}

.shape-color input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.shape-border input {
    width: 60px;
    padding: 5px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-align: center;
}

/* Enhanced Layer Drag System */
.layer-drag-handle {
    cursor: grab;
    padding: 5px;
    color: #6c757d;
    transition: color 0.2s;
}

.layer-drag-handle:hover {
    color: #667eea;
}

.layer-item.dragging {
    opacity: 0.5;
    background: #e9ecef;
    border-color: #667eea;
}

.layer-item.drag-over {
    border-top: 2px solid #667eea;
}

/* Group Indicators */
.layer-item .fa-layer-group {
    color: #28a745;
    margin-right: 5px;
}

/* Group Selection */
.canvas-element.group {
    border: 2px dashed #28a745;
}

.canvas-element.group.selected {
    border: 2px solid #28a745;
}

/* Undo/Redo State */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* History Panel (Optional) */
.history-panel {
    position: fixed;
    right: 320px;
    top: 100px;
    width: 200px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 15px;
    z-index: 1000;
    display: none;
}

.history-panel.show {
    display: block;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: 8px;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
    font-size: 12px;
}

.history-item:hover {
    background: #f8f9fa;
}

.history-item.active {
    background: #667eea;
    color: white;
}

/* Drag Preview */
.drag-preview {
    position: absolute;
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed #667eea;
    border-radius: 8px;
    pointer-events: none;
    z-index: 10000;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background: #28a745;
}

.toast.info {
    background: #17a2b8;
}

.toast.warning {
    background: #ffc107;
}

.toast.error {
    background: #dc3545;
}
/* Background Images Section */
.background-images-section {
    margin-bottom: 20px;
}

.background-images-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.background-images-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

.background-images-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

.background-image-item {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.background-image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.background-image-item.dragging {
    opacity: 0.5;
}

.bg-image-preview {
    width: 100%;
    height: 80px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.bg-image-title {
    padding: 8px;
    font-size: 12px;
    text-align: center;
    background: white;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.api-credit {
    text-align: center;
    padding-top: 10px;
    border-top: 1px solid #eee;
    color: #888;
    font-size: 11px;
}

.api-credit a {
    color: #667eea;
    text-decoration: none;
}

.api-credit a:hover {
    text-decoration: underline;
}

.drag-preview.background-preview {
    opacity: 0.8;
}

.loading, .error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #666;
    background: #f9f9f9;
    border-radius: 8px;
}

.error {
    color: #e74c3c;
}
#removeBgBtn {
    margin-top: 15px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border: none;
    transition: all 0.3s ease;
}

#removeBgBtn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
}