/* ========================================
   DSI - INVENTAIRE IT - STYLES CSS
   Design moderne, épuré et professionnel
   ======================================== */

/* === Variables CSS === */
:root {
    /* Couleurs principales */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary-color: #64748b;
    --secondary-hover: #475569;

    /* Couleurs de fond */
    --bg-color: #f8fafc;
    --bg-white: #ffffff;
    --bg-sidebar: #1e293b;

    /* Couleurs de texte */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;

    /* Couleurs des encadrés */
    --essential-bg: #fef2f2;
    --essential-border: #fecaca;
    --essential-icon: #ef4444;
    --info-bg: #eff6ff;
    --info-border: #bfdbfe;
    --example-bg: #f0fdf4;
    --example-border: #bbf7d0;
    --tip-bg: #fefce8;
    --tip-border: #fef08a;

    /* Bordures et ombres */
    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Dimensions */
    --sidebar-width: 260px;
    --header-height: 80px;
    --content-max-width: 900px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* === Reset et Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 20px);
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-color);
}

/* === Header fixe === */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary-color) 0%, #1e40af 100%);
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.header-content .subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Barre de progression */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 300px;
    margin: 0 40px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #10b981;
    border-radius: 4px;
    width: 0%;
    transition: width var(--transition-normal);
}

.progress-text {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Boutons du header */
.header-actions {
    display: flex;
    gap: 12px;
}

/* === Sidebar / Navigation === */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--bg-sidebar);
    overflow-y: auto;
    z-index: 900;
    transition: transform var(--transition-normal);
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + 10px);
    left: 10px;
    width: 40px;
    height: 40px;
    background: var(--bg-sidebar);
    color: var(--text-white);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 950;
    box-shadow: var(--shadow-md);
}

/* Contrôles de l'accordéon dans la sidebar */
.accordion-controls {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-accordion-toggle {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-accordion-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-white);
}

.btn-accordion-toggle span {
    font-size: 0.65rem;
}

.nav-list {
    list-style: none;
    padding: 16px 0;
}

.nav-link {
    display: block;
    padding: 12px 20px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-color);
}

/* Indicateur de progression par section */
.section-progress {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    font-weight: 600;
    vertical-align: middle;
}

.section-progress.empty {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.section-progress.partial {
    background: rgba(251, 191, 36, 0.2);
    color: #fcd34d;
}

.section-progress.complete {
    background: rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.section-progress.complete::before {
    content: "✓ ";
}

/* === Contenu principal === */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 32px;
    min-height: calc(100vh - var(--header-height));
}

/* === Sections du formulaire (Mode Accordéon) === */
.form-section {
    max-width: var(--content-max-width);
    margin: 0 auto 12px;
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
    border-bottom: none;
    margin-bottom: 0;
}

.section-header:hover {
    background: var(--bg-color);
}

.section-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: var(--text-white);
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 50%;
    flex-shrink: 0;
}

.section-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

/* Indicateur d'accordéon */
.accordion-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.accordion-progress {
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.accordion-progress.empty {
    background: var(--essential-bg);
    color: var(--essential-icon);
}

.accordion-progress.partial {
    background: var(--tip-bg);
    color: #b45309;
}

.accordion-progress.complete {
    background: var(--example-bg);
    color: #15803d;
}

.accordion-arrow {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: transform var(--transition-normal);
}

.form-section.open .accordion-arrow {
    transform: rotate(180deg);
}

/* Contenu de section (collapsible) */
.section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.3s ease;
    padding: 0 24px;
}

.form-section.open .section-content {
    max-height: none;
    padding: 0 24px 32px;
    border-top: 1px solid var(--border-color);
}

/* Section Introduction (toujours visible, style différent) */
.form-section.intro-section {
    margin-bottom: 24px;
}

.form-section.intro-section .section-header {
    cursor: default;
    padding-bottom: 16px;
    margin-bottom: 0;
    border-bottom: 2px solid var(--border-color);
}

.form-section.intro-section .section-header:hover {
    background: transparent;
}

.form-section.intro-section .section-content {
    max-height: none;
    padding: 24px;
    overflow: visible;
}

/* === Sous-sections === */
.subsection {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.subsection:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.subsection h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* === Encadrés d'information === */
.info-box {
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.info-box p {
    margin: 0;
}

.info-blue {
    background: var(--info-bg);
    border-left: 4px solid var(--primary-color);
}

.info-green {
    background: var(--example-bg);
    border-left: 4px solid #22c55e;
}

.info-yellow {
    background: var(--tip-bg);
    border-left: 4px solid #eab308;
}

/* === Légende === */
.legend-box {
    background: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-top: 24px;
}

.legend-box h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

.legend-item:last-child {
    margin-bottom: 0;
}

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

.legend-essential {
    background: var(--essential-bg);
}

.legend-info {
    background: var(--info-bg);
}

.legend-example {
    background: var(--example-bg);
}

.legend-tip {
    background: var(--tip-bg);
}

/* === Liste d'introduction === */
.intro-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.intro-list li {
    padding: 8px 0 8px 28px;
    position: relative;
}

.intro-list li::before {
    content: "•";
    position: absolute;
    left: 8px;
    color: var(--primary-color);
    font-weight: bold;
}

/* === Groupes de formulaire === */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-group small {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.field-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-style: italic;
}

.form-group.essential label {
    color: var(--essential-icon);
}

.form-group.essential {
    background: var(--essential-bg);
    padding: 16px;
    border-radius: var(--border-radius);
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
}

/* Ligne de formulaire */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* === Champs de saisie === */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-white);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-light);
}

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

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* === Radio buttons et Checkboxes === */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
}

