@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono&display=swap');

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

:root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-dim: #808080;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
}

/* Thème Dark (défaut) */
[data-theme="dark"] {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-dim: #808080;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
}

/* Thème Light */
[data-theme="light"] {
    --bg: #ffffff;
    --surface: #f8f9fa;
    --border: #d0d0d0;
    --text: #1a1a1a;
    --text-dim: #666666;
    --accent: #0066cc;
    --accent-hover: #0052a3;
    --success: #28a745;
}

/* Corrections spécifiques pour le thème light */
[data-theme="light"] .theme-dropdown {
    background: #ffffff !important;
    border-color: #d0d0d0 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
}

/* Forcer tous les textes du dropdown en blanc/clair par défaut */
.theme-dropdown .theme-option {
    color: #e0e0e0 !important;
}

.theme-dropdown .theme-option i {
    color: #e0e0e0 !important;
}

/* Mais en noir quand le thème Light est actif */
[data-theme="light"] .theme-dropdown .theme-option {
    color: #1a1a1a !important;
}

[data-theme="light"] .theme-dropdown .theme-option i {
    color: #1a1a1a !important;
}

[data-theme="light"] .theme-option:hover {
    background: var(--accent) !important;
    color: white !important;
}

[data-theme="light"] .theme-option:hover i {
    color: white !important;
}

[data-theme="light"] .drop-zone {
    background: #f8f9fa;
    border-color: #d0d0d0;
}

[data-theme="light"] .drop-zone:hover {
    background: #e9ecef;
    border-color: var(--accent);
}

[data-theme="light"] .drop-zone.dragover {
    background: #dee2e6;
}

/* Thème Ocean */
[data-theme="ocean"] {
    --bg: #0c1220;
    --surface: #162033;
    --border: #243447;
    --text: #c9d1d9;
    --text-dim: #8b949e;
    --accent: #00bcd4;
    --accent-hover: #00acc1;
    --success: #26a69a;
}

/* Corrections spécifiques pour le thème ocean */
[data-theme="ocean"] .theme-dropdown {
    background: #162033 !important;
    border-color: #243447 !important;
}

[data-theme="ocean"] .theme-option:hover {
    background: var(--accent) !important;
}

[data-theme="ocean"] .drop-zone {
    background: #162033;
    border-color: #243447;
}

[data-theme="ocean"] .drop-zone:hover {
    background: #1a2438;
    border-color: var(--accent);
}

[data-theme="ocean"] .drop-zone.dragover {
    background: #1e2841;
}

/* Thème Forest */
[data-theme="forest"] {
    --bg: #0d1f0d;
    --surface: #1a2f1a;
    --border: #2d4a2d;
    --text: #d4e5d4;
    --text-dim: #8fa68f;
    --accent: #66bb6a;
    --accent-hover: #4caf50;
    --success: #81c784;
}

/* Corrections spécifiques pour le thème forest */
[data-theme="forest"] .theme-dropdown {
    background: #1a2f1a !important;
    border-color: #2d4a2d !important;
}

[data-theme="forest"] .theme-option:hover {
    background: var(--accent) !important;
}

[data-theme="forest"] .drop-zone {
    background: #1a2f1a;
    border-color: #2d4a2d;
}

[data-theme="forest"] .drop-zone:hover {
    background: #1e351e;
    border-color: var(--accent);
}

[data-theme="forest"] .drop-zone.dragover {
    background: #223b22;
}

/* Thème Sunset */
[data-theme="sunset"] {
    --bg: #1a0f1f;
    --surface: #2d1b35;
    --border: #4a2854;
    --text: #f5e6ff;
    --text-dim: #c299d9;
    --accent: #ff6b9d;
    --accent-hover: #ff5283;
    --success: #feca57;
}

/* Corrections spécifiques pour le thème sunset */
[data-theme="sunset"] .theme-dropdown {
    background: #2d1b35 !important;
    border-color: #4a2854 !important;
}

[data-theme="sunset"] .theme-option:hover {
    background: var(--accent) !important;
}

[data-theme="sunset"] .drop-zone {
    background: #2d1b35;
    border-color: #4a2854;
}

[data-theme="sunset"] .drop-zone:hover {
    background: #32203a;
    border-color: var(--accent);
}

[data-theme="sunset"] .drop-zone.dragover {
    background: #37253f;
}

/* Thème Cyberpunk */
[data-theme="cyberpunk"] {
    --bg: #0a0014;
    --surface: #1a0f2e;
    --border: #2d1b50;
    --text: #e0b3ff;
    --text-dim: #b380ff;
    --accent: #00ffff;
    --accent-hover: #00e5e5;
    --success: #39ff14;
}

/* Corrections spécifiques pour le thème cyberpunk */
[data-theme="cyberpunk"] .theme-dropdown {
    background: #1a0f2e !important;
    border-color: #2d1b50 !important;
}

[data-theme="cyberpunk"] .theme-option:hover {
    background: var(--accent) !important;
}

[data-theme="cyberpunk"] .drop-zone {
    background: #1a0f2e;
    border-color: #2d1b50;
}

[data-theme="cyberpunk"] .drop-zone:hover {
    background: #1e1334;
    border-color: var(--accent);
}

[data-theme="cyberpunk"] .drop-zone.dragover {
    background: #22173a;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 20px;
    position: relative;
}

.top-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 100;
}

.lang-selector {
    position: relative;
}

