/**
 * Styles optimisés pour l'interface mobile d'Aidannot
 * Ces styles s'appliquent spécifiquement aux écrans de petite taille
 */

/* Styles pour le bouton vocal mobile */
.mobile-voice-container {
    position: sticky;
    top: 10px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 16px;
    margin: 16px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.mobile-voice-btn {
    width: 100% !important;
    font-size: 16px !important;
    padding: 16px 24px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    background: linear-gradient(135deg, var(--bs-primary), rgba(var(--bs-primary-rgb), 0.8)) !important;
    border: none !important;
    color: white !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.mobile-voice-btn:hover, .mobile-voice-btn:active {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(var(--bs-primary-rgb), 0.35);
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb), 0.9), var(--bs-primary)) !important;
}

.mobile-voice-btn.recording {
    background: linear-gradient(135deg, #dc3545, rgba(220, 53, 69, 0.8)) !important;
    animation: pulse-recording 2s infinite;
}

@keyframes pulse-recording {
    0% { box-shadow: 0 8px 25px rgba(220, 53, 69, 0.35); }
    50% { box-shadow: 0 8px 35px rgba(220, 53, 69, 0.5); }
    100% { box-shadow: 0 8px 25px rgba(220, 53, 69, 0.35); }
}

/* Mobile Navigation Improvements */
@media (max-width: 991.98px) {
    .navbar {
        padding: 0.5rem 0;
    }
    
    .navbar-brand img {
        height: 50px !important;
    }
    
    .navbar-collapse {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .navbar-nav {
        gap: 0.5rem;
    }
    
    .navbar-nav .nav-link {
        padding: 1rem !important;
        font-size: 1rem !important; /* Consistent mobile font size */
        font-weight: 500;
        border-radius: 8px;
        margin-bottom: 0.25rem;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        transition: all 0.2s ease;
    }
    
    .navbar-nav .nav-link:hover {
        background: rgba(var(--bs-primary-rgb), 0.15);
        border-color: rgba(var(--bs-primary-rgb), 0.3);
        transform: translateX(4px);
    }
    
    .navbar-nav .nav-link.active {
        background: rgba(var(--bs-primary-rgb), 0.2);
        border-color: var(--bs-primary);
        color: var(--bs-primary) !important;
    }
    
    .navbar-nav .nav-link span {
        font-size: 1.2rem;
        margin-right: 0.75rem;
    }
    
    .dropdown-menu {
        position: static !important;
        transform: none !important;
        border: none;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.1);
        margin-top: 0.5rem;
        border-radius: 8px;
    }
    
    .dropdown-item {
        color: rgba(255, 255, 255, 0.8) !important;
        padding: 0.75rem 1rem;
    }
    
    .dropdown-item:hover {
        background: rgba(255, 255, 255, 0.1);
        color: white !important;
    }
}

/* Styles généraux pour appareils mobiles */
@media (max-width: 768px) {
    /* Améliorations de la navigation */
    .navbar {
        padding: 0.5rem 1rem;
        backdrop-filter: none; /* Disable for performance */
        background: rgba(33, 37, 41, 1) !important;
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .navbar-brand img {
        max-height: 45px;
        transition: transform 0.2s ease;
    }
    
    .navbar-brand:hover img {
        transform: scale(1.05);
    }
    
    .navbar-toggler {
        padding: 0.5rem 0.7rem;
        font-size: 1rem;
        border: 1.5px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        transition: all 0.2s ease;
    }
    
    .navbar-toggler:hover {
        background: rgba(var(--bs-primary-rgb), 0.1);
        border-color: var(--bs-primary);
    }
    
    /* Améliorations du contenu principal */
    .container {
        padding-left: 16px;
        padding-right: 16px;
        max-width: 100%;
    }
    
    h1, .h1 {
        font-size: 1.75rem;
        text-align: center;
        margin-bottom: 1.5rem;
    }
    
    h2, .h2 {
        font-size: 1.5rem;
        text-align: center;
        margin-bottom: 1rem;
    }
    
    /* Améliorer l'espacement général */
    .main-content, .container > .row {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    /* Améliorer la page d'accueil/dashboard */
    .welcome-section {
        text-align: center;
        margin-bottom: 2rem;
    }
    
    .stats-cards {
        margin-bottom: 2rem;
    }
    
    .stats-card {
        margin-bottom: 1rem;
        text-align: center;
    }
    
    /* Améliorer les liens d'action */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin: 1.5rem 0;
    }
    
    .action-buttons .btn {
        width: 100%;
        padding: 1rem;
        font-size: 1.1rem;
        font-weight: 600;
        border-radius: 12px;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
    
    /* Ajustements des cartes et conteneurs */
    .card {
        margin-bottom: 1.25rem;
        border-radius: 16px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    .card-header {
        padding: 1rem 1.25rem;
        border-radius: 16px 16px 0 0 !important;
    }
    
    /* Optimisations pour les formulaires */
    .form-control, .form-select {
        font-size: 16px; /* Évite le zoom automatique sur iOS */
        height: auto;
        padding: 0.875rem 1rem;
        border-radius: 12px;
        border: 1.5px solid rgba(0, 0, 0, 0.08);
    }
    
    .form-control:focus, .form-select:focus {
        transform: none; /* Évite les transformations sur mobile */
        box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        border-radius: 12px;
        min-height: 44px; /* Meilleure accessibilité tactile */
    }
    
    .btn:hover {
        transform: none; /* Évite les transformations sur mobile */
    }
    
    /* Optimisations des tableaux */
    table {
        font-size: 0.85rem;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Forcer le texte en blanc dans les tableaux sur mobile */
    .table thead th,
    .table tbody td,
    .table tbody tr,
    .table-hover tbody tr {
        color: #ffffff !important;
    }
    
    /* S'assurer que les badges restent visibles */
    .table .badge {
        color: #ffffff !important;
    }
    
    /* Texte tronqué en blanc aussi */
    .table .text-truncate,
    .table .text-muted {
        color: rgba(255, 255, 255, 0.8) !important;
    }
    
    /* Liens et boutons dans les tableaux */
    .table a,
    .table .btn {
        color: #ffffff !important;
    }
    
    .table .btn-outline-primary,
    .table .btn-outline-success,
    .table .btn-outline-danger {
        border-color: rgba(255, 255, 255, 0.3) !important;
        color: #ffffff !important;
    }
    
    /* Ajustements pour les graphiques */
    canvas.chart {
        height: 250px !important;
        max-height: 250px !important;
    }
    
    /* Optimisation des espaces */
    .mt-4, .my-4 {
        margin-top: 1rem !important;
    }
    
    .mb-4, .my-4 {
        margin-bottom: 1rem !important;
    }
    
    .pt-4, .py-4 {
        padding-top: 1rem !important;
    }
    
    .pb-4, .py-4 {
        padding-bottom: 1rem !important;
    }
}

/* Styles spécifiques pour très petits écrans */
@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    /* Boutons en pleine largeur sur très petits écrans */
    .btn-block-xs {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Formulaires simplifiés */
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    label {
        font-size: 0.9rem;
    }
    
    /* Meilleure gestion des tabs */
    .nav-tabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Ajustements pour l'éditeur d'annotation */
    .ql-editor {
        max-height: 300px;
        min-height: 150px;
    }
    
    /* Améliorations modales */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
    }
    
    .modal-content {
        height: auto;
        min-height: 100%;
        border-radius: 0;
        border: none;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
        height: calc(100vh - 120px);
    }
    
    .modal-footer {
        padding: 1rem;
        position: sticky;
        bottom: 0;
        background-color: #fff;
    }
    
    /* Améliorer les boutons de fermeture des modales */
    .btn-close {
        padding: 1rem;
        margin: -0.5rem -0.5rem -0.5rem auto;
        opacity: 0.9;
        font-size: 1.25rem;
    }
    
    /* Ajouter un bouton de fermeture fixe en bas des modales */
    .mobile-modal-close {
        display: block;
        width: 100%;
        padding: 1rem;
        margin-top: 1rem;
        text-align: center;
        background-color: #e9ecef;
        border-radius: 0.25rem;
        font-weight: 500;
        font-size: 1.1rem;
        color: #212529;
        border: none;
        position: sticky;
        bottom: 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    /* Rendre le contenu modal plus facile à toucher */
    .modal p, .modal div, .modal button {
        touch-action: auto;
    }
    
    /* Améliorer l'interaction tactile pour les textes */
    .selectable-text {
        -webkit-user-select: text;
        user-select: text;
        cursor: text;
    }
}

/* Interface tactile améliorée */
@media (hover: none) and (pointer: coarse) {
    /* Plus grand espacement pour les éléments cliquables */
    .btn, .nav-link, .form-check-label, .dropdown-item {
        padding: 0.625rem 0.875rem; /* Légèrement plus grand pour faciliter l'appui */
    }
    
    /* Plus d'espace entre les éléments de liste */
    .list-group-item {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    
    /* Meilleur rendu des cases à cocher et boutons radio */
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    /* Ajuster les sliders et autres contrôles tactiles */
    input[type="range"] {
        height: 2rem;
    }
}

/* Optimisations pour l'écran d'annotation */
.mobile-annotation-container {
    display: none !important; /* Caché par défaut, affiché uniquement sur mobile */
}

.desktop-annotation-container {
    display: block !important; /* Affiché par défaut sur desktop */
}

@media (max-width: 768px) {
    .desktop-annotation-container {
        display: none !important; /* Cacher la version desktop sur mobile */
    }
    
    .mobile-annotation-container {
        display: block !important; /* Afficher la version mobile */
    }
    
    /* Optimiser l'espacement des cartes d'annotation */
    .annotation-card, .card {
        margin-bottom: 0.75rem;
        border: none;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* Optimiser les zones de texte */
    #original-text, .mobile-textarea, textarea {
        min-height: 80px;
        max-height: 120px;
        font-size: 16px; /* Pour éviter le zoom sur iOS */
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        resize: vertical;
    }
    
    /* Zones de texte spécifiques pour les annotations */
    #mobile-editor {
        min-height: 80px;
        max-height: 120px;
    }
    
    /* Réduire l'espacement des zones d'annotation */
    .annotation-section {
        margin-bottom: 0.75rem;
    }
    
    .annotation-result {
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
        padding: 0.5rem;
        max-height: 120px;
        overflow-y: auto;
    }
    
    /* Réduire l'espacement entre les éléments */
    .mb-3 {
        margin-bottom: 0.75rem !important;
    }
    
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    /* Boutons d'action compacts */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .action-buttons .btn {
        margin: 0;
        padding: 0.5rem 1rem;
    }
    
    /* Améliorer le rendu de l'annotation reformulée */
    .reformulated-text {
        font-size: 0.95rem;
        padding: 0.5rem;
        margin-top: 0.5rem;
        line-height: 1.5;
    }
    
    /* Réduire l'espacement des sections principales */
    .main-content {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    /* Optimiser l'affichage du compteur d'annotations */
    .stats-card {
        margin-bottom: 0.5rem;
        padding: 0.75rem;
    }
    
    .stats-card .display-4 {
        font-size: 2rem;
    }
}

/* Optimisations pour l'écran d'historique */
@media (max-width: 768px) {
    .history-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .history-filters .form-group {
        margin-bottom: 0.5rem;
    }
    
    .annotation-list .card {
        margin-bottom: 1rem;
    }
    
    .annotation-list .card-body {
        padding: 0.75rem;
    }
    
    .annotation-list .card-title {
        font-size: 1rem;
    }
    
    .annotation-list .card-text {
        font-size: 0.9rem;
    }
    
    /* Ajouter un bouton "voir plus" pour les annotations longues */
    .truncated-text {
        max-height: 100px;
        overflow: hidden;
        position: relative;
    }
    
    .show-more-button {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        text-align: center;
        background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
        padding: 2rem 0 0.5rem 0;
    }
}

/* Amélioration de l'interface tactile pour les sélections et actions */
@media (max-width: 768px) {
    /* Rendre plus facile la sélection de texte */
    .selectable-text {
        user-select: text;
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
    }
    
    /* Améliorer les interactions de glisser-déposer */
    .touch-scroll {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }
    
    /* Ajuster la taille des popups et tooltips */
    .tooltip, .popover {
        font-size: 14px;
    }
    
    /* Boutons flottants supprimés suite à demande utilisateur */
    .floating-action-button {
        display: none !important;
    }
}