/* Custom styles for Document Management System */

/* Dashboard cards */
.card {
    transition: transform 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2) !important;
}

/* Document preview */
.content-preview {
    white-space: pre-wrap;
    font-family: monospace;
    max-height: 70vh;
    overflow-y: auto;
}

/* Chat styles */
.message {
    max-width: 80%;
    word-break: break-word;
}

.message-content {
    white-space: pre-line;
}

/* Document list hover effect */
.table tbody tr {
    transition: background-color 0.2s;
}

.table tbody tr:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.05);
}

/* Improve spacing in the dashboard */
.dashboard-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dashboard-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Make sure footer stays at the bottom and doesn't overlap content */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-bottom: 0;
    position: relative;
    padding-bottom: 60px; /* Space for footer */
}

main {
    flex: 1;
    margin-bottom: 2rem; /* Add extra space at the bottom of the main content */
}

.footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 60px;
    background-color: var(--bs-dark);
    border-top: 1px solid rgba(var(--bs-secondary-rgb), 0.1);
    z-index: 1000; /* Ensure footer stays on top */
}

/* Focus states for accessibility */
:focus {
    outline: 2px solid var(--bs-primary) !important;
    outline-offset: 2px;
}

/* Custom scrollbars for message list */
.message-list::-webkit-scrollbar {
    width: 8px;
}

.message-list::-webkit-scrollbar-track {
    background: rgba(var(--bs-dark-rgb), 0.1);
    border-radius: 10px;
}

.message-list::-webkit-scrollbar-thumb {
    background: rgba(var(--bs-dark-rgb), 0.2);
    border-radius: 10px;
}

.message-list::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--bs-dark-rgb), 0.3);
}

/* Style for source citations in AI responses */
.sources {
    color: var(--bs-secondary);
}

.sources ul {
    padding-left: 1.5rem;
    margin-bottom: 0;
}

/* Spinner for loading states */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 0.2em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
}

/* ==============================================
   MOBILE RESPONSIVE STYLES - FASE 1
   ============================================== */

/* Pulsanti azione chat - flex wrap per mobile */
.answer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.answer-actions .btn {
    white-space: nowrap;
}

/* Sources/Fonti chat - scroll orizzontale su mobile */
.sources {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    min-width: 0;
}

/* Fix per accordion fonti su mobile - previeni testo verticale */
.sources .accordion {
    width: 100%;
    min-width: 0;
}

.sources .accordion-item {
    width: 100%;
    min-width: 0;
}

.sources .accordion-button {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    text-align: left;
    padding: 0.5rem 1rem;
}

.sources .accordion-button strong {
    flex-shrink: 0;
}

.sources .accordion-body {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
    padding: 0.75rem;
}

.sources .accordion-body .table {
    width: 100%;
    table-layout: fixed;
}

.sources .accordion-body .table td,
.sources .accordion-body .table th {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Colonna label più stretta */
.sources .accordion-body .table td:first-child,
.sources .accordion-body .table th:first-child {
    width: 35%;
    min-width: 80px;
}

/* Contenitore accordion con max-width forzato */
.sources .accordion-collapse {
    max-width: 100%;
    overflow: hidden;
}

.sources .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.sources .nav-tabs .nav-item {
    flex-shrink: 0;
}

.sources .nav-tabs .nav-link {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
}

/* Header pulsanti responsive */
.btn-group-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Tabelle responsive wrapper universale */
.table-mobile-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Media queries per schermi piccoli */
@media (max-width: 767.98px) {
    /* Navbar menu items più compatti */
    .navbar-nav .nav-link .text-center {
        font-size: 0.75rem;
    }
    
    .navbar-nav .nav-link i.fa-lg {
        font-size: 1rem;
    }
    
    /* Chat container altezza ridotta */
    .chat-container {
        height: calc(100vh - 140px);
        min-height: 400px;
    }
    
    /* Messaggi chat più larghi su mobile */
    .message {
        max-width: 95%;
    }
    
    /* Pulsanti azione in colonna su schermi molto piccoli */
    .answer-actions {
        flex-direction: column;
    }
    
    .answer-actions .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    /* Card statistiche impilate */
    .stats-card-row .col-md-3 {
        margin-bottom: 0.5rem;
    }
    
    /* Document detail header buttons */
    .document-header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-start;
    }
    
    .document-header-actions .btn,
    .document-header-actions form {
        flex: 1 1 auto;
        min-width: 120px;
    }
    
    .document-header-actions .btn {
        width: 100%;
    }
    
    /* Categorie/Banche - pulsanti più piccoli */
    .list-group-item .btn-sm {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }
    
    /* Modal più responsive */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    /* Form inputs più grandi per touch */
    .form-control, .form-select {
        font-size: 16px; /* Previene zoom su iOS */
    }
    
    /* Sidebar chat nascosta di default su mobile */
    .chat-sidebar-mobile {
        position: fixed;
        left: -100%;
        top: 0;
        width: 80%;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        background: var(--bs-dark);
    }
    
    .chat-sidebar-mobile.show {
        left: 0;
    }
    
    /* Footer più compatto su mobile */
    .footer {
        height: auto;
        padding: 0.5rem 0;
    }
    
    .footer .container {
        font-size: 0.75rem;
    }
}

/* Schermi molto piccoli (< 576px) */
@media (max-width: 575.98px) {
    /* Titoli più piccoli */
    h1, .h1 {
        font-size: 1.5rem;
    }
    
    h2, .h2 {
        font-size: 1.25rem;
    }
    
    /* Container padding ridotto */
    .container, .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Card body padding ridotto */
    .card-body {
        padding: 0.75rem;
    }
    
    /* Pulsanti full-width su mobile piccolo */
    .btn-mobile-full {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Badge più piccoli */
    .badge {
        font-size: 0.65rem;
        padding: 0.25em 0.5em;
    }
    
    /* Progress bar sezione limiti più compatta */
    #limitsSection .card-body {
        padding: 0.5rem;
    }
    
    #limitsSection h4 {
        font-size: 0.9rem;
    }
    
    #limitsSection small {
        font-size: 0.65rem;
    }
}
