/* ===== OPTIMISATION RESPONSIVE COMPLÈTE ===== */

/* Variables CSS pour les breakpoints */
:root {
    --mobile: 480px;
    --tablet: 768px;
    --desktop: 1024px;
    --large: 1200px;
}

/* ===== OPTIMISATIONS GÉNÉRALES ===== */

/* Amélioration du viewport et des interactions tactiles */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

body {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Amélioration des boutons pour les écrans tactiles */
.btn {
    min-height: 44px; /* Taille minimale recommandée pour les écrans tactiles */
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px; /* Évite le zoom automatique sur iOS */
    border-radius: 8px;
    transition: all 0.2s ease;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-sm {
    min-height: 36px;
    padding: 8px 16px;
    font-size: 14px;
}

/* ===== HEADER ET NAVIGATION MOBILE ===== */

@media (max-width: 768px) {
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        padding: 10px 0;
    }
    
    .header .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }
    
    .header h1 {
        font-size: 1.5rem;
        margin: 0;
        flex: 1;
    }
    
    /* Menu hamburger pour mobile */
    .mobile-menu-toggle {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 8px;
        border-radius: 4px;
        transition: background-color 0.3s;
    }
    
    .mobile-menu-toggle:hover {
        background-color: rgba(255,255,255,0.2);
    }
    
    .mobile-menu-toggle:active {
        background-color: rgba(255,255,255,0.3);
    }
    
    /* Navigation mobile */
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        flex-direction: column;
        padding: 20px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        border-radius: 0 0 15px 15px;
    }
    
    .nav.active {
        display: flex;
        animation: slideDown 0.3s ease-out;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .nav-link {
        padding: 15px 20px;
        margin: 5px 0;
        border-radius: 8px;
        text-align: center;
        font-size: 16px;
        font-weight: 500;
        transition: all 0.3s ease;
        border: 1px solid rgba(255,255,255,0.2);
    }
    
    .nav-link:hover {
        background-color: rgba(255,255,255,0.3);
        transform: translateX(5px);
    }
    
    .nav-link:active {
        transform: scale(0.98);
    }
}

/* Masquer le toggle sur desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none;
    }
    
    .nav {
        display: flex !important;
    }
}

/* ===== CONTENU PRINCIPAL ===== */

@media (max-width: 768px) {
    .main {
        margin-top: 80px; /* Ajuster selon la hauteur du header mobile */
        padding: 15px 0;
    }
    
    .container {
        padding: 0 15px;
    }
}

/* ===== DASHBOARD RESPONSIVE ===== */

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .dashboard-card {
        padding: 20px;
        margin-bottom: 15px;
    }
    
    .quick-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .quick-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 15px 20px;
        font-size: 16px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .stat-item {
        padding: 15px;
        text-align: center;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-item {
        padding: 12px;
    }
}

/* ===== CARTES D'ANIMAUX RESPONSIVE ===== */

