/* ===== CERTIFER Document Rebranding Platform - Styles ===== */

:root {
    --primary: #003DA5;
    --primary-dark: #002D7A;
    --primary-light: #E8EEF8;
    --accent: #49a336;
    --accent-light: #e8f5e4;
    --success: #28a745;
    --error: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --text: #2d3436;
    --text-muted: #636e72;
    --bg: #f0f3f8;
    --card-bg: #ffffff;
    --border: #dfe6e9;
    --shadow: 0 2px 12px rgba(0, 61, 165, 0.06);
    --shadow-hover: 0 8px 24px rgba(0, 61, 165, 0.12);
    --radius: 10px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== LOGIN OVERLAY ===== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2rem;
    justify-content: center;
}

.login-logo .logo-icon {
    width: 42px;
    height: 42px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
}

.login-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--primary);
}

.login-logo .subtitle {
    font-size: 0.7rem;
    opacity: 0.6;
    color: var(--text);
}

.login-error {
    background: #fce4ec;
    color: var(--error);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

#loginForm .form-group {
    margin-bottom: 1.2rem;
}

#loginForm label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text);
}

#loginForm input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

#loginForm input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 61, 165, 0.1);
}

/* ===== USER MENU ===== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 1rem;
}

.user-name {
    font-size: 0.85rem;
    opacity: 0.9;
    white-space: nowrap;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 0.35rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

/* ===== HEADER ===== */
header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, #0056d2 100%);
    color: white;
    padding: 0 2rem;
    box-shadow: 0 4px 20px rgba(0, 45, 122, 0.35);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

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

.logo .subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
    font-weight: 400;
}

nav {
    display: flex;
    gap: 4px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    transform: translateY(-1px);
}

.nav-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.6);
}

