/* ===================================
   Melis Platform CMS - Main Styles
   =================================== */

:root {
    --melis-red: #dc2626;
    --sidebar-width: 250px;
    --header-height: 50px;
    --melis-orange: #ff6b35;
    --melis-purple: #6b46c1;
    --melis-blue: #3b82f6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    overflow-x: hidden;
}

/* Red scrollbars everywhere */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-left: 1px solid #e5e5e5;
}

*::-webkit-scrollbar-thumb {
    background: #dc2626;
    border-radius: 0;
}

*::-webkit-scrollbar-thumb:hover {
    background: #b91c1c;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #dc2626 #f5f5f5;
}

/* Main Layout */
.main-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header Styles */
.melis-header {
    background: #dc2626;
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border: none;
    overflow: hidden;
}

.melis-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    color: white;
    width: var(--sidebar-width);
    flex-shrink: 0;
}

.melis-logo-icon {
    width: 32px;
    height: 32px;
    background: white;
    color: #dc2626;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 4px;
}

.melis-logo span {
    color: white;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Header Navigation */
.header-nav {
    padding: 0 15px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.header-nav .nav-item {
    color: white;
    text-decoration: none;
    padding: 0 15px;
    background: transparent;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
    height: 100%;
}

.header-nav .nav-item:hover {
    background: rgba(0, 0, 0, 0.1);
    color: white;
    text-decoration: none;
}

.header-nav .nav-item i {
    font-size: 12px;
}

/* Tabs Container */
.tabs-container {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    overflow: hidden;
    height: 100%;
    position: relative;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tab {
    background: rgba(255, 255, 255, 0.15);
    padding: 10px 20px;
    padding-bottom: 12px;
    margin-bottom: -2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
    transition: all 0.2s;
    height: calc(100% - 2px);
    flex-shrink: 0;
}

.tab.active {
    background: white;
    color: #333;
    border-bottom: 2px solid white;
}

.tab:hover:not(.active) {
    background: white;
    color: #333;
}

.tab i {
    font-size: 12px;
}

.tab-text {
    font-size: 13px;
}

.tab-close {
    background: none;
    border: none;
    color: currentColor;
    opacity: 0.6;
    font-size: 14px;
    line-height: 1;
    padding: 0 0 0 8px;
    margin-left: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover .tab-close {
    opacity: 1;
}

.tab-close:hover {
    color: #dc2626;
    opacity: 1;
}

/* Bouton + retiré - les nouveaux tabs sont créés uniquement via le générateur AI
.add-tab {
    background: white;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    color: #999;
    height: calc(100% - 2px);
    display: flex;
    align-items: center;
    transition: all 0.2s;
    margin-bottom: -2px;
    flex-shrink: 0;
}

.add-tab:hover {
    background: #f8f8f8;
    color: #dc2626;
}
*/

/* Removed secondary header - not needed */

/* Duplicate tab styles removed - using the ones defined above
.tab {
    background: #f5f5f5;
    padding: 8px 16px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    border: 1px solid transparent;
}

.tab.active {
    background: var(--melis-red);
    color: white;
}

.tab:hover:not(.active) {
    background: #e5e5e5;
}

.tab-icon {
    font-size: 14px;
}

.tab-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    margin-left: 8px;
    opacity: 0.7;
}

.tab-close:hover {
    opacity: 1;
}
*/

/* Add tab button styles now in header-center section above */

/* Header Actions */
.header-actions {
    display: flex;
    gap: 15px;
    margin-left: auto;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
}

.header-actions button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    padding: 8px;
    cursor: pointer;
    font-size: 16px;
    position: relative;
}

.header-actions button:hover {
    color: white;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--melis-red);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: #1a202c;
    color: #e2e8f0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #2d3748;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
}

.user-status {
    font-size: 12px;
    color: #68d391;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 15px 0;
}

.sidebar-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.sidebar-item:hover {
    background: #2d3748;
}

.sidebar-item.active {
    background: var(--melis-red);
}

.sidebar-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    background: #4a5568;
}

.sidebar-icon.red { background: var(--melis-red); }
.sidebar-icon.orange { background: var(--melis-orange); }
.sidebar-icon.purple { background: var(--melis-purple); }
.sidebar-icon.blue { background: var(--melis-blue); }

.sidebar-expand {
    margin-left: auto;
    font-size: 18px;
}

/* Sidebar Tree */
.sidebar-tree {
    display: none;
    padding: 0;
}

.sidebar-tree.expanded {
    display: block;
}

.sidebar-tree-item {
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.sidebar-tree-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Sidebar Search */
.sidebar-search {
    padding: 10px 15px;
    background: #2d3748;
    border: 0;
    border-radius: 4px;
    color: white;
    width: 100%;
}

.sidebar-search::placeholder {
    color: #a0aec0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #2d3748;
    font-size: 10px;
    color: #718096;
    margin-top: auto;
}

/* Page Navigation Bar */
.page-nav-bar {
    background: #f8f9fa;
    padding: 0;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    overflow-x: auto;
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
}

.page-nav-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6c757d;
    transition: all 0.2s;
    white-space: nowrap;
}

.page-nav-btn:hover {
    background: rgba(0,0,0,0.03);
    color: #495057;
}

.page-nav-btn.active {
    color: #495057;
    border-bottom-color: #dc2626;
    background: white;
}

.page-nav-btn i {
    font-size: 14px;
}

/* Content Wrapper */
.content-wrapper {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);  /* Add margin to compensate for fixed header */
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;  /* Ensure content is not clipped */
    position: relative;
}

