/* Karbon Legal v9 - Design Neutre Condensé - CSS Complet */
:root {
    --bg: #f5f5f7;
    --sidebar-bg: #ffffff;
    --surface: #ffffff;
    --border: #e0e0e0;
    --border-dark: #d0d0d0;
    --text: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --green: #16a34a;
    --yellow: #ca8a04;
    --orange: #ea580c;
    --red: #dc2626;
    --purple: #9333ea;
    --pink: #ec4899;
    --success-bg: #f0fdf4;
    --warning-bg: #fffbeb;
    --danger-bg: #fef2f2;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-xs: 4px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #e5e5e5;
    min-height: 100vh;
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}

/* ========== APP CONTAINER ========== */
.app-container {
    margin: 8px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.05);
    overflow: hidden;
    min-height: calc(100vh - 16px);
    display: flex;
    flex-direction: column;
}

/* ========== TOP NAVIGATION ========== */
.top-nav {
    height: 38px;
    background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-brand .logo {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.nav-menu {
    display: flex;
    gap: 2px;
    margin-left: 20px;
}

.nav-item {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    border-radius: var(--radius-xs);
    transition: all 0.15s;
}

.nav-item:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

/* ========== APP BODY & SECTIONS ========== */
.app-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section.hidden { display: none; }

/* App = Sidebar + Main layout */
.app {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #fafafa;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.sidebar-search {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

/* Company Item in sidebar */
.company-item {
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    margin-bottom: 2px;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.company-item:hover {
    background: var(--bg);
}

.company-item.active {
    background: var(--accent-light);
    border-color: var(--accent);
}

.company-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.company-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

/* Intervenant Item */
.intervenant-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    margin-bottom: 2px;
    border: 1px solid transparent;
}

.intervenant-item:hover { background: var(--bg); }
.intervenant-item.active {
    background: var(--accent-light);
    border-color: var(--accent);
}

.intervenant-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    background: var(--purple);
    flex-shrink: 0;
}

.intervenant-icon.physique { background: var(--accent); }
.intervenant-icon.morale { background: var(--purple); }

.intervenant-info h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.intervenant-info span {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Archive Item */
.archive-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    margin-bottom: 2px;
    border: 1px solid transparent;
}

.archive-item:hover { background: var(--bg); }
.archive-item.active {
    background: var(--accent-light);
    border-color: var(--accent);
}

/* ========== MAIN CONTENT ========== */
.main {
    flex: 1;
    background: var(--bg);
    overflow-y: auto;
    padding: 12px;
}

/* Detail Header */
.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.detail-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
}

.detail-header p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
    gap: 0;
}

.tabs .btn {
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--border);
}

.tab-btn {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    transition: all 0.15s;
    border-right: 1px solid var(--border);
}

.tab-btn:last-of-type { border-right: none; }

.tab-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
}

/* ========== CARDS ========== */
.card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 12px;
    overflow: hidden;
}

.card-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
}

.card-header h3,
.card-header .card-title {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
}

.card-body {
    padding: 12px;
}

.card-body.np,
.np { padding: 0 !important; }

/* ========== INFO GRID ========== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 900px) {
    .info-grid { grid-template-columns: 1fr; }
}

/* ========== EXERCICE HEADER ========== */
.exercice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

