:root {
    --primary: #009639;
    --primary-hover: #007c30;
    --primary-light: #e8f5ec;
    --secondary: #f7d618;
    --accent: #ce1126;
    --background: #f8fafc;
    --surface: #ffffff;
    --foreground: #0f172a;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

/* ============================================
   LAYOUT
   ============================================ */
.detail-page {
    background: var(--background);
    min-height: calc(100vh - 70px);
}

.detail-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}

/* ============================================
   HEADER
   ============================================ */
.detail-header {
    grid-column: 1 / -1;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--muted);
    text-decoration: none;
    transition: var(--transition);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb i {
    width: 14px;
    height: 14px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
}

.header-info {
    flex: 1;
}

.header-badges {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-type {
    background: var(--primary);
    color: white;
}

.badge-correction {
    background: var(--secondary);
    color: var(--foreground);
}

.badge-premium {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.badge-pages {
    background: var(--border-light);
    color: var(--muted);
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

.meta-item i {
    width: 16px;
    height: 16px;
}

.header-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn i {
    width: 18px;
    height: 18px;
}

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

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

.btn-outline {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--border-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================
   CONTENU PRINCIPAL - PAGES
   ============================================ */
.detail-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pages-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.pages-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pages-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--foreground);
}

.pages-title i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.pages-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--border-light);
    border: none;
    border-radius: var(--radius);
    color: var(--muted);
    cursor: pointer;
    transition: var(--transition);
}

.page-nav-btn:hover:not(:disabled) {
    background: var(--primary-light);
    color: var(--primary);
}

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

.page-nav-btn i {
    width: 18px;
    height: 18px;
}

.page-indicator {
    font-size: 0.8125rem;
    color: var(--muted);
    min-width: 80px;
    text-align: center;
}

/* ============================================
   PAGES CONTAINER - PROTECTION
   ============================================ */
.pages-container {
    padding: 1rem;
    background: var(--border-light);
    /* Protection anti-sélection */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.page-wrapper {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.page-wrapper:last-child {
    margin-bottom: 0;
}

.page-image {
    width: 100%;
    height: auto;
    display: block;
    /* Protection anti-drag */
    pointer-events: none;
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-touch-callout: none;
}

/* Overlay transparent pour bloquer l'interaction */
.page-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    z-index: 2;
    cursor: default;
}

.page-number {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.75rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    z-index: 3;
}

/* Mode vue unique (une page à la fois) */
.pages-container.single-view .page-wrapper {
    display: none;
}

.pages-container.single-view .page-wrapper.active {
    display: block;
}

/* Mode toutes les pages */
.pages-container.all-view .page-wrapper {
    display: block;
}

/* Toggle view buttons */
.view-mode-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--border-light);
    padding: 0.25rem;
    border-radius: var(--radius);
}

.view-mode-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    transition: var(--transition);
}

.view-mode-btn.active {
    background: var(--surface);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
}

/* ============================================
   SIDEBAR
   ============================================ */
.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Info Card */
.info-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.info-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-card-header i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.info-card-body {
    padding: 1rem 1.25rem;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 0.8125rem;
}

.info-label {
    color: var(--muted);
}

.info-value {
    color: var(--foreground);
    font-weight: 500;
    text-align: right;
    max-width: 60%;
}

/* Hiérarchie */
.hierarchy-path {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.hierarchy-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--foreground);
}

.hierarchy-item i {
    width: 16px;
    height: 16px;
    color: var(--muted-light);
}

.hierarchy-item a {
    color: var(--primary);
    text-decoration: none;
}

.hierarchy-item a:hover {
    text-decoration: underline;
}

/* Stats Card */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.stat-item {
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: var(--border-light);
    border-radius: var(--radius);
}

.stat-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--foreground);
}

.stat-label {
    font-size: 0.6875rem;
    color: var(--muted);
    margin-top: 0.125rem;
}

/* Correction Card */
.correction-card {
    background: linear-gradient(135deg, var(--primary-light) 0%, #d1fae5 100%);
    border-color: var(--primary);
}

.correction-card .info-card-header {
    background: var(--primary);
    color: white;
    border-bottom: none;
}

.correction-card .info-card-header i {
    color: white;
}

/* Actions Card */
.actions-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-block {
    width: 100%;
}

/* Related Epreuves */
.related-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.related-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--border-light);
    border-radius: var(--radius);
    text-decoration: none;
    transition: var(--transition);
}

.related-item:hover {
    background: var(--primary-light);
}

.related-thumb {
    width: 50px;
    height: 65px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.related-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.related-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-meta {
    font-size: 0.6875rem;
    color: var(--muted);
}

/* ============================================
   PROTECTION NOTICE
   ============================================ */
.protection-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    font-size: 0.75rem;
    color: #92400e;
}

.protection-notice i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ============================================
   WATERMARK OVERLAY (optionnel)
   ============================================ */
.watermark-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.watermark-text {
    font-size: 3rem;
    font-weight: 700;
    color: rgba(0, 150, 57, 0.08);
    transform: rotate(-30deg);
    white-space: nowrap;
    user-select: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .detail-container {
        grid-template-columns: 1fr;
    }
    
    .detail-sidebar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .info-card:first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .detail-container {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
    }
    
    .header-actions {
        flex-direction: row;
        width: 100%;
    }
    
    .header-actions .btn {
        flex: 1;
    }
    
    .header-title {
        font-size: 1.25rem;
    }
    
    .detail-sidebar {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .pages-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .pages-nav {
        justify-content: center;
    }
    
    .view-mode-toggle {
        justify-content: center;
    }
    
    .header-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ============================================
   PRINT PROTECTION
   ============================================ */
@media print {
    .pages-container,
    .page-wrapper,
    .page-image {
        display: none !important;
    }
    
    body::after {
        content: "L'impression de ce document n'est pas autorisée.";
        display: block;
        padding: 2rem;
        text-align: center;
        font-size: 1.5rem;
    }
}