/* Page Title Bar */
.page-title-bar {
    background: #f8f9fa;  /* Light gray/white background */
    padding: 12px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 10;
    min-height: 50px;
}

.hidden-initially {
    display: none;
}

.page-title {
    font-size: 14px;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    color: #495057;  /* Dark gray text */
}

.page-number {
    color: #495057;
    font-weight: 400;
}

.page-name {
    color: #495057;
    font-weight: 400;
    text-transform: uppercase;
}

.page-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-success {
    background: #28a745;
    color: white;
}

.status-label {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
}

/* Page Editor Tabs (below toolbar) */
.page-editor-tabs {
    background: #f7f7f7;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.editor-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background: transparent;
    border: none;
    color: #757575;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-width: 70px;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
}

.editor-tab i {
    font-size: 22px;
    margin-bottom: 6px;
    display: block;
    color: #757575;
}

.editor-tab span {
    display: block;
    font-size: 10px;
    line-height: 1.3;
    white-space: nowrap;
    font-weight: 400;
    color: #757575;
    margin-top: 2px;
}

.editor-tab:hover {
    background: rgba(0, 0, 0, 0.04);
}

.editor-tab:hover i,
.editor-tab:hover span {
    color: #dc2626;
}

.editor-tab.active {
    background: transparent;
}

.editor-tab.active i,
.editor-tab.active span {
    color: #dc2626;
}

.editor-tab.active::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: #dc2626;
    border-radius: 3px 3px 0 0;
}

/* Toolbar */
.melis-toolbar {
    background: #f8f9fa;
    padding: 8px 15px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    gap: 3px;
    align-items: center;
}

.toolbar-section-separator {
    width: 1px;
    height: 24px;
    background: #dee2e6;
    margin: 0 8px;
}

.toolbar-btn {
    padding: 6px 12px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    transition: all 0.2s;
    color: #495057;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.toolbar-btn i {
    font-size: 14px;
}

.toolbar-btn.btn-ai {
    background: var(--melis-red);
    color: white;
    border-color: var(--melis-red);
}