/* ========== TABLE ========== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.table td {
    padding: 8px 10px;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tr:hover td { background: rgba(0,0,0,0.02); }

.table .actions {
    white-space: nowrap;
    text-align: right;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    transition: all 0.15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover {
    background: #f5f5f5;
    border-color: var(--border-dark);
}

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

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

.btn-secondary {
    background: #6b7280;
    border-color: #6b7280;
    color: white;
}
.btn-secondary:hover { background: #4b5563; }

.btn-success {
    background: var(--green);
    border-color: var(--green);
    color: white;
}
.btn-success:hover { background: #15803d; }

.btn-danger {
    background: var(--red);
    border-color: var(--red);
    color: white;
}
.btn-danger:hover { background: #b91c1c; }

.btn-warning {
    background: var(--orange);
    border-color: var(--orange);
    color: white;
}
.btn-warning:hover { background: #c2410c; }

.btn-purple {
    background: var(--purple);
    border-color: var(--purple);
    color: white;
}
.btn-purple:hover { background: #7c22ce; }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 11px;
}

.btn-lg {
    padding: 10px 18px;
    font-size: 14px;
}

.btn-block { width: 100%; }

.btn-group {
    display: flex;
    gap: 4px;
}

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-secondary { background: #e5e7eb; color: #4b5563; }
.badge-success { background: #dcfce7; color: var(--green); }
.badge-danger { background: #fee2e2; color: var(--red); }
.badge-warning { background: #ffedd5; color: var(--orange); }
.badge-info { background: var(--accent-light); color: var(--accent); }

/* ========== FORM ELEMENTS ========== */
.form-group {
    margin-bottom: 12px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ========== MODAL ========== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.show {
    display: flex;
}

.modal-dialog {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-dialog.lg { max-width: 800px; }
.modal-dialog.xl { max-width: 1000px; }

.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #fafafa;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--text);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.warning { background: var(--orange); }

/* ========== ALERT ========== */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
}

.alert-info {
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
}

.alert-success {
    background: #dcfce7;
    color: var(--green);
    border: 1px solid var(--green);
}

.alert-warning {
    background: #ffedd5;
    color: var(--orange);
    border: 1px solid var(--orange);
}

.alert-danger {
    background: #fee2e2;
    color: var(--red);
    border: 1px solid var(--red);
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.empty-state p {
    font-size: 13px;
}

.empty-state-sm {
    text-align: center;
    padding: 20px;
    color: var(--text-tertiary);
    font-size: 12px;
}

/* ========== DASHBOARD ========== */
#dashboard-content {
    padding: 12px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.dashboard-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 16px;
}

.dashboard-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
}

.dashboard-stat {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
}

/* ========== DOCUMENT PREVIEW ========== */
.preview-a4 {
    background: white;
    padding: 2cm;
    max-width: 21cm;
    margin: 0 auto;
    font-family: "Times New Roman", serif;
    font-size: 12pt;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.preview-a4 h1 {
    font-size: 16pt;
    text-align: center;
    margin-bottom: 1rem;
    text-transform: uppercase;
    font-weight: bold;
}

.preview-a4 h2 {
    font-size: 14pt;
    margin: 1.5rem 0 0.75rem;
    font-weight: bold;
    text-decoration: underline;
}

.preview-a4 h3 {
    font-size: 12pt;
    margin: 1rem 0 0.5rem;
    font-weight: bold;
}

.preview-a4 p {
    margin: 0.5rem 0;
    text-align: justify;
}

.preview-a4 .center { text-align: center; }
.preview-a4 .right { text-align: right; }

.preview-a4 table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.preview-a4 table td,
.preview-a4 table th {
    padding: 0.5rem;
    border: 1px solid #000;
}

.preview-a4 ul, .preview-a4 ol {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.preview-a4 li { margin: 0.25rem 0; }

.preview-a4 .page-break { page-break-before: always; margin-top: 2rem; }

.preview-a4 .article { margin: 1rem 0; }
.preview-a4 .article-title { font-weight: bold; margin-bottom: 0.5rem; }

/* ========== STAKEHOLDERS SUMMARY ========== */
.stakeholders-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.stakeholder-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: var(--radius-xs);
    font-size: 12px;
}

/* ========== LOADING ========== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
}

.loading::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

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

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track { background: transparent; }

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ========== UTILITIES ========== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--accent); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--orange); }
.text-sm { font-size: 11px; }
.text-xs { font-size: 10px; }
.font-bold { font-weight: 600; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.ml-1 { margin-left: 4px; }
.mr-1 { margin-right: 4px; }

.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.border { border: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.rounded { border-radius: var(--radius-sm); }

.bg-white { background: white; }
.bg-gray { background: var(--bg); }

.cursor-pointer { cursor: pointer; }
.no-select { user-select: none; }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .app-container { margin: 0; border-radius: 0; min-height: 100vh; }
    .sidebar { width: 200px; }
    .form-row { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .sidebar { display: none; }
    .nav-menu { display: none; }
    .main { padding: 8px; }
}

/* ========== PROGRESS BAR ========== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ========== CHECKBOX GROUP ========== */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ========== PRINT ========== */
@media print {
    .top-nav, .sidebar, .btn, .modal, .tabs { display: none !important; }
    .app-container { margin: 0; box-shadow: none; border-radius: 0; }
    .main { padding: 0; background: white; }
    .preview-a4 { box-shadow: none; padding: 0; }
}
