/* ===============================================
   ANNUAIRE (DIRECTORY) MODULE
   =============================================== */

.annuaire-view {
    padding: 60px 0 0 0; /* Header offset */
    width: 100%;
}

/* Impersonation offset */
.main-content.impersonating .annuaire-view {
    padding-top: 100px;
}

/* Removed redundant H1 styling as header was removed for space optimization */

.search-box {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 50px auto;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 10;
    transition: all 0.3s ease;
}

.search-input {
    width: 100%;
    padding: 18px 24px 18px 55px;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    /* Correct dynamic border */
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Stronger shadow */
    transition: all 0.3s ease;
    text-align: left;
    /* Better with icon */
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.2);
    
}

.search-input:focus+.search-icon,
.search-box:focus-within .search-icon {
    color: var(--primary);
}

.search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

[data-theme="dark"] .search-input:focus {
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.4);
}

.annuaire-section {
    margin-bottom: 50px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--danger);
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(239, 68, 68, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.annuaire-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}


.annuaire-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.annuaire-card:hover {
    box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.annuaire-card.is-selected {
    border-color: var(--accent);
    background: var(--accent-glow);
    box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.1);
}

.annuaire-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 12px;
    background: white;
    padding: 8px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.annuaire-info {
    flex: 1;
}

.annuaire-info h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--text-main);
}

.annuaire-info p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.annuaire-info i {
    font-size: 1.1rem;
    color: var(--primary);
    opacity: 0.8;
}

.copy-hint {
    position: absolute;
    bottom: 12px;
    right: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.annuaire-card:hover .copy-hint {
    opacity: 0.6;
    transform: translateY(0);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 14px 28px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-icon {
    color: #10b981;
    font-size: 1.4rem;
}

/* Dashbord Hero & Sales Stats (Final Version) */
.dashboard-hero {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
}

/* ========== ANNUAIRE FIXES ==========*/
/* =========================================
   ANNUAIRE FIXES
   ========================================= */
.annuaire-card {
    position: relative !important;
    overflow: hidden;
}

.annuaire-card .copy-hint {
    position: absolute !important;
    top: auto !important;
    left: auto !important;
    bottom: 8px !important;
    right: 8px !important;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    opacity: 0;
    
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    z-index: 50;
    /* Force specific dimensions to avoid flex stretching */
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    line-height: normal;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .annuaire-card .copy-hint {
    background: #1f2937;
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="neon"] .annuaire-card .copy-hint {
    background: #0f0f1d !important;
    color: #fcee09 !important;
    border-color: rgba(252, 238, 9, 0.4) !important;
    box-shadow: 0 0 8px rgba(252, 238, 9, 0.2);
}

.annuaire-card:hover .copy-hint,
.rio-aside-card:hover .copy-hint {
    opacity: 1 !important;
    transform: translateY(0);
}

/* --- CARD ACTIONS --- */
.annuaire-card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 60;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s ease;
}

.annuaire-card:hover .annuaire-card-actions,
.annuaire-card.is-selected .annuaire-card-actions {
    opacity: 1;
    transform: translateX(0);
}

.btn-card-action {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-card-action:hover {
    background: var(--bg-body);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-card-action.report-btn {
    color: var(--danger);
    opacity: 0.6;
}

.btn-card-action.report-btn:hover {
    color: var(--danger);
    opacity: 1;
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.btn-card-action.delete-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* --- MODERATION LIST --- */
.annuaire-moderation-list {
    max-height: 400px;
    overflow-y: auto;
}

.moderation-item {
    transition: background 0.2s;
}

.moderation-item:hover {
    background: var(--bg-body-secondary);
}

.suggestion-diff {
    background: var(--bg-body);
    padding: 8px;
    border-radius: 8px;
    font-family: inherit;
    line-height: 1.4;
}

.italic {
    font-style: italic;
}

/* --- CATEGORY ANCHORS --- */
.annuaire-anchors {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.anchor-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.anchor-link:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateX(5px);
}

.anchor-link i {
    font-size: 1.1rem;
    color: var(--primary);
    opacity: 0.7;
}

/* --- RIO ASIDE GRID --- */
.rio-aside-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.rio-aside-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.rio-aside-card:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-2px);
}

.rio-aside-card img {
    height: 30px;
    max-width: 80%;
    object-fit: contain;
    margin-bottom: 5px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.rio-aside-card .rio-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main);
    display: block;
    line-height: 1.2;
}

.rio-aside-card .rio-num {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* --- COPY HISTORY --- */
.copy-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.history-item .history-icon {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 6px;
    padding: 4px;
    object-fit: contain;
}

.history-item .history-info {
    flex: 1;
    overflow: hidden;
}

.history-item .history-name {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item .history-date {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-copy-icon {
    font-size: 1rem;
    color: var(--primary);
    opacity: 0.4;
    transition: opacity 0.2s;
}

.history-item:hover .history-copy-icon {
    opacity: 1;
}

/* ==============================================
   MODERATION MODAL & ADMIN PANEL
   ============================================== */

/* --- Admin panel: deux boutons stylisÃ©s --- */
.admin-btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 16px;
    border-radius: 13px;
    font-weight: 600;
    font-size: 0.87rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1.5px solid transparent;
}

.admin-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-color: #2563eb;
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.3);
}

.admin-btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 5px 14px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.admin-btn-warning {
    background: rgba(245, 158, 11, 0.08);
    color: #d97706;
    border-color: rgba(245, 158, 11, 0.3);
}

.admin-btn-warning:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .admin-btn-warning {
    color: #fbbf24;
}

.moderation-badge {
    background: #f59e0b;
    color: #1a100a;
    font-weight: 800;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
    line-height: 1.6;
}

/* --- Overlay --- */
.mod-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* --- Modal box --- */
.mod-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.4);
    animation: modIn 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
    overflow: hidden;
}