@media (max-width: 768px) {
    .animals-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .animal-card {
        padding: 20px;
        margin-bottom: 15px;
    }
    
    .animal-card .animal-photo-section {
        margin-bottom: 15px;
    }
    
    .animal-card-photo {
        height: 200px;
        object-fit: cover;
        border-radius: 8px;
    }
    
    .animal-card .animal-photo-placeholder {
        height: 200px;
        border-radius: 8px;
    }
    
    .animal-header h3 {
        font-size: 1.3rem;
        margin-bottom: 8px;
    }
    
    .animal-species {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .animal-details p {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    
    .animal-info-row {
        flex-direction: column;
        gap: 5px;
        margin-bottom: 10px;
    }
    
    .animal-physical {
        flex-direction: column;
        gap: 8px;
    }
    
    .animal-color,
    .animal-size,
    .animal-weight {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
    
    .animal-actions {
        justify-content: center;
        margin-top: 15px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .animal-actions .btn {
        flex: 1;
        min-width: 120px;
        padding: 10px 15px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .animal-card {
        padding: 15px;
    }
    
    .animal-card-photo {
        height: 150px;
    }
    
    .animal-card .animal-photo-placeholder {
        height: 150px;
    }
    
    .animal-actions {
        flex-direction: column;
    }
    
    .animal-actions .btn {
        width: 100%;
        min-width: auto;
    }
}

/* ===== FORMULAIRES RESPONSIVE ===== */

@media (max-width: 768px) {
    .form-page {
        padding: 10px;
    }
    
    .form-card {
        padding: 20px;
        margin: 0;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-group label {
        font-size: 16px; /* Évite le zoom automatique sur iOS */
        margin-bottom: 8px;
        font-weight: 600;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Évite le zoom automatique sur iOS */
        padding: 12px 15px;
        border-radius: 8px;
        border: 2px solid #e9ecef;
        transition: all 0.3s ease;
    }
    
    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        border-color: #007bff;
        box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
        outline: none;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 25px;
    }
    
    .form-actions .btn {
        width: 100%;
        padding: 15px 20px;
        font-size: 16px;
        justify-content: center;
    }
}

/* ===== UPLOAD DE PHOTOS RESPONSIVE ===== */

@media (max-width: 768px) {
    .photo-upload-container {
        padding: 15px;
    }
    
    .photo-tabs {
        flex-direction: column;
        gap: 5px;
        margin-bottom: 15px;
    }
    
    .photo-tab {
        padding: 12px 15px;
        font-size: 14px;
        text-align: center;
        border-radius: 8px;
        border: 1px solid #ddd;
        background: white;
    }
    
    .photo-tab.active {
        background: #007bff;
        color: white;
        border-color: #007bff;
    }
    
    .file-upload-box {
        padding: 30px 15px;
    }
    
    .file-upload-box i {
        font-size: 36px;
    }
    
    .file-upload-box p {
        font-size: 14px;
    }
    
    .file-upload-box small {
        font-size: 11px;
    }
    
    .webcam-container video {
        max-height: 250px;
        width: 100%;
    }
    
    .webcam-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .webcam-controls .btn {
        width: 100%;
        padding: 12px 20px;
    }
    
    .file-preview img,
    .webcam-preview img,
    .url-preview img {
        max-width: 100%;
        height: auto;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .photo-upload-container {
        padding: 10px;
    }
    
    .file-upload-box {
        padding: 20px 10px;
    }
    
    .file-upload-box i {
        font-size: 28px;
    }
    
    .webcam-container video {
        max-height: 200px;
    }
}

/* ===== PAGE DÉTAIL ANIMAL RESPONSIVE ===== */

@media (max-width: 768px) {
    .animal-detail-page {
        padding: 10px;
    }
    
    .animal-header-section {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 20px;
        padding: 20px;
    }
    
    .animal-photo-section {
        order: 1;
    }
    
    .animal-basic-info {
        order: 2;
    }
    
    .animal-actions {
        order: 3;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .animal-title {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .animal-title h1 {
        font-size: 2rem;
    }
    
    .animal-quick-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .animal-quick-info .info-item {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .stat-card {
        padding: 15px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .tab-navigation {
        flex-direction: column;
    }
    
    .tab-btn {
        padding: 15px;
        font-size: 14px;
        text-align: center;
    }
    
    .tab-pane {
        padding: 20px;
    }
    
    .info-sections-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .info-section,
    .medical-section {
        padding: 20px;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .modern-form {
        padding: 20px;
    }
    
    .modern-form .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .modern-form .form-actions {
        flex-direction: column;
    }
    
    .medical-item,
    .reminder-item {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        text-align: center;
    }
    
    .item-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .animal-header-section {
        padding: 15px;
    }
    
    .animal-title h1 {
        font-size: 1.5rem;
    }
    
    .animal-status-badge {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .stat-number {
        font-size: 1.2rem;
    }
    
    .tab-pane {
        padding: 15px;
    }
    
    .info-section,
    .medical-section {
        padding: 15px;
    }
}

/* ===== MODALES RESPONSIVE ===== */

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .modal-header h3 {
        font-size: 1.2rem;
    }
    
    .modal form {
        padding: 15px;
    }
    
    .form-container {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 98%;
        margin: 5% auto;
    }
    
    .modal-header {
        padding: 12px;
    }
    
    .modal form {
        padding: 12px;
    }
    
    .form-container {
        padding: 12px;
    }
}

/* ===== CALENDRIER RESPONSIVE ===== */

@media (max-width: 768px) {
    .calendar-container {
        padding: 10px;
    }
    
    .fc-toolbar {
        flex-direction: column;
        gap: 10px;
    }
    
    .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .fc-button {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .fc-toolbar-title {
        font-size: 1.2rem;
        text-align: center;
    }
}

/* ===== AMÉLIORATIONS POUR LES ÉCRANS TACTILES ===== */

/* Amélioration des zones de clic */
.btn, .nav-link, .animal-card, .modal-close {
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Feedback visuel pour les interactions tactiles */
.btn:active,
.nav-link:active,
.animal-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* Amélioration des listes et scrolls */
.animals-list,
.rappels-list,
.vaccins-list,
.traitements-list {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Amélioration des inputs pour mobile */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 8px;
}

/* Amélioration des selects sur mobile */
select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* ===== OPTIMISATIONS POUR TABLETTE ===== */

@media (min-width: 769px) and (max-width: 1024px) {
    .animals-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .animal-header-section {
        grid-template-columns: 150px 1fr auto;
        gap: 20px;
    }
    
    .animal-photo-placeholder {
        width: 120px;
        height: 120px;
    }
    
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .info-sections-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== AMÉLIORATIONS POUR L'ACCESSIBILITÉ ===== */

/* Focus visible pour la navigation au clavier */
.btn:focus,
.nav-link:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Amélioration du contraste pour les petits écrans */
@media (max-width: 768px) {
    .animal-species,
    .animal-details p,
    .rappel-date,
    .vaccin-date {
        color: #555;
    }
    
    .status-badge {
        font-weight: 600;
    }
}

/* ===== ANIMATIONS ET TRANSITIONS OPTIMISÉES ===== */

/* Désactiver les animations sur les appareils qui préfèrent la réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== CORRECTIONS SPÉCIFIQUES POUR iOS ===== */

/* Correction du zoom automatique sur iOS */
@supports (-webkit-touch-callout: none) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px;
    }
}

/* Correction des problèmes de scroll sur iOS */
.animals-list,
.rappels-list,
.modal-content {
    -webkit-overflow-scrolling: touch;
}

/* ===== UTILITAIRES RESPONSIVE ===== */

/* Classes utilitaires pour cacher/afficher selon la taille d'écran */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none;
    }
    
    .show-mobile {
        display: block;
    }
}

/* Classes pour les espacements responsive */
.mobile-padding {
    padding: 15px;
}

@media (min-width: 769px) {
    .mobile-padding {
        padding: 20px;
    }
}

/* Classes pour les tailles de police responsive */
.responsive-text {
    font-size: 14px;
}

@media (min-width: 769px) {
    .responsive-text {
        font-size: 16px;
    }
}

@media (min-width: 1024px) {
    .responsive-text {
        font-size: 18px;
    }
}
