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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    height: 100vh;
    padding: 10px;
    color: #333;
    overflow: hidden;
}

.container {
    max-width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    display: none;
}

.controls-title {
    font-size: 2.4em;
    margin: 0;
    font-weight: 700;
    letter-spacing: -1px;
    color: #2c3e50;
}

.user-info {
    position: static;
    transform: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 8px 14px;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #e9ecef;
}

.user-avatar {
    width: 35px;
    height: 35px;
    /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 2px;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.user-email {
    font-size: 11px;
    color: #6c757d;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .controls-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

.controls {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 16px 16px 12px 16px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.25);
    margin-bottom: 10px;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: visible;
    z-index: 2000;
}

.controls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

.controls-title {
    flex-shrink: 0;
    margin: 0;
}

.user-info {
    flex-shrink: 0;
}

.controls-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    flex: 1;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 36px;
    cursor: pointer;
    font-size: 17px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    letter-spacing: 0.3px;
}

button:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

button:active:not(:disabled) {
    transform: translateY(-1px);
}

button:disabled {
    background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%);
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

/* Dropdown Menu Styles */
.dropdown-container {
    position: relative;
    display: inline-block;
    z-index: 99999;
}

.dropdown-btn {
    padding: 15px 30px;
    background: linear-gradient(135deg, #48c6ef 0%, #6f86d6 100%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.dropdown-container.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    padding: 15px 10px;
    min-width: 280px;
    z-index: 99999;
    display: none;
    border: 2px solid rgba(102, 126, 234, 0.2);
    max-height: 80vh;
    overflow-y: auto;
}

.dropdown-container.open .dropdown-menu {
    display: block;
    animation: dropdownFadeIn 0.3s ease;
}

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

.dropdown-header {
    font-size: 13px;
    font-weight: 700;
    color: #667eea;
    padding: 10px 12px;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin: 2px 0;
}

.dropdown-item:hover {
    background: rgba(102, 126, 234, 0.1);
}

.dropdown-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #667eea;
}

.dropdown-item span {
    font-size: 15px;
    font-weight: 500;
    color: #2c3e50;
    user-select: none;
}

/* Panel visibility states */
.panel.hidden {
    display: none;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 25px;
    margin-top: 20px;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    transition: grid-template-columns 0.3s ease, grid-template-rows 0.3s ease;
}

.content-grid.pdf-hidden {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.content-grid.pdf-hidden .pdf-panel {
    display: none;
}

.pdf-panel {
    grid-row: 1 / 3;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    .pdf-panel {
        grid-row: auto;
    }
    
    .dropdown-menu {
        left: 0;
        right: auto;
    }
}

.panel {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    min-height: 0;
    overflow: hidden;
}

.panel:hover {
    transform: translateY(-5px);
}

.panel h2 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #2c3e50;
    border-bottom: 3px solid #667eea;
    padding-bottom: 12px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
    min-height: 0;
}

.placeholder {
    text-align: center;
    color: #6c757d;
    padding: 60px 20px;
    font-style: italic;
    font-size: 1.05em;
}

.pdf-preview {
    min-height: 0;
    height: 100%;
    overflow: auto;
    background: #ffffff;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10px;
}

.pdf-preview canvas {
    display: block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
}

.pdf-scroll-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.pdf-page-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.pdf-page-label {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pdf-preview.drag-over {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 3px dashed #667eea;
}

.pdf-preview.drag-over .placeholder {
    color: #667eea;
    transform: scale(1.05);
}

.text-content {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.7;
    color: #2c3e50;
    word-wrap: break-word;
}

.text-content .highlight {
    transition: opacity 0.2s ease, text-decoration 0.2s ease;
}

#modifiedText .text-content {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    cursor: text;
}

/* Légende filtrée */
.legend-item {
    transition: background-color 0.2s ease;
    position: relative;
}

.legend-item:hover {
    background-color: rgba(102, 126, 234, 0.08) !important;
}

.legend-checkbox {
    transition: all 0.2s ease;
}

.legend-checkbox:hover {
    transform: scale(1.1);
}

.legend-item .legend-popover {
    position: absolute;
    top: 110%;
    left: 0;
    min-width: 260px;
    max-width: 320px;
    max-height: 220px;
    overflow: auto;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.12);
    padding: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 5000;
}

.legend-item:hover .legend-popover {
    opacity: 1;
    pointer-events: auto;
}

.legend-popover-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-popover-item {
    padding: 6px 8px;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    font-size: 13px;
    color: #2c3e50;
    word-break: break-word;
}

.legend-popover-empty,
.legend-popover-empty-state .legend-popover-content {
    text-align: center;
    color: #6c757d;
    font-size: 13px;
}

.legend-popover-empty-state {
    border: 1px dashed #ced4da;
}

.legend-item[data-category][aria-disabled="true"] {
    cursor: not-allowed;
}

#fileInput {
    display: none;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    padding: 18px 30px;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.25);
    animation: slideInRight 0.3s ease;
    pointer-events: auto;
    min-width: 300px;
    max-width: 500px;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: space-between;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.toast-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

.toast-close:active {
    transform: scale(0.95);
}

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

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast.removing {
    animation: slideOutRight 0.3s ease forwards;
}

.toast.loading {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    color: #856404;
    border-left: 5px solid #ffc107;
}

.toast.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 5px solid #28a745;
}

.toast.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left: 5px solid #dc3545;
}

.pdf-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 2px solid #e9ecef;
}

.pdf-controls button {
    padding: 10px 20px;
    font-size: 14px;
}

.pdf-controls button.small {
    padding: 8px 16px;
    font-size: 14px;
}

.page-info {
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-selector {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-selector:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.page-selector:hover {
    border-color: #764ba2;
}

.copy-btn {
    padding: 8px 16px;
    font-size: 14px;
    margin-bottom: 0;
}

.copy-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.copy-btn.copied {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.toggle-pdf-btn {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
}

.toggle-pdf-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%) !important;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 15px;
    padding-left: 15px;
    border-left: 2px solid #e9ecef;
}

#zoomLevel {
    font-weight: 600;
    color: #2c3e50;
    min-width: 50px;
    text-align: center;
}