.lang-btn {
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.lang-btn:focus {
    outline: none;
}

.lang-dropdown {
    position: absolute;
    top: 45px;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    min-width: 140px;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.lang-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-option:focus {
    outline: none;
}

.lang-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 20px;
    padding: 0 6px;
    background: var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
}

.lang-option:hover {
    background: var(--accent);
    color: white;
}

.lang-option:hover .lang-code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.lang-option.active {
    background: var(--accent);
    color: white;
}

.lang-option.active .lang-code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.theme-selector {
    position: relative;
}

.theme-btn {
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--border);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    background: var(--accent);
    color: white;
    transform: rotate(15deg);
}

.theme-dropdown {
    position: absolute;
    top: 55px;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    min-width: 150px;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.theme-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.theme-option i {
    width: 20px;
    text-align: center;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.theme-option:hover {
    background: var(--accent) !important;
    color: white !important;
}

.theme-option:hover i {
    color: white !important;
}

.theme-option.active {
    background: var(--accent);
    color: white;
}

.history-btn-top {
    position: static;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 100;
}

.history-btn-top:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

header {
    text-align: center;
    margin-bottom: 60px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

h1 i {
    margin-right: 12px;
    color: var(--accent);
}

.subtitle {
    color: var(--text-dim);
    font-size: 1rem;
}

.drop-zone {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    margin-bottom: 32px;
}

.drop-zone:hover {
    border-color: var(--accent);
    background: var(--surface);
    filter: brightness(0.95);
}

.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--surface);
    filter: brightness(0.9);
}

.upload-icon {
    width: 64px;
    height: 64px;
    stroke: var(--accent);
    margin-bottom: 20px;
}

.drop-text {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.drop-subtext {
    color: var(--text-dim);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.select-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.select-btn:hover {
    background: var(--accent-hover);
}

.tree-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}

.tree-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
    margin-bottom: 24px;
}

.tree-header h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.stats {
    display: flex;
    gap: 24px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.stats i {
    margin-right: 6px;
    color: var(--accent);
}

.controls {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.control-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

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

.control-btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.tree {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
    overflow: auto;
    max-height: 600px;
    padding: 24px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    white-space: pre;
    user-select: text;
}

.tree::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.tree::-webkit-scrollbar-track {
    background: transparent;
}

.tree::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.tree::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

.filter-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.filter-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.filter-hint {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.exclude-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.exclude-input:focus {
    outline: none;
    border-color: var(--accent);
}

.preset-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    min-width: 180px;
    z-index: 10;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.export-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.export-option:hover {
    background: var(--accent);
    color: white;
}

.search-container {
    margin: 16px 0;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-controls {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-results {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.nav-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: opacity 0.2s;
}

.nav-btn:hover {
    opacity: 0.8;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.highlight {
    background: rgba(59, 130, 246, 0.3);
    color: var(--text);
    padding: 0 2px;
    border-radius: 2px;
}

.highlight.current {
    background: rgba(59, 130, 246, 0.6);
    font-weight: bold;
}

/* Adaptation des highlights pour chaque thème */
[data-theme="light"] .highlight {
    background: rgba(0, 102, 204, 0.2);
}

[data-theme="light"] .highlight.current {
    background: rgba(0, 102, 204, 0.4);
}

[data-theme="ocean"] .highlight {
    background: rgba(0, 188, 212, 0.3);
}

[data-theme="ocean"] .highlight.current {
    background: rgba(0, 188, 212, 0.5);
}

[data-theme="forest"] .highlight {
    background: rgba(102, 187, 106, 0.3);
}

[data-theme="forest"] .highlight.current {
    background: rgba(102, 187, 106, 0.5);
}

[data-theme="sunset"] .highlight {
    background: rgba(255, 107, 157, 0.3);
}

[data-theme="sunset"] .highlight.current {
    background: rgba(255, 107, 157, 0.5);
}

[data-theme="cyberpunk"] .highlight {
    background: rgba(0, 255, 255, 0.2);
}

[data-theme="cyberpunk"] .highlight.current {
    background: rgba(0, 255, 255, 0.4);
}

.history-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.history-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.history-header h3 {
    font-size: 1.3rem;
    font-weight: 500;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--border);
    color: var(--text);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
}

.history-item {
    position: relative;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.history-item:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent);
}

.history-item-content {
    flex: 1;
    padding: 12px;
    padding-right: 40px;
    cursor: pointer;
}

.delete-history-item {
    position: absolute;
    right: 8px;
    top: 8px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.9rem;
    opacity: 0;
    z-index: 1;
}

.history-item:hover .delete-history-item {
    opacity: 1;
}

.delete-history-item:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Corrections du bouton delete pour le thème light */
[data-theme="light"] .delete-history-item:hover {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.history-item-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.history-item-info {
    font-size: 0.85rem;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
}

.empty-history {
    text-align: center;
    color: var(--text-dim);
    padding: 40px;
}

.stats-section {
    margin-top: 24px;
}

.stats-toggle {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.stats-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.toggle-icon {
    margin-left: auto;
    transition: transform 0.3s;
}

.stats-toggle.active .toggle-icon {
    transform: rotate(180deg);
}

.stats-content {
    margin-top: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    animation: slideDown 0.3s ease-out;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.stat-card h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card h3 i {
    color: var(--accent);
}

#languageChart {
    max-height: 250px;
}

.top-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.top-file-item:last-child {
    border-bottom: none;
}

.file-name {
    color: var(--text);
    font-size: 0.9rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-left: 12px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.detail-value {
    color: var(--text);
    font-weight: 500;
}

@media (max-width: 768px) {
    .container {
        padding: 40px 20px;
    }
    
    .top-controls {
        top: 10px;
        right: 10px;
    }
    
    .theme-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .history-btn-top {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .drop-zone {
        padding: 40px 24px;
    }
    
    .tree-container {
        padding: 24px 16px;
    }
    
    .stats {
        flex-wrap: wrap;
    }
}