:root {
    --bg-main: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.5);
    
    --font-family: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 350px;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    overflow-y: auto;
    flex-shrink: 0;
}

.logo h1 {
    font-weight: 700;
    font-size: 1.8rem;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--accent);
}

/* Dropzone */
.upload-section {
    position: relative;
}

.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255,255,255, 0.02);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 15px var(--accent-glow);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    pointer-events: none;
}

.upload-icon {
    color: var(--accent);
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease;
}

.dropzone:hover .upload-icon {
    transform: translateY(-5px);
}

.dropzone p {
    font-size: 0.95rem;
    color: var(--text-main);
}

.text-sm {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Loading */
.loading-indicator {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Metrics Panel (Etats 2 placeholder) */
.metrics-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.metric-card {
    background: rgba(255,255,255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.metric-value {
    font-weight: 600;
    color: var(--text-main);
}

/* Quote Section (Étape 3) */
.quote-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.premium-select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    appearance: none;
    cursor: pointer;
}

.premium-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.quote-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.01) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.quote-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.price-highlight {
    font-size: 1.2rem;
    font-weight: 700;
    color: #4ade80; /* Vert pour l'argent */
}

.complexity-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.5rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.simple {
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
}

.status-dot.complex {
    background: #f97316;
    box-shadow: 0 0 8px #f97316;
}

.mt-2 {
    margin-top: 1rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:disabled {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.3);
    cursor: not-allowed;
}

/* --- VIEWER AREA --- */
.viewer-area {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    display: flex;
    flex-direction: column;
}

.viewers-wrapper {
    display: flex;
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
}

#viewer-container {
    flex: 1;
    height: 100%;
    position: relative;
}

#flat-pattern-container {
    width: 50%;
    flex-shrink: 0;
    height: 100%;
    background: #ffffff;
    border-left: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#flat-pattern-container.hidden {
    width: 0 !important;
    border-left: none !important;
    min-width: 0 !important;
}

.flat-pattern-header {
    padding: 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #0f172a;
}

.flat-pattern-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 1rem;
}

.flat-pattern-content img, .flat-pattern-content svg {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Canvas Three.js */
#viewer-container canvas {
    display: block;
    outline: none;
}

.viewer-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    color: var(--text-muted);
}

.viewer-placeholder h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: rgba(255,255,255, 0.5);
}

.viewer-controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    gap: 1rem;
}

.btn-icon {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}

/* --- MODALS --- */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
}

.modal-large {
    max-width: 800px;
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close-modal:hover {
    color: var(--text-main);
}

.premium-input {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.8rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    margin-top: 0.5rem;
}

.auth-switch {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

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

/* Auth Section in Sidebar */
.auth-section {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

#authLogged p {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Table in Modal */
.table-container {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1.5rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

/* --- PDF TEMPLATE --- */
#pdfTemplate {
    background: white;
    color: black;
    padding: 40px;
    font-family: 'Helvetica', 'Arial', sans-serif;
}

.pdf-header {
    border-bottom: 2px solid #3b82f6;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.pdf-header h2 {
    color: #3b82f6;
    font-size: 28px;
}

.pdf-body p {
    margin: 10px 0;
    font-size: 14px;
}

.pdf-image-container {
    margin-top: 30px;
    text-align: center;
    border: 1px solid #ccc;
    padding: 10px;
    background: #f9f9f9;
}

.pdf-image-container img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.pdf-footer {
    margin-top: 50px;
    text-align: center;
    font-size: 12px;
    color: #666;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

/* --- 3D INTERACTION TOOLBAR --- */
.toolbar-3d {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--accent);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5), 0 0 15px rgba(59, 130, 246, 0.3);
}

.toolbar-3d.hidden {
    display: none;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toolbar-group label {
    font-weight: 600;
    color: var(--text-main);
}

.select-sm {
    padding: 0.5rem;
    font-size: 0.9rem;
}

.toolbar-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Operations List */
.operations-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.operations-section.hidden {
    display: none;
}

.operations-section h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.operations-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.op-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    border-left: 3px solid var(--accent);
}

.op-item button {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    padding: 0 0.5rem;
}

.op-item button:hover {
    color: #f87171;
}

/* --- SPA ARCHITECTURE --- */
.page-section {
    display: none;
    width: 100%;
    height: 100vh;
    flex-direction: column;
    padding-top: 70px;
}

.page-section.active {
    display: flex;
}

/* Header Global */
.global-header {
    height: 70px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
}

.header-logo {
    cursor: pointer;
}

.header-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Nouveau bouton Premium Connexion */
.btn-nav-premium {
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-main);
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.btn-nav-premium:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3) 0%, rgba(59, 130, 246, 0.1) 100%);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    color: #fff;
}

/* Espacement sous le header pour les sections */
#page-home, #page-login, #page-dashboard {
    background: var(--bg-main);
    overflow-y: auto;
}

/* Studio prend toute la hauteur */
#page-studio {
    background: var(--bg-main);
}

/* --- ACCUEIL (HERO) --- */
#page-home {
    position: relative;
    overflow: hidden;
}

.hero-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translateX(-50%) translateY(-50%);
    z-index: 0;
    object-fit: cover;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75); /* Sombre pour rendre le texte très lisible */
    z-index: 1;
}

.hero-container {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.hero-content h1 {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

.hero-content h1 .highlight {
    color: var(--accent);
}

.hero-content p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2.5rem;
    line-height: 1.6;
}

.btn-large {
    font-size: 1.2rem;
    padding: 1rem 3rem;
    border-radius: 50px;
}

.hero-features {
    display: flex;
    gap: 2rem;
    margin-top: 5rem;
    width: 100%;
}

.feature-box {
    flex: 1;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: 12px;
    text-align: left;
    transition: transform 0.3s;
}

.feature-box:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
}

.feature-box h3 {
    color: var(--accent);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* --- LOGIN PAGE --- */
.auth-split {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 70px);
}

.auth-left {
    flex: 1;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border-color);
}

.auth-brand {
    text-align: center;
}

.auth-brand h2 {
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-weight: 300;
}

.auth-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
}

.auth-form-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.auth-form-container h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

/* --- DASHBOARD --- */
.dashboard-layout {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 70px);
}

.dashboard-sidebar {
    width: 250px;
    background: rgba(255,255,255,0.02);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
}

.dashboard-sidebar ul {
    list-style: none;
}

.dashboard-sidebar li {
    padding: 1rem 2rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.dashboard-sidebar li:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.05);
}

.dashboard-sidebar li.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.dashboard-content {
    flex: 1;
    padding: 2rem;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
}

.dashboard-card h3 {
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