@keyframes modIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Header --- */
.mod-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.mod-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mod-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.1);
    border: 1.5px solid rgba(245, 158, 11, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f59e0b;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.mod-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.mod-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.mod-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s;
    flex-shrink: 0;
}

.mod-close-btn:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
    transform: rotate(90deg);
}

/* --- List (scrollable) --- */
.mod-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-body-secondary, #f5f6f8);
}

[data-theme="dark"] .mod-list {
    background: var(--bg-body);
}

/* --- Empty state --- */
.mod-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 50px 20px;
    color: var(--text-muted);
    font-weight: 600;
}

.mod-empty i {
    font-size: 3rem;
    color: #10b981;
}

/* --- Single correction item --- */
.mod-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* Item header row */
.mod-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-body);
    gap: 10px;
}

.mod-item-entry {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.mod-item-entry i {
    color: var(--primary, #3b82f6);
    font-size: 1rem;
}

.mod-item-user {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Changes section */
.mod-changes {
    padding: 4px 0;
}

/* Each changed field row */
.mod-change-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border-color);
}

.mod-change-row:last-of-type {
    border-bottom: none;
}

.mod-change-field {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 80px;
    flex-shrink: 0;
}

.mod-change-before {
    font-size: 0.85rem;
    color: var(--text-muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: line-through;
    opacity: 0.7;
}

.mod-change-arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.mod-change-after {
    font-size: 0.88rem;
    font-weight: 700;
    color: #d97706;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-theme="dark"] .mod-change-after {
    color: #fbbf24;
}

.mod-no-data {
    padding: 12px 18px;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Comment */
.mod-item-comment {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.83rem;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(245, 158, 11, 0.04);
    border-top: 1px solid rgba(245, 158, 11, 0.1);
}

.mod-item-comment i {
    color: #f59e0b;
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Action buttons */
.mod-item-actions {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-body);
}

.mod-action-reject {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.18s;
}

.mod-action-reject:hover {
    background: rgba(239, 68, 68, 0.07);
    border-color: #ef4444;
    color: #ef4444;
}

.mod-action-approve {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.18s;
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.3);
}

.mod-action-approve:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 5px 14px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.mod-action-approve:disabled,
.mod-action-reject:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}


html {
    scroll-behavior: smooth;
}

/* --- IMAGE LIBRARY SUB-MODAL --- */
.library-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000; /* Higher than main modal */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.library-modal {
    background: var(--bg-card);
    width: 100%;
    max-width: 700px;
    max-height: 85vh;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.library-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-body);
}

.library-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    white-space: nowrap;
}

.library-search-box {
    flex-fill: 1;
    width: 100%;
    position: relative;
}

.library-search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.library-search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.library-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}

.library-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.library-close:hover {
    color: var(--danger);
}

.library-body {
    padding: 24px;
    overflow-y: auto;
    flex-fill: 1;
    background: var(--bg-card);
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.library-item {
    background: var(--bg-body);
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.library-item:hover {
    border-color: var(--primary-glow);
    background: var(--bg-input);
    transform: translateY(-2px);
}

.library-item.selected {
    border-color: var(--primary);
    background: var(--primary-glow);
    box-shadow: 0 4px 12px var(--primary-shadow);
}

.library-thumb {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.library-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.library-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.library-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.library-empty i {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.3;
}
