/* frontend/webapps.css */

/* Layout principal */
.main-layout {
    display: flex;
    min-height: 100vh;
    padding-top: 80px; /* Hauteur du header */
    background: #f8f9fa;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    transition: all 0.3s ease;
    overflow-y: auto;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .search-container,
.sidebar.collapsed .categories-container,
.sidebar.collapsed h5,
.sidebar.collapsed .btn-group {
    display: none;
}

.search-container {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.categories-container {
    flex-grow: 1;
    overflow-y: auto;
}

/* Catégories */
.category-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.category-item:hover {
    background-color: #e9ecef;
}

.category-item.active {
    background-color: #007bff;
    color: white;
    border-left-color: #0056b3;
}

.category-toggle {
    cursor: pointer;
    font-size: 0.8rem;
}

.category-children {
    margin-left: 1rem;
    transition: all 0.3s ease;
}

.category-children.collapsed {
    display: none;
}

.drag-handle {
    cursor: grab;
    opacity: 0.3;
}

.drag-handle:hover {
    opacity: 0.7;
}

/* Zone principale */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-header {
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.content-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Liste des applications */
.app-list {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: #f8f9fa;
}

.app-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

.app-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.app-card.active {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.app-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: #212529;
    margin-bottom: 0.5rem;
}

.app-description {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.app-meta {
    font-size: 0.8rem;
}

.app-meta .badge {
    font-size: 0.7rem;
}

/* Zone de prévisualisation */
.preview-area {
    width: 50%;
    border-left: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    background: white;
}

.preview-controls {
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.preview-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
}

/* Modals */
.modal-lg {
    max-width: 900px;
}

.form-label {
    font-weight: 500;
}

/* Onglets du modal d'import */
#importTabs .nav-link {
    color: #6c757d;
    border-color: transparent;
}

#importTabs .nav-link.active {
    color: #007bff;
    border-color: #007bff #007bff transparent;
    background-color: transparent;
}

#importTabs .nav-link:hover {
    color: #007bff;
    border-color: transparent;
}

/* Textareas de code */
#htmlCode, #cssCode, #jsCode {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

#htmlCode:focus, #cssCode:focus, #jsCode:focus {
    background-color: #ffffff;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Zone d'onglets */
.tab-content {
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 1.5rem;
    background-color: #ffffff;
}

/* Alertes dans les onglets */
.tab-pane .alert {
    margin-bottom: 0;
    border-radius: 6px;
}

/* ========================================
   DARK MODE STYLES
   ======================================== */

[data-bs-theme="dark"] #importTabs .nav-link {
    color: #adb5bd;
}

[data-bs-theme="dark"] #importTabs .nav-link.active {
    color: #0d6efd;
    border-color: #0d6efd #0d6efd transparent;
}

[data-bs-theme="dark"] #importTabs .nav-link:hover {
    color: #0d6efd;
}

[data-bs-theme="dark"] .tab-content {
    background-color: #212529;
    border-color: #495057;
}

[data-bs-theme="dark"] #htmlCode,
[data-bs-theme="dark"] #cssCode,
[data-bs-theme="dark"] #jsCode {
    background-color: #343a40;
    border-color: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] #htmlCode:focus,
[data-bs-theme="dark"] #cssCode:focus,
[data-bs-theme="dark"] #jsCode:focus {
    background-color: #2b3035;
    border-color: #0d6efd;
}

[data-bs-theme="dark"] #dropzone {
    border-color: #495057;
    color: #adb5bd;
}

[data-bs-theme="dark"] #dropzone:hover,
[data-bs-theme="dark"] #dropzone.dragover {
    border-color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.1);
}

[data-bs-theme="dark"] .file-preview {
    background-color: #343a40;
    border-color: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .tab-pane .alert-info {
    background-color: #0c4a6e;
    border-color: #164e63;
    color: #bae6fd;
}

/* Drag and drop */
#dropzone {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

#dropzone:hover,
#dropzone.dragover {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.05);
}

.file-preview {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.5rem;
}

/* Sortable */
.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    cursor: grabbing;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 1000;
        height: calc(100vh - 76px);
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        width: 100%;
    }
    
    .content-body {
        flex-direction: column;
    }
    
    .preview-area {
        width: 100%;
        border-left: none;
        border-top: 1px solid #dee2e6;
        min-height: 300px;
    }
}

@media (max-width: 576px) {
    .main-layout {
        padding-top: 56px; /* Header plus petit sur mobile */
    }
    
    .content-header {
        padding: 0.75rem 1rem;
    }
    
    .app-list {
        padding: 0.75rem;
    }
    
    .app-card {
        padding: 0.75rem;
    }
    
    .sidebar {
        width: 280px;
    }
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-card {
    animation: slideIn 0.3s ease;
}

/* États de chargement */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Badge personnalisés */
.badge.bg-tech {
    background-color: #e3f2fd !important;
    color: #1976d2 !important;
}

.badge.bg-size {
    background-color: #f3e5f5 !important;
    color: #7b1fa2 !important;
}

/* Boutons d'action */
.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Messages d'état */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state .display-4 {
    opacity: 0.5;
    margin-bottom: 1rem;
}

/* Amélioration de l'accessibilité */
.btn:focus,
.form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Indicateurs de statut */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-dot.success {
    background-color: #28a745;
}

.status-dot.warning {
    background-color: #ffc107;
}

.status-dot.error {
    background-color: #dc3545;
}

/* Tooltips personnalisés */
.custom-tooltip {
    position: relative;
}

.custom-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.custom-tooltip:hover::after {
    opacity: 1;
}