/**
 * styles.css - FactureX2 Professional UI
 */

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    flex-shrink: 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-steps {
    list-style: none;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    cursor: default;
    transition: all 0.2s;
}

.step-item.active {
    background-color: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.step-item.completed {
    color: var(--success);
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.step-item.active .step-number {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Main Menu Tabs */
.main-menu {
    list-style: none;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.menu-item:hover {
    background-color: #f1f5f9;
    color: var(--text-main);
}

.menu-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.menu-icon {
    font-size: 1.1rem;
}

/* Main Layout */
main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    height: 64px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    justify-content: space-between;
}

.content-area {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

.card {
    background-color: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
    box-shadow: var(--shadow);
}

.actions {
    padding: 1rem 2rem;
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

/* Forms & UI Elements */
h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
p.subtitle { color: var(--text-muted); margin-bottom: 2rem; }

.form-group { margin-bottom: 1.5rem; }
label { display: block; font-weight: 600; font-size: 0.875rem; margin-bottom: 0.5rem; color: var(--text-main); }
select, input, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
select:focus, input:focus { border-color: var(--primary); }

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
}
.btn-primary { background-color: var(--primary); color: white; }
.btn-outline { background-color: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-mandatory { background-color: #fee2e2; color: #991b1b; }
.badge-conditional { background-color: #fef3c7; color: #92400e; }
.badge-optional { background-color: #f1f5f9; color: #475569; }
.badge-missing { background-color: var(--danger); color: white; }
.badge-valid { background-color: var(--success); color: white; }
.badge-on-avance { background-color: #2563eb; color: white; border: 1px solid #1e40af; box-shadow: 0 0 10px rgba(37,99,235,0.4); }

/* Grid / Table Summary */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 2rem;
    font-size: 0.875rem;
}
.summary-table th {
    background-color: #f1f5f9;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.summary-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
}

.help-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    background: var(--secondary);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Scenarios Styles */
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.scenario-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.scenario-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.scenario-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.scenario-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.scenario-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    flex-grow: 1;
    margin-bottom: 1.5rem;
}

.scenario-card .btn {
    width: 100%;
    margin-top: auto;
}

@media print {
    .sidebar, .actions, header { display: none; }
    body { background: white; height: auto; display: block; overflow: visible; }
    main { overflow: visible; display: block; }
    .content-area { padding: 0; }
    .card { box-shadow: none; border: none; max-width: 100%; width: 100%; }
}

/* Dynamic Lines Table */
.lines-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.lines-table th {
    text-align: left;
    padding: 0.5rem;
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.lines-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.lines-table input {
    padding: 0.4rem;
    font-size: 0.9rem;
}

.line-total {
    font-weight: 700;
    color: var(--primary);
    text-align: right;
}

/* Professional Sections */
.form-section {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed var(--border);
}

.form-section h3 {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin-bottom: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.totals-summary {
    background: #f1f5f9;
    padding: 1.5rem;
    border-radius: 12px;
    border-left: 5px solid var(--primary);
}

.totals-summary h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-main);
}

/* UI Refinements */
.btn-primary { 
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); 
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:active { transform: translateY(1px); }

.scenario-card .scenario-icon {
    background-color: #f1f5f9;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    margin-bottom: 1.25rem;
}

/* Responsive Table Scroll */
.lines-table-container {
    overflow-x: auto;
    margin-bottom: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    animation: fadeIn 0.4s ease-out;
}


/* Resource Links in Sidebar */
.resource-link:hover {
    color: var(--primary) !important;
    background-color: #f1f5f9;
    border-radius: 4px;
}

.resource-link span {
    transition: transform 0.2s;
}

.resource-link:hover span {
    transform: scale(1.2);
}

/* ============================================================
   TABLE HISTORIQUE DES FACTURES GÉNÉRÉES
   ============================================================ */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}
.history-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}
.history-header p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0 0;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
}

.data-table thead tr {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
}

.data-table thead th {
    color: white;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0.9rem 1rem;
    border: none;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background 0.2s, transform 0.1s;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

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

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.data-table tbody tr:hover {
    background: #dbeafe;
    transform: scale(1.002);
}

.data-table tbody td {
    padding: 0.85rem 1rem;
    border: none;
    vertical-align: middle;
    color: var(--text-main);
}

.data-table tbody td strong {
    font-family: 'Courier New', monospace;
    color: var(--primary-dark);
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* Badge use case */
.badge-usecase {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.badge-commerciale { background: #dbeafe; color: #1e40af; }
.badge-avoir       { background: #fde8d8; color: #9a3412; }
.badge-acompte     { background: #fef9c3; color: #854d0e; }
.badge-public      { background: #dcfce7; color: #166534; }
.badge-hors_ue     { background: #f3e8ff; color: #7e22ce; }
.badge-particulier { background: #fce7f3; color: #9d174d; }

/* Action buttons inside table */
.btn-table-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s;
}
.btn-table-open {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}
.btn-table-open:hover { background: #dbeafe; }

.btn-table-delete {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
    margin-left: 0.4rem;
}
.btn-table-delete:hover { background: #fee2e2; }

/* Empty state */
.history-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.history-empty .empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.history-empty p { font-size: 1rem; margin: 0; }

/* ============================================================
   ERGONOMIE PILOTEGEST / SIRH
   ============================================================ */
:root {
    --primary: #004AAD;
    --primary-dark: #003b8e;
    --accent: #FF7F24;
    --background: #f8f9fa;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

body {
    background: var(--background);
}

.sidebar {
    width: 260px;
    position: relative;
    overflow: hidden;
    padding: 1.25rem 0.75rem;
    color: #e2e8f0;
    background: radial-gradient(circle at 30% 20%, #0f172a 0%, #1e293b 100%);
    border-right: 1px solid rgba(255,255,255,0.06);
    box-shadow: 4px 0 30px rgba(0,0,0,0.25);
}

.sidebar::before,
.sidebar::after {
    content: "";
    position: absolute;
    z-index: 0;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(80px);
}

.sidebar::before {
    width: 180px;
    height: 180px;
    top: -42px;
    left: -52px;
    background: #004AAD;
    opacity: 0.55;
}

.sidebar::after {
    width: 150px;
    height: 150px;
    right: -46px;
    bottom: -36px;
    background: #FF7F24;
    opacity: 0.28;
}

.logo,
.main-menu,
.nav-steps {
    position: relative;
    z-index: 1;
}

.logo {
    margin: 1rem 0 2rem;
    padding: 0 0.75rem;
    color: #ffffff;
    font-size: 1.35rem;
    letter-spacing: 0;
}

.logo svg {
    flex: 0 0 auto;
    filter: drop-shadow(0 8px 18px rgba(0, 74, 173, 0.45));
}

.logo strong {
    color: var(--accent);
}

.main-menu {
    border-bottom-color: rgba(255,255,255,0.08);
}

.menu-item,
.step-item {
    color: #cbd5e1;
    border-radius: 8px;
}

.menu-item:hover,
.step-item:hover {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
}

.menu-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(0, 74, 173, 0.35);
}

.menu-icon {
    width: 24px;
    color: var(--accent);
    text-align: center;
}

.menu-item.active .menu-icon {
    color: #ffffff;
}

.step-item.active {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
}

.step-item.completed {
    color: #86efac;
}

.step-item.active .step-number {
    background: var(--accent);
    border-color: var(--accent);
}

header {
    height: 68px;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

#sessionInfo {
    font-weight: 700;
    color: #334155;
}

.content-area {
    padding: 2rem 2.5rem;
}

.card,
.history-header,
.data-table {
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.card {
    max-width: 1120px;
    padding: 1.5rem;
}

.history-header {
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    background: #ffffff;
}

.history-header h1 {
    color: #0f172a;
    font-size: 1.45rem;
}

.data-table thead tr {
    background: #003b8e;
}

.data-table tbody tr:nth-child(even) {
    background: #f5f8ff;
}

.data-table tbody tr:hover {
    background: #e9f0ff;
    transform: none;
}

.data-table tbody td:first-child {
    border-left: 5px solid #003b8e;
}

.btn-primary {
    background: linear-gradient(135deg, #004AAD 0%, #1d4ed8 100%);
    box-shadow: 0 4px 12px rgba(0, 74, 173, 0.25);
}

.btn:hover {
    opacity: 0.96;
    transform: translateY(-1px);
}

.actions {
    background: rgba(255,255,255,0.96);
}

@media (max-width: 900px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow: auto;
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
    }

    .content-area {
        padding: 1rem;
    }

    .history-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 1rem;
    }
}
