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

:root {
    --primary: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --gray: #6b7280;
    --light: #f9fafb;
    --border: #e5e7eb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f3f4f6;
    height: 100vh;
    overflow: hidden;
}

/* LAYOUT 2 COLONNES */
.app-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    height: 100vh;
    gap: 0;
}

.projects-panel, .chat-panel {
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.projects-panel {
    border-right: 1px solid var(--border);
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.panel-header h1, .panel-header h2 {
    font-size: 20px;
    font-weight: 600;
}

/* BUTTONS */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary {
    background: white;
    color: var(--primary);
}

.btn-icon {
    background: rgba(255,255,255,0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 20px;
}

/* SEARCH BAR */
.search-container {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-search {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 50px;
}

.btn-search:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}

/* FILTRES */
.filters {
    display: flex;
    gap: 8px;
    padding: 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}

.filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* STATS */
.quick-stats {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    background: var(--light);
    font-size: 13px;
    color: var(--gray);
}

/* PROJECTS LIST */
.projects-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.project-card {
    padding: 16px;
    margin-bottom: 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.project-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.project-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.project-meta {
    font-size: 12px;
    color: var(--gray);
    display: flex;
    gap: 12px;
}

/* CHAT */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--light);
}

.chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-content {
    background: white;
    padding: 12px;
    border-radius: 12px;
    max-width: 70%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.user .message-content {
    background: var(--primary);
    color: white;
}

.chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: white;
}

.chat-input-container textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    margin-bottom: 8px;
}

.chat-input-container textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-xl {
    max-width: 1200px;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--gray);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* TABS */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    color: var(--gray);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

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

/* UPLOAD ZONE */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    color: var(--gray);
    margin-bottom: 20px;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--light);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .chat-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
    }
}

/* ============================================== */
/* FILE TREE EXPLORER (Windows style)            */
/* ============================================== */
.file-tree {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    user-select: none;
}

.file-tree-item {
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background 0.15s;
}

.file-tree-item:hover {
    background: #e8f4fd;
}

.file-tree-item.selected {
    background: #cce8ff;
}

.tree-icon {
    margin-right: 6px;
    font-size: 14px;
    width: 16px;
    display: inline-block;
    text-align: center;
}

.tree-toggle {
    cursor: pointer;
    margin-right: 4px;
    font-size: 12px;
    width: 12px;
    display: inline-block;
    text-align: center;
    color: #666;
}

.tree-toggle.collapsed::before {
    content: '▶';
}

.tree-toggle.expanded::before {
    content: '▼';
}

.tree-toggle.empty {
    visibility: hidden;
}

.tree-children {
    margin-left: 20px;
    display: none;
}

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

.tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-file .tree-label {
    color: #333;
}

.tree-folder .tree-label {
    font-weight: 500;
    color: #000;
}

/* Double-click feedback */
.file-tree-item.file-opening {
    background: #b3d9ff;
}

/* ============================================== */
/* CODE PREVIEW (style Google Drive)             */
/* ============================================== */
.code-preview {
    background: #1e1e1e;
    border-radius: 8px;
    overflow: hidden;
}

.code-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
}

.code-language {
    background: #0078d4;
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.code-lines {
    color: #888;
    font-size: 12px;
}

.btn-copy {
    margin-left: auto;
    background: #404040;
    border: none;
    color: #ccc;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: #505050;
    color: white;
}

.code-content {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #d4d4d4;
    background: #1e1e1e;
    max-height: 60vh;
    overflow-y: auto;
}

.code-content code {
    display: block;
    white-space: pre;
}

.line-number {
    display: inline-block;
    width: 45px;
    color: #5a5a5a;
    text-align: right;
    padding-right: 16px;
    margin-right: 16px;
    border-right: 1px solid #333;
    user-select: none;
}

/* Scrollbar style pour code */
.code-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.code-content::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.code-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 5px;
}

.code-content::-webkit-scrollbar-thumb:hover {
    background: #666;
}
