/*
 * Styles personnalisés pour l'application de gestion de prêt
 */

/* Variables */
:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
}

/* Reset et base */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.navbar-brand {
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Cards */
.card {
    border-radius: 10px;
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
}

/* Tableaux */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    white-space: nowrap;
    border-top: none;
}

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

.table-responsive {
    border-radius: 0 0 10px 10px;
}

/* Sticky header pour les tableaux */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
}

/* Boutons */
.btn {
    border-radius: 6px;
    font-weight: 500;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
}

/* Formulaires */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid #dee2e6;
    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 3px rgba(13, 110, 253, 0.15);
}

.input-group-text {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

/* Alertes */
.alert {
    border-radius: 8px;
    border: none;
}

/* Progress bar */
.progress {
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    font-weight: 600;
}

/* Modals */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

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

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

/* États des lignes du tableau */
.table-success {
    --bs-table-bg: rgba(25, 135, 84, 0.1);
}

.table-warning {
    --bs-table-bg: rgba(255, 193, 7, 0.15);
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Loader */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Stats cards icons */
.bg-opacity-10 {
    background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
}

.rounded-circle.p-3 {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Montants : toujours sur la même ligne que le signe monétaire */
.text-end, h3.mb-0, h4.mb-0 {
    white-space: nowrap;
}

/* Titres : retour à la ligne avant le libellé du prêt */
h1.h3 {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.5rem;
}
h1.h3 > small.pret-label {
    flex-basis: 100%;
}
@media (min-width: 769px) {
    h1.h3 > small.pret-label {
        flex-basis: auto;
    }
    h1.h3 > small.pret-label::before {
        content: '— ';
    }
}

/* Nom du prêt dans la navbar : masquer en mode burger */
.navbar .nav-pret-name {
    display: flex;
}
@media (max-width: 991.98px) {
    .navbar .nav-pret-name {
        display: none !important;
    }
}

/* Durée : ne pas couper dans la parenthèse */
.nowrap-parenthesis {
    white-space: nowrap;
}

/* Tableau des remboursements : centrer toutes les valeurs */
#versements-table th,
#versements-table td {
    text-align: center !important;
}

/* Modal historique responsive */
@media (max-width: 576px) {
    #historyModal .modal-dialog {
        max-width: 100%;
        margin: 0.5rem;
    }
    #historyModal .table th,
    #historyModal .table td {
        padding: 0.35rem;
        font-size: 0.8rem;
    }
}

/* Responsive */
@media (max-width: 768px) {
    html {
        overflow-x: hidden;
    }

    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .table th, .table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    /* Permettre le retour à la ligne pour les libellés, pas pour les montants */
    .table td {
        white-space: normal;
    }

    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* Login page */
.min-vh-100 {
    min-height: 100vh !important;
}

.login-gradient {
    background: linear-gradient(135deg, #4a6fa5 0%, #6b5b95 100%);
    min-height: 100vh;
}

.login-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #4a6fa5 0%, #6b5b95 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #4a6fa5 0%, #6b5b95 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-box .form-control {
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
}

.login-box .form-control:focus {
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}

.login-box .form-label {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.btn-login {
    background: linear-gradient(135deg, #4a6fa5 0%, #6b5b95 100%);
    border: none;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 10px;
    color: white;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(74, 111, 165, 0.4);
    color: white;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

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

/* Boutons actions admin de même largeur */
.admin-actions-group .btn,
.admin-actions-group form {
    min-width: 250px;
}

/* Print styles */
@media print {
    .navbar, .btn, .modal {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* Tooltip personnalisé */
.tooltip-inner {
    max-width: none;
    white-space: nowrap;
}

/* Focus visible pour l'accessibilité */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Monospace pour les montants */
.text-end {
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Numéros de versement */
td:first-child {
    font-weight: 600;
    color: var(--primary-color);
}

/* Boutons désactivés (verrouillés) */
.btn-locked-wrapper {
    cursor: not-allowed;
}
.btn-locked-wrapper button {
    pointer-events: none;
}