/* ===== MAIN ===== */
main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* ===== CARDS ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card h2 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.description {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ===== UPLOAD ZONE ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
    background: linear-gradient(135deg, #fafbff 0%, #f0f3f8 100%);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.005);
    box-shadow: 0 0 0 4px rgba(0, 61, 165, 0.08);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-zone p {
    margin-bottom: 0.5rem;
}

.small {
    font-size: 0.85rem;
}

.muted {
    color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #0056d2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 61, 165, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    box-shadow: 0 4px 16px rgba(0, 61, 165, 0.35);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: #d4dff0;
    transform: translateY(-1px);
}

.btn-danger {
    background: #fce4e4;
    color: var(--error);
}

.btn-danger:hover {
    background: #f8c9c9;
    transform: translateY(-1px);
}

.btn-large {
    padding: 14px 32px;
    font-size: 1rem;
    width: 100%;
    justify-content: center;
    margin-top: 1rem;
}

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

/* ===== FORMS ===== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 61, 165, 0.12);
    transition: all var(--transition);
}

input[type="color"] {
    width: 60px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

/* ===== FILE LIST ===== */
.file-list {
    margin-top: 1.5rem;
}

.file-list h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.file-item .file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

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

.file-item .file-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.file-type-pdf { background: #fce4e4; color: #c0392b; }
.file-type-docx { background: #e3ecfa; color: #2b6cc0; }
.file-type-xlsx { background: #e4f8e4; color: #27ae60; }

.file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
}

.file-remove:hover {
    color: var(--error);
}

/* ===== PROGRESS ===== */
.progress-section {
    margin-top: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg);
    border-radius: 6px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #0056d2, var(--accent));
    background-size: 200% 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
    width: 0%;
    animation: shimmer 2s ease infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== RESULTS ===== */
.result-section {
    margin-top: 1.5rem;
}

.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.result-item.success {
    background: #e8f5e9;
    border-left: 4px solid var(--success);
}

.result-item.error {
    background: #fce4e4;
    border-left: 4px solid var(--error);
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.result-filename {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-details {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.result-details .detail-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.detail-tag.tag-count {
    background: #e3f2fd;
    color: #1565c0;
}

.detail-tag.tag-ia {
    background: #f3e5f5;
    color: #7b1fa2;
}

.detail-tag.tag-template {
    background: #e0f2f1;
    color: #00695c;
}

.detail-tag.tag-cover {
    background: #fff3e0;
    color: #e65100;
}

.detail-tag.tag-toc {
    background: #e8eaf6;
    color: #283593;
}

.result-actions {
    display: flex;
    gap: 8px;
    margin-left: 16px;
    flex-shrink: 0;
}

/* ===== TABLE ===== */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    min-width: 750px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    table-layout: fixed;
}

thead th {
    background: linear-gradient(135deg, var(--primary-light) 0%, #dce5f5 100%);
    color: var(--primary);
    font-weight: 600;
    padding: 10px 6px;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    font-size: 0.8rem;
}

/* Column widths for 9 columns (must sum to 100%) */
thead th:nth-child(1) { width: 3.5%; }   /* checkbox */
thead th:nth-child(2) { width: 13%; }    /* Date */
thead th:nth-child(3) { width: 28%; }    /* Fichier */
thead th:nth-child(4) { width: 6.5%; }   /* Type */
thead th:nth-child(5) { width: 8%; }     /* Mode */
thead th:nth-child(6) { width: 12%; }    /* Utilisateur */
thead th:nth-child(7) { width: 6%; }     /* Rempl. */
thead th:nth-child(8) { width: 8%; }     /* Statut */
thead th:nth-child(9) { width: 15%; }    /* Actions */

thead th:first-child {
    border-radius: 6px 0 0 0;
}

thead th:last-child {
    border-radius: 0 6px 0 0;
}

tbody td {
    padding: 7px 6px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
}

tbody td:nth-child(4) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

tbody td:last-child {
    white-space: normal;
    overflow: visible;
}

tbody tr:hover {
    background: var(--primary-light);
    transition: background var(--transition);
}

.log-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
}

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

/* ===== STATUS BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-error { background: #fce4e4; color: #c62828; }
.badge-processing { background: #fff3e0; color: #e65100; }
.badge-pending { background: #e3ecfa; color: #1565c0; }

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--primary-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid transparent;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--border);
}

.stat-card.success { background: #e8f5e9; }
.stat-card.error { background: #fce4e4; }
.stat-card.info { background: #e1f5fe; }

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card.success .stat-number { color: var(--success); }
.stat-card.error .stat-number { color: var(--error); }
.stat-card.info .stat-number { color: var(--info); }

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== CONFIG SECTIONS ===== */
.config-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.config-section h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.replacement-rule {
    display: grid;
    grid-template-columns: 1fr 30px 1fr 40px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.replacement-arrow {
    text-align: center;
    color: var(--primary);
    font-weight: 700;
}

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 1rem;
}

.toolbar select {
    width: auto;
    min-width: 160px;
}

/* ===== SHAREPOINT ===== */
.sharepoint-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.error { background: var(--error); }

/* ===== TAB SYSTEM ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ===== FOOTER ===== */
.site-footer { background: linear-gradient(135deg, var(--primary-dark) 0%, #001a4d 100%); color: #b0c4de; margin-top: auto; }
.footer-main { max-width: 1400px; margin: 0 auto; padding: 2.5rem 2rem 2rem; display: flex; gap: 3rem; align-items: flex-start; }
.footer-brand { flex: 0 0 220px; }
.footer-logo { height: 56px; width: auto; background: #fff; padding: 6px 10px; border-radius: 8px; margin-bottom: 0.75rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.footer-tagline { font-size: 0.8rem; color: #7a9bbf; line-height: 1.4; }
.footer-links { flex: 1; display: flex; gap: 3rem; }
.footer-col h4 { color: #fff; font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.75rem; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 0.4rem; }
.footer-col a { color: #8fafc8; text-decoration: none; font-size: 0.82rem; transition: all var(--transition); }
.footer-col a:hover { color: var(--accent); padding-left: 4px; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, 0.1); text-align: center; padding: 1rem 2rem; font-size: 0.75rem; }
.footer-bottom p { margin-bottom: 0.2rem; color: #7a9bbf; }
.footer-address { color: #5a7d9e !important; font-size: 0.7rem !important; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
    max-width: 400px;
    font-size: 0.9rem;
}

.toast.success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid var(--success); }
.toast.error { background: #fce4e4; color: #c62828; border-left: 4px solid var(--error); }
.toast.info { background: #e1f5fe; color: #01579b; border-left: 4px solid var(--info); }

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

/* ===== ENTITY GRID ===== */
.entity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.entity-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.entity-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: rgba(0, 61, 165, 0.2);
}

.entity-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.75rem;
}

.entity-card-header img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 4px;
    background: white;
    padding: 4px;
}

.entity-card-header .entity-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
}

.entity-card-header .entity-code {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.entity-card-body {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.entity-card-body p {
    margin-bottom: 2px;
}

.entity-card-images {
    display: flex;
    gap: 8px;
    margin-bottom: 0.75rem;
}

.entity-card-images .img-thumb {
    width: 60px;
    height: 36px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

.entity-card-images .img-placeholder {
    width: 60px;
    height: 36px;
    border: 1px dashed var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: pointer;
}

.entity-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.entity-card-actions .btn {
    padding: 5px 12px;
    font-size: 0.78rem;
}

/* ===== USER CARDS ===== */
.user-card .entity-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.user-card.inactive {
    opacity: 0.6;
    border-left: 3px solid var(--danger);
}
.user-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-admin {
    background: #dbeafe;
    color: #1e40af;
}
.badge-user {
    background: #f3f4f6;
    color: #6b7280;
}
.badge-active {
    background: #dcfce7;
    color: #166534;
}
.badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}
.entity-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}
.entity-detail-row {
    display: flex;
    justify-content: space-between;
}
.entity-detail-row .label {
    color: var(--text-muted);
}
.entity-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.entity-actions .btn {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--primary);
}

.modal-body {
    padding: 1.5rem;
}

/* ===== PREVIEW MODAL ===== */
.preview-modal-content {
    max-width: 90vw;
    width: 90vw;
    max-height: 92vh;
    height: 92vh;
    display: flex;
    flex-direction: column;
}

.preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.preview-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: 0 0 var(--radius) var(--radius);
}

.preview-footer #previewPageInfo {
    min-width: 100px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 3rem;
    gap: 1rem;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: 6px;
    line-height: 1;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    fill: none;
    stroke: currentColor;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.08);
}

.btn-icon.btn-icon-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.btn-icon.btn-icon-success:hover {
    background: #2e7d32;
    color: white;
    transform: scale(1.08);
}

.btn-icon.btn-icon-danger {
    background: #fce4e4;
    color: #c62828;
}

.btn-icon.btn-icon-danger:hover {
    background: #c62828;
    color: white;
    transform: scale(1.08);
}

/* Alias for backward compat */
.btn-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: 6px;
    line-height: 1;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-preview svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    fill: none;
    stroke: currentColor;
}

.btn-preview:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.08);
}

.preview-frame {
    width: 100%;
    flex: 1;
    border: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--bg);
}

.preview-docx-container {
    flex: 1;
    overflow-y: auto;
    background: #e8e8e8;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 0;
    display: none;
}

.preview-docx-container .docx-wrapper {
    background: #e8e8e8 !important;
    padding: 20px !important;
}

.preview-docx-container .docx-wrapper > section.docx {
    margin: 0 auto 20px auto !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15) !important;
}

.preview-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.preview-fallback p {
    margin-bottom: 0.5rem;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

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

/* ===== ENTITY PREVIEW ===== */
.entity-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 6px;
    font-weight: 500;
}

/* ===== CHECKBOX LABEL ===== */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
}

/* ===== TRANSFORM OPTIONS ===== */
.transform-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.transform-options-grid .checkbox-label {
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: background 0.15s;
}
.transform-options-grid .checkbox-label:hover {
    background: var(--hover);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .header-content {
        flex-direction: column;
        height: auto;
        padding: 1rem 0;
        gap: 0.75rem;
    }

    nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .replacement-rule {
        grid-template-columns: 1fr;
    }

    .replacement-arrow {
        transform: rotate(90deg);
    }

    main {
        padding: 1rem;
    }
}