.toolbar-btn.btn-ai:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.toolbar-btn.success {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.toolbar-btn.success:hover {
    background: #059669;
    border-color: #059669;
}

/* Content Area */
.melis-content {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    position: relative;
}

/* Padding only for specific content */
#page-a-content,
.welcome-content {
    padding: 20px;
}

/* Welcome Content */
.welcome-content {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.welcome-content h1 {
    font-size: 36px;
    margin-bottom: 10px;
}

.welcome-content .subtitle {
    font-size: 18px;
    color: #999;
}

/* Generated Content */
.generated-content {
    padding: 0;
    width: 100%;
    min-height: 100%;
    background: white;
}

.generated-content.page-b-content,
.generated-content.page-c-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
}

/* Melis Button Style */
.btn-melis-primary {
    background: var(--melis-red);
    color: white;
    border: none;
}

.btn-melis-primary:hover {
    background: #b91c1c;
    color: white;
}

/* Modal Styles */
#aiGeneratorBtn {
    position: fixed;
    top: 15px;
    right: 20px;
    z-index: 1001;
    padding: 10px 20px;
    background: var(--melis-red);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#aiGeneratorBtn:hover {
    background: #b91c1c;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Radio options for generation modes */
.radio-option {
    padding: 15px;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.radio-option:hover {
    border-color: var(--melis-red);
    background: #fff5f5;
}

.radio-option.selected {
    border-color: var(--melis-red);
    background: #fef2f2;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-option label {
    cursor: pointer;
    margin: 0;
}

#previewFrame {
    width: 100%;
    height: 500px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

.spinner-border {
    color: var(--melis-red);
}

/* Description panel styles */
.description-panel {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    height: 500px;
    overflow-y: auto;
}

/* Description panel scrollbar */
.description-panel::-webkit-scrollbar {
    width: 10px;
}

.description-panel::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-left: 1px solid #e5e5e5;
}

.description-panel::-webkit-scrollbar-thumb {
    background: #dc2626;
    border-radius: 0;
}

.description-panel::-webkit-scrollbar-thumb:hover {
    background: #b91c1c;
}

/* Firefox scrollbar for description panel */
.description-panel {
    scrollbar-width: thin;
    scrollbar-color: #dc2626 #f5f5f5;
}

/* Preview container styles */
.preview-container {
    height: 500px;
    overflow: hidden;
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
}

.preview-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

.preview-container .code-view {
    width: 100%;
    height: 100%;
    max-height: 500px;
    overflow-y: auto;
    padding: 15px;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    border-radius: 8px;
    margin: 0;
}

/* Code view scrollbar */
.code-view::-webkit-scrollbar {
    width: 10px;
}

.code-view::-webkit-scrollbar-track {
    background: #2e2e2e;
}

.code-view::-webkit-scrollbar-thumb {
    background: #dc2626;
    border-radius: 0;
}

.code-view::-webkit-scrollbar-thumb:hover {
    background: #b91c1c;
}

/* Firefox scrollbar for code view */
.code-view {
    scrollbar-width: thin;
    scrollbar-color: #dc2626 #2e2e2e;
}

/* Modal specific overrides */
.modal-dialog.modal-xl {
    max-width: 90%;
    margin: 1.75rem auto;
}

.modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 30px;
}

/* Modal body scrollbar */
.modal-body::-webkit-scrollbar {
    width: 10px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-left: 1px solid #e5e5e5;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #dc2626;
    border-radius: 0;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #b91c1c;
}

.modal-body {
    scrollbar-width: thin;
    scrollbar-color: #dc2626 #f5f5f5;
}

/* Context menu styles - Dark theme */
.context-menu {
    position: fixed;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    padding: 4px 0;
    z-index: 10000;
    min-width: 180px;
    display: none;
}

.context-menu.show {
    display: block;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: #4a5568;
}

.context-menu-item i {
    width: 16px;
    margin-right: 10px;
    font-size: 14px;
    color: #cbd5e0;
}

/* Specific icon colors */
.context-menu-item[data-action="new"] i {
    color: #48bb78; /* Green for New */
}

.context-menu-item[data-action="new-ai"] i {
    color: #dc2626; /* Red for AI */
}

.context-menu-item[data-action="edit"] i {
    color: #ed8936; /* Orange for Edit */
}

.context-menu-item[data-action="duplicate"] i {
    color: #4299e1; /* Blue for Duplicate */
}

.context-menu-item[data-action="duplicate-tree"] i {
    color: #9f7aea; /* Purple for Duplicate tree */
}

.context-menu-item[data-action="export"] i {
    color: #38b2ac; /* Teal for Export */
}

.context-menu-item[data-action="import"] i {
    color: #f6ad55; /* Orange for Import */
}

.context-menu-separator {
    height: 1px;
    background-color: #4a5568;
    margin: 4px 0;
}

/* Preview tabs in modal - closer to preview area */
.preview-tabs {
    border-bottom: none !important;
    margin-bottom: -1px !important;
}

.preview-tabs .nav-link {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px 4px 0 0;
    margin-right: 2px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-bottom: none;
    color: #6c757d;
}

.preview-tabs .nav-link:hover {
    background: white;
    color: #dc2626;
}

.preview-tabs .nav-link.active {
    background: white;
    border-color: #dee2e6;
    color: #dc2626;
    border-bottom: 1px solid white;
    margin-bottom: -1px;
    z-index: 1;
    position: relative;
}

.preview-container {
    border: 1px solid #dee2e6;
    border-radius: 0 0 4px 4px;
    background: white;
    margin-top: 0;
}