/**
 * Modular widgets styles for Alpi Météo
 */

/* Base Widget Styles */
.alpi-meteo-modular-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    margin: 20px 0;
    position: relative;
}

.alpi-meteo-modular-widget.responsive {
    width: 100%;
    max-width: 100%;
}

.alpi-meteo-modular-widget.preview-mode {
    border: 2px dashed #ccc;
}

/* Widget Sections */
.widget-section {
    position: relative;
}

.section-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
}

/* Widget Columns */
.widget-column {
    flex: 1;
    min-height: 50px;
    position: relative;
}

/* Content Items */
.widget-content-item {
    margin-bottom: 15px;
}

.widget-content-item:last-child {
    margin-bottom: 0;
}

/* Text Content */
.text-content {
    line-height: 1.6;
}

.text-content h1,
.text-content h2,
.text-content h3,
.text-content h4,
.text-content h5,
.text-content h6 {
    margin-top: 0;
    margin-bottom: 10px;
}

.text-content p {
    margin-bottom: 15px;
}

.text-content p:last-child {
    margin-bottom: 0;
}

/* Image Content */
.image-content img {
    max-width: 100%;
    height: auto;
    display: block;
}

.image-placeholder {
    background: #f5f5f5;
    border: 2px dashed #ddd;
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Weather Data Content */
.weather-data-content {
    display: flex;
    align-items: center;
    gap: 5px;
}

.weather-value {
    font-weight: 600;
    color: #2c3e50;
}

/* Calculated Field Content */
.calculated-field-content {
    display: flex;
    align-items: center;
    gap: 5px;
}

.calculated-value {
    font-weight: 600;
    font-size: 1.2em;
    color: #3498db;
}

/* Pictogram Content */
.pictogram-content {
    text-align: center;
}

.pictogram-content img {
    max-width: 100%;
    height: auto;
}

.pictogram-small img {
    width: 32px;
    height: 32px;
}

.pictogram-medium img {
    width: 48px;
    height: 48px;
}

.pictogram-large img {
    width: 64px;
    height: 64px;
}

.pictogram-preview {
    font-size: 48px;
    color: #3498db;
}

/* Empty States */
.empty-column-preview {
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    border-radius: 4px;
}

.unknown-content-type {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 10px;
    border-radius: 4px;
    color: #856404;
    font-size: 12px;
}

/* Error States */
.alpi-widget-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
    margin: 20px 0;
}

/* Loading States */
.widget-loading {
    position: relative;
    opacity: 0.6;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .section-columns {
        flex-direction: column;
    }
    
    .widget-column {
        width: 100% !important;
        margin-bottom: 15px;
    }
    
    .widget-column:last-child {
        margin-bottom: 0;
    }
}

/* Widget Builder Styles */
.alpi-widget-builder {
    display: flex;
    height: 80vh;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.widget-builder-toolbar {
    background: #f8f9fa;
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.widget-builder-canvas {
    flex: 1;
    background: #fff;
    overflow: auto;
    position: relative;
}

.canvas-inner {
    padding: 20px;
    min-height: 100%;
}

.empty-canvas {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    color: #6c757d;
}

.widget-builder-sidebar {
    width: 300px;
    background: #f8f9fa;
    border-left: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
}

.sidebar-tabs {
    display: flex;
    background: #e9ecef;
    border-bottom: 1px solid #dee2e6;
}

.tab-btn {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    color: #6c757d;
}

.tab-btn.active {
    background: #f8f9fa;
    color: #495057;
}

.sidebar-content {
    flex: 1;
    overflow: auto;
}

.tab-panel {
    display: none;
    padding: 20px;
}

.tab-panel.active {
    display: block;
}

/* Content Types Panel */
.content-types h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #495057;
}

.content-type-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.content-type-item:hover {
    background: #e3f2fd;
    border-color: #2196f3;
}

.content-type-item .dashicons {
    color: #6c757d;
}

/* Section Styles in Builder */
.widget-section {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 15px;
    background: #fff;
}

.section-header {
    background: #f8f9fa;
    padding: 8px 12px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-controls {
    display: flex;
    gap: 5px;
}

.btn-icon {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 2px;
    color: #6c757d;
}

.btn-icon:hover {
    background: #e9ecef;
    color: #495057;
}

.section-content {
    padding: 15px;
}

.columns-container {
    display: flex;
    gap: 15px;
    min-height: 100px;
}

/* Column Styles in Builder */
.widget-column {
    border: 1px dashed #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    position: relative;
}

.column-header {
    position: absolute;
    top: 5px;
    right: 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.widget-column:hover .column-header {
    opacity: 1;
}

.column-controls {
    display: flex;
    gap: 2px;
}

.column-content {
    padding: 15px;
    min-height: 80px;
}

.empty-column {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
    color: #6c757d;
    font-style: italic;
    font-size: 12px;
}

/* Content Item Styles in Builder */
.content-item {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 10px;
    overflow: hidden;
}

.content-header {
    background: #f8f9fa;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
}

.content-type {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
}

.content-controls {
    display: flex;
    gap: 5px;
}

.content-preview {
    padding: 12px;
    font-size: 12px;
    color: #6c757d;
}

.text-preview {
    font-style: italic;
}

.image-preview img {
    max-width: 60px;
    max-height: 40px;
    object-fit: cover;
}

.weather-preview,
.generic-preview {
    font-family: monospace;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 2px;
    display: inline-block;
}

.placeholder-preview {
    color: #dc3545;
    font-style: italic;
}

/* Modal Styles */
.alpi-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #495057;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #495057;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow: auto;
}

/* Drag and Drop Styles */
.dragging {
    opacity: 0.5;
}

.drop-zone {
    border: 2px dashed #007cba;
    background: rgba(0, 124, 186, 0.1);
}

.drag-placeholder {
    background: #e3f2fd;
    border: 2px dashed #2196f3;
    height: 40px;
    margin: 5px 0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2196f3;
    font-size: 12px;
}

/* Responsive Builder */
@media (max-width: 1200px) {
    .widget-builder-sidebar {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .alpi-widget-builder {
        flex-direction: column;
        height: auto;
    }
    
    .widget-builder-sidebar {
        width: 100%;
        max-height: 300px;
    }
    
    .widget-builder-canvas {
        min-height: 400px;
    }
    
    .columns-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .widget-column {
        width: 100% !important;
    }
}
