/* Website Builder Styles */

/* Sortable.js Ghost Classes */
.sortable-ghost {
    opacity: 0.4;
    background: #f8f9ff !important;
    border: 2px dashed #3498db !important;
}

.sortable-chosen {
    opacity: 0.8;
}

.sortable-drag {
    opacity: 0.6;
}

/* Enhanced Widget Styles */
.widget {
    position: relative;
    transition: all 0.3s ease;
    cursor: move;
}

.widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.widget.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

/* Widget Type Indicators */
.widget[data-widget-type="header"]::before {
    content: "HEADER";
    position: absolute;
    top: -8px;
    left: 10px;
    background: #9b59b6;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.widget[data-widget-type="title"]::before {
    content: "TITLE";
    position: absolute;
    top: -8px;
    left: 10px;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.widget[data-widget-type="text"]::before {
    content: "TEXT";
    position: absolute;
    top: -8px;
    left: 10px;
    background: #3498db;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.widget[data-widget-type="image"]::before {
    content: "IMAGE";
    position: absolute;
    top: -8px;
    left: 10px;
    background: #27ae60;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.widget:hover::before {
    opacity: 1;
}

/* Enhanced Drop Zone */
.drop-zone {
    position: relative;
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    animation: pulse-border 1s infinite;
}

@keyframes pulse-border {
    0% { border-color: #3498db; }
    50% { border-color: #2980b9; }
    100% { border-color: #3498db; }
}

/* Widget Controls Enhancement */
.widget-controls {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 2px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.widget-control-btn {
    transition: all 0.2s ease;
}

.widget-control-btn:hover {
    transform: scale(1.1);
}

.btn-edit:hover {
    background: #e67e22;
}

.btn-delete:hover {
    background: #c0392b;
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    .widget-controls {
        position: static;
        display: flex !important;
        justify-content: center;
        margin-top: 10px;
        background: transparent;
        box-shadow: none;
    }
    
    .widget::before {
        display: none;
    }
    
    .widget {
        margin: 15px 0;
    }
}

/* Loading States */
.widget.loading {
    opacity: 0.6;
    pointer-events: none;
}

.widget.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #3498db;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Success/Error States */
.widget.success {
    border-color: #27ae60;
    background: #d5f4e6;
}

.widget.error {
    border-color: #e74c3c;
    background: #fadbd8;
}

/* Enhanced Modal Styles */
.modal-content {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Enhancements */
.form-control:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.color-picker:hover {
    transform: scale(1.05);
}

/* Toolbar Enhancements */
.sidebar .btn {
    width: 100%;
    margin-bottom: 5px;
}

.sidebar .btn:hover {
    transform: translateX(5px);
}

/* Canvas Enhancements */
.canvas {
    position: relative;
    overflow: hidden;
}

.canvas::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, rgba(52,152,219,0.1) 1px, transparent 1px),
        linear-gradient(rgba(52,152,219,0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.canvas:hover::before {
    opacity: 1;
}

/* Save Status Indicator */
#save-status {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Widget Animation on Add */
.widget.newly-added {
    animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Drag Handle */
.widget::after {
    content: "⋮⋮";
    position: absolute;
    top: 5px;
    right: 50px;
    color: #bdc3c7;
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: move;
}

.widget:hover::after {
    opacity: 1;
}

/* Empty State */
.canvas-inner:empty::before {
    content: "Start building your website by dragging widgets from the sidebar";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #7f8c8d;
    font-size: 18px;
    text-align: center;
    pointer-events: none;
}

/* Accessibility Improvements */
.widget:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.widget-control-btn:focus {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

/* Print Styles */
@media print {
    .sidebar,
    .editor-toolbar,
    .widget-controls {
        display: none !important;
    }
    
    .editor-main {
        margin-left: 0 !important;
    }
    
    .canvas {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}