/* ==========================================
   Système de Gestion de Stock et Factures
   Styles CSS - Design professionnel moderne
   ========================================== */

/* Variables CSS */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --border-radius: 0.5rem;
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

/* Reset et base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6f8;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typographie */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--dark-color);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

/* Navbar personnalisée */
.navbar {
    box-shadow: var(--shadow-md);
    padding: 0.75rem 1rem;
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand i {
    font-size: 1.8rem;
}

.navbar-nav .nav-link {
    padding: 0.6rem 1rem;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar-nav .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.navbar-dark .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.5);
}

.navbar-expand-lg .navbar-collapse {
    justify-content: space-between;
}

/* Sélecteur de méthode de valorisation */
#valuationMethod {
    width: auto;
    min-width: 180px;
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: 500;
}

#valuationMethod option {
    color: #333;
    background-color: white;
}

/* Contenu principal */
main {
    flex: 1;
    padding-bottom: 2rem;
}

.content-section {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Cartes statistiques */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

.card.bg-primary,
.card.bg-success,
.card.bg-warning,
.card.bg-info,
.card.bg-danger,
.card.bg-secondary {
    border: none;
}

.card.bg-primary h2,
.card.bg-success h2,
.card.bg-info h2 {
    color: white;
    margin: 0;
    font-size: 2rem;
}

.card.bg-warning h2 {
    color: var(--dark-color);
    margin: 0;
    font-size: 2rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    font-size: 1.3rem;
}

/* Tableau */
.table {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
    background-color: var(--dark-color);
    color: white;
    padding: 0.75rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.table-dark thead th {
    background-color: var(--dark-color);
}

.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
}

/* Boutons */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

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

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0b5ed7;
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-success:hover {
    background-color: #157347;
    border-color: #157347;
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #bb2d3b;
    border-color: #bb2d3b;
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: var(--dark-color);
}

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

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
    color: var(--dark-color);
}

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

.btn-outline-success {
    color: var(--success-color);
    border-color: var(--success-color);
}

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

.btn-outline-danger {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

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

.btn-outline-info {
    color: var(--info-color);
    border-color: var(--info-color);
}

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

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.35rem 0.6rem;
    border-radius: 0.25rem;
}

/* Formulaires */
.form-label {
    font-weight: 500;
    color: var(--dark-color);
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-radius: var(--border-radius);
    padding: 0.6rem 0.9rem;
    font-size: 0.95rem;
    border: 1px solid #ced4da;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.form-control::placeholder {
    color: #adb5bd;
}

/* Modals */
.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
}

.modal-header.bg-primary {
    background-color: var(--primary-color);
}

.modal-header.bg-success {
    background-color: var(--success-color);
}

.modal-header.bg-warning {
    background-color: var(--warning-color);
}

.modal-header.bg-info {
    background-color: var(--info-color);
}

.modal-footer {
    border-top: 1px solid #dee2e6;
}

/* Liste de groupes */
.list-group {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.list-group-item {
    padding: 0.75rem 1.25rem;
    border-left: none;
    border-right: none;
}

.list-group-item:first-child {
    border-top: none;
}

.list-group-item:last-child {
    border-bottom: none;
}

/* Alertes */
.alert {
    border-radius: var(--border-radius);
    padding: 1rem 1.25rem;
}

/* Facture preview */
#invoicePreviewContent {
    background: white;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
}

.invoice-header {
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.invoice-header h3 {
    font-size: 18px;
    margin-bottom: 5px;
}

.invoice-header p {
    margin: 2px 0;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.invoice-table th,
.invoice-table td {
    border: 1px solid #000;
    padding: 5px 8px;
    text-align: left;
}

.invoice-table th {
    background-color: #f0f0f0;
    font-weight: bold;
}

.invoice-total {
    text-align: right;
    margin-top: 20px;
}

.invoice-total p {
    margin: 3px 0;
}

.invoice-footer {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid #000;
    font-size: 10px;
}

/* Footer */
footer {
    margin-top: auto;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive design */
@media (max-width: 991.98px) {
    .navbar-nav {
        margin-top: 1rem;
    }

    .navbar-nav .nav-link {
        padding: 0.5rem 0.75rem;
    }

    #valuationMethod {
        width: 100%;
        margin-top: 0.5rem;
    }

    .d-flex.justify-content-between.align-items-center {
        flex-direction: column;
        gap: 1rem;
    }

    .d-flex.justify-content-between.align-items-center .btn {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .card-body {
        padding: 1rem;
    }

    .card.bg-primary h2,
    .card.bg-success h2,
    .card.bg-warning h2,
    .card.bg-info h2 {
        font-size: 1.5rem;
    }

    .table {
        font-size: 0.8rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.5rem;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 575.98px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .col-md-3,
    .col-md-4,
    .col-md-6 {
        margin-bottom: 1rem;
    }
}

/* Classes utilitaires personnalisées */
.text-stock-low {
    color: var(--danger-color);
    font-weight: 600;
}

.text-stock-ok {
    color: var(--success-color);
}

.bg-stock-alert {
    background-color: rgba(220, 53, 69, 0.1);
}

.print-only {
    display: none;
}

/* Animation de chargement */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    .modal-footer button:not(.btn-primary):not(.btn-secondary),
    footer {
        display: none !important;
    }

    body {
        background: white;
    }

    .content-section {
        display: block !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Notifications toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    animation: slideIn 0.3s ease;
}

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

/* Tooltip personnalisée */
[data-bs-toggle="tooltip"] {
    cursor: pointer;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 0.35rem;
}

.action-buttons .btn {
    padding: 0.3rem 0.5rem;
}

/* Table sort icons */
.sort-icon {
    cursor: pointer;
    margin-left: 0.25rem;
    opacity: 0.5;
}

.sort-icon:hover {
    opacity: 1;
}

.sort-icon.active {
    opacity: 1;
    color: var(--primary-color);
}