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

/* Variables CSS pour le thème minimaliste */
:root {
    --bg-main: #f8f9fa;
    --bg-primary: #ffffff;
    --bg-secondary: #f0f2f5;
    --bg-hover: #e9ecef;
    --text-primary: #1a1a1a;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --accent: #2c3e50;
    --accent-light: #34495e;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-main: #0d1117;
    --bg-primary: #161b22;
    --bg-secondary: #1c2128;
    --bg-hover: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border-color: #30363d;
    --accent: #58a6ff;
    --accent-light: #79c0ff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', sans-serif;
    background: var(--bg-main);
    min-height: 100vh;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Authentification */
.auth-container {
    max-width: 420px;
    margin: 80px auto;
    background: var(--bg-primary);
    padding: 48px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.auth-container h1 {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 32px;
    font-weight: 600;
    font-size: 26px;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    color: var(--accent);
    margin-bottom: 24px;
    text-align: center;
    font-weight: 500;
    font-size: 20px;
}

.auth-form input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

[data-theme="dark"] .auth-form input:focus {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-form button:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.auth-form p {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-form a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-form a:hover {
    text-decoration: underline;
}

.message {
    display: none;
    padding: 12px 16px;
    margin-top: 16px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

.message.success {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.message.error {
    background-color: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

/* Page principale */
#main-page {
    min-height: 100vh;
}

header {
    background: var(--bg-primary);
    padding: 16px 32px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    color: var(--accent);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info span {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.theme-toggle {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}

#logout-btn {
    padding: 8px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

#logout-btn:hover {
    background: var(--bg-hover);
    border-color: #dc3545;
    color: #dc3545;
}

.main-container {
    display: flex;
    height: calc(100vh - 65px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

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

.sidebar-header h2 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

#add-collection-btn {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#add-collection-btn:hover {
    background: var(--accent-light);
    transform: scale(1.05);
}

.collections-list {
    padding: 12px;
}

.collection-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
}

.collection-item:hover {
    background: var(--bg-secondary);
}

.collection-item.active {
    background: var(--accent);
    color: white;
}

.collection-name {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
}

.delete-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    opacity: 0;
}

.collection-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    color: #dc3545;
}

.collection-item.active .delete-btn {
    color: rgba(255, 255, 255, 0.7);
    opacity: 1;
}

.collection-item.active .delete-btn:hover {
    color: white;
}

/* Contenu principal */
.content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background: var(--bg-main);
}

.content-header {
    margin-bottom: 32px;
}

.content-header h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: 600;
}

.upload-zone {
    background: var(--bg-primary);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    transition: all 0.3s;
}

.upload-zone:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.upload-zone p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 15px;
}

.upload-zone.drag-over p {
    color: white;
}

#browse-btn {
    padding: 10px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

#browse-btn:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
}

/* Grille de fichiers */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.no-files {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
    padding: 48px;
}

.file-card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 0;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s;
    overflow: hidden;
}

.file-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.file-thumbnail-container {
    width: 100%;
    height: 200px;
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.file-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.file-thumbnail-3d {
    width: 100%;
    height: 100%;
}

.file-info {
    padding: 16px;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: var(--text-muted);
    font-size: 13px;
}

.file-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px 16px;
}

.file-actions button {
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

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

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

.detail-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.detail-btn:hover {
    background: var(--bg-hover);
}

.delete-file-btn {
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.delete-file-btn:hover {
    background: #dc3545;
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

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

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    height: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.modal-content.small {
    max-width: 480px;
    height: auto;
}

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

.modal-header h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

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

.close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 15px;
}

.prompt-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.prompt-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

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

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #c82333;
}

#viewer-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.viewer-controls {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: center;
}

.viewer-controls button {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.viewer-controls button:hover {
    background: var(--accent-light);
}

/* Page de détail */
.detail-container {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.back-btn {
    padding: 10px 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--bg-secondary);
}

.detail-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.detail-viewer {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

#detail-viewer-container {
    width: 100%;
    height: 500px;
    max-height: 60vh;
    border-radius: 8px;
    overflow: hidden;
}

.detail-info {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.detail-info h1 {
    color: var(--text-primary);
    margin-bottom: 24px;
    word-wrap: break-word;
    font-size: 22px;
    font-weight: 600;
}

.detail-meta {
    margin-bottom: 24px;
}

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

.meta-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
}

.meta-item span:last-child {
    color: var(--text-primary);
    font-size: 14px;
}

.share-section {
    margin-bottom: 24px;
}

.share-section h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
}

.share-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.share-input-group input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
}

.share-input-group button {
    padding: 10px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.2s;
}

.share-input-group button:hover {
    background: var(--accent-light);
}

.share-toggle {
    display: flex;
    align-items: center;
}

.share-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
}

.share-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#detail-download {
    background: #28a745;
    color: white;
}

#detail-download:hover {
    background: #218838;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .detail-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 300px;
    }

    .files-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        height: 95%;
    }

    header {
        padding: 12px 20px;
    }

    .user-info span {
        display: none;
    }

    .content {
        padding: 20px;
    }
}