.radio-label input,
.checkbox-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* === Tableaux dynamiques === */
.dynamic-table-container {
    margin: 16px 0;
    overflow-x: auto;
}

.dynamic-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.dynamic-table th {
    background: var(--bg-color);
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.dynamic-table th.essential-col {
    color: var(--essential-icon);
}

.dynamic-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.dynamic-table td input,
.dynamic-table td select {
    padding: 8px 10px;
    font-size: 0.85rem;
}

.dynamic-table .action-col {
    width: 40px;
    text-align: center;
}

.btn-remove-row {
    width: 28px;
    height: 28px;
    border: none;
    background: #fee2e2;
    color: #ef4444;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    transition: all var(--transition-fast);
}

.btn-remove-row:hover {
    background: #ef4444;
    color: white;
}

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

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

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

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-white);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-add-row {
    margin-top: 12px;
    background: var(--primary-light);
    color: var(--primary-color);
}

.btn-add-row:hover {
    background: var(--primary-color);
    color: var(--text-white);
}

/* === Grille de sécurité === */
.security-grid {
    display: grid;
    gap: 16px;
}

.security-item {
    background: var(--bg-color);
    padding: 16px;
    border-radius: var(--border-radius);
}

.security-item.essential {
    background: var(--essential-bg);
}

.security-item label {
    display: block;
    font-weight: 500;
    margin-bottom: 12px;
}

.security-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.security-fields input {
    flex: 1;
    min-width: 150px;
}

/* === Documents checklist === */
.documents-checklist {
    display: grid;
    gap: 12px;
}

.doc-item {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: center;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
}

.doc-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

/* === Section validation === */
.validation-section {
    background: var(--bg-color);
    padding: 24px;
    border-radius: var(--border-radius);
}

.validation-box {
    background: var(--bg-white);
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 2px solid var(--border-color);
}

.validation-box .checkbox-label {
    font-weight: 500;
}

/* === Info finale === */
.final-info {
    margin-top: 32px;
    padding: 24px;
    background: var(--info-bg);
    border-radius: var(--border-radius);
    text-align: center;
}

.final-info p {
    margin: 8px 0;
}

.final-info .thanks {
    margin-top: 16px;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--primary-color);
}

/* === Toast notification === */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-sidebar);
    color: var(--text-white);
    padding: 16px 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 2000;
}

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

.toast.success {
    background: #059669;
}

.toast.error {
    background: #dc2626;
}

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 3000;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-white);
    padding: 32px;
    border-radius: var(--border-radius-lg);
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 12px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-actions .btn {
    padding: 10px 20px;
}

.modal-actions .btn-secondary {
    background: var(--bg-color);
    color: var(--text-secondary);
}

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

/* === Responsive Design === */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        margin-left: 0;
    }

    .progress-container {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .main-header {
        padding: 0 16px;
    }

    .header-content h1 {
        font-size: 1.1rem;
    }

    .header-content .subtitle {
        display: none;
    }

    .btn-label {
        display: none;
    }

    .btn {
        padding: 10px 12px;
    }

    .main-content {
        padding: 16px;
    }

    .form-section {
        padding: 20px;
        margin-bottom: 20px;
    }

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

    .dynamic-table {
        font-size: 0.8rem;
    }

    .dynamic-table th,
    .dynamic-table td {
        padding: 6px 4px;
    }

    .dynamic-table td input,
    .dynamic-table td select {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .radio-group {
        flex-direction: column;
        gap: 10px;
    }

    .security-fields {
        flex-direction: column;
        align-items: stretch;
    }

    .security-fields input {
        min-width: auto;
    }

    .doc-item {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header-actions {
        gap: 8px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .form-group.essential {
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* === Impression === */
@media print {
    .main-header,
    .sidebar,
    .btn-add-row,
    .btn-remove-row,
    .toast,
    .modal,
    .accordion-indicator {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .form-section {
        box-shadow: none;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }

    /* En impression, tout est visible */
    .section-content {
        max-height: none !important;
        overflow: visible !important;
        padding: 16px !important;
    }

    .section-header {
        cursor: default;
        padding: 16px;
        border-bottom: 2px solid var(--border-color);
    }
}
