/* Reset et configuration de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
}

.editor-container {
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    position: relative;
    overflow: hidden;
}

/* Conteneur scrollable */
.pdf-scroll-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: auto;
    padding: 120px 20px;
}

.pdf-wrapper {
    min-height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.pdf-scroll-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.pdf-scroll-container::-webkit-scrollbar-track {
    background: rgba(20, 25, 40, 0.6);
}

.pdf-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(142, 68, 173, 0.5);
    border-radius: 6px;
}

.pdf-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(142, 68, 173, 0.7);
}

/* Écran d'importation */
.upload-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    overflow-y: auto;
}

.home-container {
    width: 100%;
    max-width: 1200px;
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.home-header {
    text-align: center;
    margin-bottom: 50px;
}

.home-title {
    font-size: 48px;
    font-weight: 700;
    color: white;
    margin-bottom: 12px;
    letter-spacing: -1px;
}

.home-subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 300;
    letter-spacing: 0.5px;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.action-card {
    padding: 40px;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.action-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.action-icon {
    width: 64px;
    height: 64px;
    color: white;
    margin-bottom: 20px;
    opacity: 0.9;
}

.action-title {
    font-size: 22px;
    font-weight: 600;
    color: white;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.action-description {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 300;
    letter-spacing: 0.3px;
}

.recent-section {
    margin-top: 40px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: white;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
}

.recent-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.file-card {
    padding: 20px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 16px;
}

.file-card:hover {
    transform: translateX(4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.file-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #8E44AD 0%, #9b59b6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.file-info {
    flex: 1;
    min-width: 0;
}

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

.file-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 300;
}

.no-files {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 300;
    border-radius: 16px;
}

input[type="file"] {
    display: none;
}

/* Canvas PDF */
.pdf-canvas {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 20px 0;
}

.page-container {
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    background: white;
    margin: 0 auto;
    transition: opacity 0.2s ease;
}

.page-container.zooming {
    opacity: 0.7;
}

.page-container canvas {
    display: block;
    background: white;
}

.pdf-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 18px;
    font-weight: 300;
    letter-spacing: 2px;
}

/* Style solide moderne (sans glassmorphism) */
.glass {
    background: rgba(30, 35, 55, 0.95);
    border: 1px solid rgba(100, 110, 150, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Variante pour les cartes interactives */
.glass.action-card:hover,
.glass.file-card:hover {
    background: rgba(40, 45, 65, 0.98);
    border-color: rgba(142, 68, 173, 0.4);
}

/* Navigation Bar */
.nav-bar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 24px;
    border-radius: 50px;
    z-index: 1000;
    animation: fadeInDown 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-bar:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* Logo JacPDF */
.logo-button {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 12px 24px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    animation: fadeInLeft 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-button:hover {
    transform: translateX(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.logo-text span {
    background: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, 0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.doc-name {
    font-size: 14px;
    font-weight: 500;
    color: white;
    letter-spacing: 0.5px;
    user-select: none;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-button {
    background: rgba(50, 55, 75, 0.9);
    border: 1px solid rgba(100, 110, 150, 0.3);
    border-radius: 12px;
    padding: 8px 16px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-button:hover {
    background: rgba(60, 65, 85, 1);
    border-color: rgba(142, 68, 173, 0.5);
    transform: scale(1.05);
}

.nav-button.primary {
    background: linear-gradient(135deg, #8E44AD 0%, #9b59b6 100%);
    border: 1px solid rgba(142, 68, 173, 0.5);
}

.nav-button.primary:hover {
    box-shadow: 0 4px 16px rgba(142, 68, 173, 0.4);
}

/* Bouton Paramètres (Haut à droite) */
.settings-button {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    animation: fadeInRight 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-button:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.settings-button svg {
    color: white;
    width: 24px;
    height: 24px;
}

/* Bouton Download (À côté de Settings) */
.download-button {
    position: fixed;
    top: 20px;
    right: 96px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    animation: fadeInRight 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.1s both;
    background: linear-gradient(135deg, #8E44AD 0%, #9b59b6 100%);
}

.download-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(142, 68, 173, 0.4);
}

.download-button svg {
    color: white;
    width: 24px;
    height: 24px;
}

/* Boutons Undo/Redo (Gauche) */
.history-controls {
    position: fixed;
    top: 20px;
    left: 200px;
    display: flex;
    gap: 12px;
    z-index: 1000;
    animation: fadeInLeft 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.history-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
}

.history-button:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.history-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.history-button svg {
    color: white;
    width: 20px;
    height: 20px;
}

/* Panneau de Paramètres */
.settings-panel {
    position: fixed;
    top: 90px;
    right: 20px;
    width: 320px;
    border-radius: 20px;
    padding: 24px;
    z-index: 1001;
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.settings-panel::-webkit-scrollbar {
    width: 8px;
}

.settings-panel::-webkit-scrollbar-track {
    background: rgba(20, 25, 40, 0.6);
    border-radius: 4px;
}

.settings-panel::-webkit-scrollbar-thumb {
    background: rgba(142, 68, 173, 0.5);
    border-radius: 4px;
}

.settings-title {
    font-size: 20px;
    font-weight: 600;
    color: white;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}

.settings-section {
    margin-bottom: 20px;
}

.settings-separator {
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(142, 68, 173, 0.3) 50%, 
        transparent 100%);
    margin: 24px 0;
}

.credits-section {
    margin-bottom: 0;
}

.credits-content {
    background: rgba(20, 25, 40, 0.4);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(100, 110, 150, 0.2);
}

.credit-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
}

.credit-icon {
    width: 18px;
    height: 18px;
    color: #8E44AD;
    flex-shrink: 0;
}

.credit-text {
    letter-spacing: 0.3px;
}

.credit-version {
    margin-top: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(142, 68, 173, 0.15) 0%, rgba(155, 89, 182, 0.15) 100%);
    border-radius: 8px;
    border: 1px solid rgba(142, 68, 173, 0.3);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.credit-copyright {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(100, 110, 150, 0.2);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.settings-label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    display: block;
    letter-spacing: 0.3px;
}

.language-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(40, 45, 65, 0.8);
    border: 1px solid rgba(100, 110, 150, 0.3);
    color: white;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

.language-select:hover {
    background: rgba(50, 55, 75, 0.9);
    border-color: rgba(142, 68, 173, 0.5);
    transform: translateY(-2px);
}

.language-select option {
    background: #1a1a2e;
    color: white;
    padding: 12px;
}

/* Contrôles de Navigation et Zoom (Bas à droite) */
.page-controls {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 50px;
}

.control-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(50, 55, 75, 0.9);
    border: 1px solid rgba(100, 110, 150, 0.3);
}

.control-button:hover:not(:disabled) {
    background: rgba(60, 65, 85, 1);
    border-color: rgba(142, 68, 173, 0.5);
    transform: scale(1.1);
}

.control-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.control-button svg {
    color: white;
    width: 18px;
    height: 18px;
}

.page-info {
    font-size: 13px;
    font-weight: 500;
    color: white;
    padding: 0 8px;
    user-select: none;
    min-width: 60px;
    text-align: center;
}

.zoom-info {
    font-size: 13px;
    font-weight: 500;
    color: white;
    padding: 0 4px;
    user-select: none;
    min-width: 50px;
    text-align: center;
}

/* Toolbar */
.toolbar {
    position: fixed;
    display: flex;
    gap: 8px;
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    will-change: transform;
}

.toolbar.grabbing {
    cursor: grabbing;
    transition: none;
    will-change: top, left;
}

.toolbar.vertical {
    flex-direction: column;
    padding: 16px 12px;
    border-radius: 20px;
}

.toolbar.horizontal {
    flex-direction: row;
    padding: 12px 16px;
    border-radius: 50px;
}

.toolbar.vertical:hover {
    transform: translateX(4px);
}

.toolbar.horizontal:hover {
    transform: translateY(-4px);
}

.toolbar.grabbing:hover {
    transform: none;
}

.toolbar.magnetic {
    box-shadow: 0 0 0 3px rgba(142, 68, 173, 0.4);
}

.tool-button {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(40, 45, 65, 0.8);
    border: 1px solid rgba(100, 110, 150, 0.3);
    position: relative;
}

.tool-button:hover {
    background: rgba(50, 55, 75, 0.9);
    border-color: rgba(142, 68, 173, 0.5);
    transform: scale(1.1);
}

.tool-button.active {
    background: linear-gradient(135deg, #8E44AD 0%, #9b59b6 100%);
    border-color: rgba(142, 68, 173, 0.7);
    box-shadow: 0 4px 16px rgba(142, 68, 173, 0.4);
}

.tool-button svg {
    color: white;
    width: 22px;
    height: 22px;
}

.tool-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid rgba(142, 68, 173, 0.3);
}

.toolbar.vertical .tool-tooltip {
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
}

.toolbar.horizontal .tool-tooltip {
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
}

.tool-button:hover .tool-tooltip {
    opacity: 1;
}

/* Text Elements */
.text-element {
    position: absolute;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    cursor: move;
    user-select: none;
    will-change: transform;
}

.text-element.dragging {
    transition: none;
    will-change: left, top;
}

.text-element.selected {
    border-color: #8E44AD;
    box-shadow: 0 0 0 1px rgba(142, 68, 173, 0.3);
}

.text-content {
    width: 100%;
    height: 100%;
    padding: 8px;
    outline: none;
    border: none;
    background: transparent;
    font-family: 'Outfit', sans-serif;
    resize: none;
    overflow: hidden;
    cursor: text;
}

.text-content[contenteditable="false"] {
    cursor: move;
    user-select: none;
}

.text-content[contenteditable="true"] {
    background: rgba(142, 68, 173, 0.1);
    border: 2px dashed rgba(142, 68, 173, 0.4);
    cursor: text;
    user-select: text;
}

/* Poignées de contrôle */
.control-handles {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    pointer-events: none;
}

.handle {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #8E44AD;
    border: 2px solid white;
    pointer-events: all;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.handle:hover {
    transform: scale(1.3);
    box-shadow: 0 4px 12px rgba(142, 68, 173, 0.4);
}

.handle.delete {
    background: #E67E22;
    top: 0;
    left: 0;
    cursor: pointer;
}

.handle.resize-tr { top: 0; right: 0; cursor: nesw-resize; }
.handle.resize-br { bottom: 0; right: 0; cursor: nwse-resize; }
.handle.resize-bl { bottom: 0; left: 0; cursor: nesw-resize; }

.handle.rotate {
    bottom: -5px;
    left: -5px;
    background: linear-gradient(135deg, #8E44AD 0%, #9b59b6 100%);
    cursor: grab;
}

.handle.rotate:active {
    cursor: grabbing;
}

.handle svg {
    width: 12px;
    height: 12px;
    color: white;
}

/* Menu Contextuel */
.context-menu {
    position: fixed;
    min-width: 180px;
    border-radius: 12px;
    padding: 8px;
    z-index: 2000;
    animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.context-item {
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 13px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    background: rgba(40, 45, 65, 0.6);
    margin-bottom: 4px;
}

.context-item:last-child {
    margin-bottom: 0;
}

.context-item:hover {
    background: rgba(142, 68, 173, 0.6);
    transform: translateX(4px);
}

.context-item svg {
    width: 16px;
    height: 16px;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .pdf-canvas canvas {
        max-width: 90vw;
        height: auto !important;
    }
}
