:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
}

html, body {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body {
    padding-top: 56px;
    background-color: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    position: relative;
    height: auto;
    min-height: 100vh;
}

.content-wrapper {
    min-height: calc(100vh - 56px);
    padding: 20px 15px;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .content-wrapper {
        padding: 15px 10px;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
}

/* Touch device optimizations */
.touch-device .btn {
    min-height: 44px;
    min-width: 44px;
}

.touch-device .form-control,
.touch-device .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Badge styles */
.badge {
    padding: 0.35em 0.65em;
    font-size: 0.75em;
}

/* Card styles */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* Table styles */
.table {
    font-size: 0.9rem;
}

.table th {
    font-weight: 600;
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

/* Form styles */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* Calendar styles */
.calendar-container {
    overflow-x: auto;
}

.calendar {
    min-width: 100%;
}

.calendar-day {
    min-height: 100px;
    border: 1px solid #dee2e6;
    padding: 5px;
}

.calendar-event {
    background-color: var(--primary-color);
    color: white;
    padding: 2px 5px;
    margin-bottom: 2px;
    border-radius: 3px;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Dashboard stats */
.stat-card-link {
    text-decoration: none;
    display: block;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card-link:hover {
    transform: translateY(-4px);
}

.stat-card-link:hover .stat-card {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.stat-card-link:hover .card {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.stat-card .stat-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    color: #fff;
    font-size: 0.875rem;
}

/* Stat cards mobile compact */
@media (max-width: 576px) {
    .stat-card {
        padding: 1rem 0.5rem;
    }

    .stat-card .stat-icon {
        font-size: 2rem;
        margin-bottom: 0.25rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
        margin-bottom: 0.125rem;
    }

    .stat-card .stat-label {
        font-size: 0.75rem;
        line-height: 1.2;
    }
}

/* Photo gallery */
.photo-thumbnail {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 5px;
    margin: 5px;
    cursor: pointer;
}

.photo-preview {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
}

/* Responsive utilities */
@media (max-width: 576px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Kanban Board Styles */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    height: calc(100vh - 200px); /* Hauteur fixe basée sur la hauteur de l'écran */
    position: relative;
    -webkit-overflow-scrolling: touch; /* Scroll fluide sur iOS */
}

.kanban-column {
    flex: 0 0 300px;
    min-width: 300px;
    background-color: #f8f9fa;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    height: 100%; /* Prendre toute la hauteur du board */
}

.kanban-column-header {
    padding: 1rem;
    color: white;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    flex-shrink: 0; /* Ne pas rétrécir le header */
}

.kanban-column-header h5 {
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
}

.kanban-column-body {
    flex: 1; /* Prendre tout l'espace restant */
    overflow-y: auto;
    padding: 0.5rem;
    min-height: 0; /* Important pour que flex fonctionne correctement */
}

.kanban-card {
    background: white;
    border-radius: 6px;
    padding: 0;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: default;
    transition: box-shadow 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.kanban-card:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.kanban-card-content {
    padding: 0.75rem;
}

.kanban-card-title {
    font-size: 0.9rem;
    line-height: 1.3;
    display: block;
    margin-right: 0.5rem;
}

.kanban-card-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
    line-height: 1.2;
}

.kanban-card-info i {
    font-size: 0.75rem;
    width: 14px;
}

.kanban-card-info span {
    color: #495057;
}

.kanban-card-actions {
    display: flex;
    gap: 0.5rem;
}

.kanban-card-actions .btn {
    color: #6c757d;
    font-size: 0.9rem;
}

.kanban-card-actions .btn:hover {
    color: #495057;
}

.badge-sm {
    font-size: 0.7rem;
    padding: 0.25em 0.5em;
}

.sortable-ghost {
    opacity: 0.4;
    background-color: #e9ecef;
    border: 2px dashed #6c757d;
}

.sortable-drag {
    opacity: 0.8;
    transform: rotate(3deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.sortable-chosen {
    opacity: 0.5;
}

/* Mobile Kanban */
@media (max-width: 768px) {
    .kanban-board {
        /* Garder le scroll horizontal sur mobile pour une vraie expérience Kanban */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Scroll fluide sur iOS */
        padding-bottom: 1rem;
        height: calc(100vh - 11rem); /* ~176px - header + padding */
        transition: transform 0.3s ease, padding 0.3s ease, height 0.3s ease;
    }

    /* Augmenter la hauteur au dézoom pour profiter de l'espace */
    .kanban-board.zoomed-out {
        height: calc(100vh - 3.5rem) !important; /* Maximum de hauteur au dézoom */
        margin-bottom: 0 !important;
    }

    /* Réduire le padding du container quand on est en mode zoom-out */
    .kanban-board.zoomed-out ~ * {
        display: none;
    }

    .kanban-column {
        flex: 0 0 280px; /* Largeur fixe pour chaque colonne sur mobile */
        min-width: 280px;
        height: 100%; /* Utiliser toute la hauteur disponible */
        transition: all 0.3s ease;
    }

    .kanban-column-body {
        flex: 1;
        overflow-y: auto;
        /* Ajouter du padding pour faciliter le scroll sur mobile */
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        transition: max-height 0.3s ease;
        min-height: 0;
    }

    /* Améliorer la zone de scroll sur mobile */
    .kanban-column-body::-webkit-scrollbar {
        width: 8px;
    }

    .kanban-column-body::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    .kanban-column-body::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 4px;
    }

    .kanban-column-body::-webkit-scrollbar-thumb:hover {
        background: #555;
    }

    /* Espacer les cartes pour faciliter le scroll */
    .kanban-card {
        margin-bottom: 1rem;
        transition: all 0.2s ease;
    }

    /* Mode "Vue d'ensemble" pendant le drag sur mobile */
    .kanban-board.kanban-dragging {
        transform: scale(0.6);
        transform-origin: top left; /* Aligner à gauche pour maximiser l'espace */
        padding: 0;
        min-height: 150vh; /* Permettre de voir beaucoup plus de cartes */
        width: 166.67%; /* Compenser le zoom 0.6 (100/0.6 = 166.67) pour utiliser toute la largeur */
    }

    .kanban-board.kanban-dragging .kanban-column {
        flex: 0 0 24%; /* 4 colonnes = ~24% chacune pour maximiser l'espace */
        min-width: 24%;
        max-height: none; /* Retirer la limite de hauteur */
    }

    .kanban-board.kanban-dragging .kanban-column-header {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .kanban-board.kanban-dragging .kanban-column-header h5 {
        font-size: 0.8rem;
    }

    .kanban-board.kanban-dragging .kanban-column-body {
        max-height: none; /* Retirer la limite pour voir toutes les cartes */
        overflow-y: visible;
        padding: 0.25rem;
    }

    .kanban-board.kanban-dragging .kanban-card {
        margin-bottom: 0.4rem;
        font-size: 0.7rem;
    }

    .kanban-board.kanban-dragging .kanban-card-content {
        padding: 0.4rem;
    }

    .kanban-board.kanban-dragging .kanban-card-info {
        font-size: 0.6rem;
        gap: 0.2rem;
    }

    .kanban-board.kanban-dragging .kanban-card-title {
        font-size: 0.75rem;
    }
}

/* Cartes intervention mobile */
.intervention-card-mobile {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid #dee2e6;
}

.intervention-card-mobile .intervention-date {
    font-size: 0.9rem;
}

.intervention-actions .btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    min-width: 40px;
}

.intervention-actions .btn i {
    font-size: 0.9rem;
}

/* Cartes produit mobile */
.produit-card-mobile {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid #10b981;
    transition: all 0.2s;
}

.produit-card-mobile:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.produit-actions .btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    min-width: 40px;
}

.produit-actions .btn i {
    font-size: 0.9rem;
}

/* Vue clients style contacts mobile */
.client-contact-card {
    background: white;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.2s;
    position: relative;
    cursor: pointer;
}

.client-contact-card:active {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.client-contact-content {
    padding: 16px;
}

.client-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.client-name {
    font-weight: 600;
    font-size: 1rem;
    color: #111827;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
}

.client-info {
    font-size: 0.875rem;
    color: #6b7280;
}

.client-quick-actions {
    display: flex;
    gap: 10px;
    padding-top: 12px;
    justify-content: flex-start;
    position: relative;
    z-index: 2;
}

.quick-action-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    transition: all 0.2s;
    pointer-events: auto;
    border-radius: 50%;
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%) !important;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
    flex-shrink: 0;
}

.quick-action-btn:active {
    transform: scale(0.9);
    box-shadow: 0 1px 2px rgba(59, 130, 246, 0.3);
}

.quick-action-btn.disabled {
    background: #e5e7eb !important;
    color: #9ca3af !important;
    pointer-events: none;
    box-shadow: none;
    opacity: 0.5;
}

.quick-action-btn i {
    font-size: 1.1rem;
}

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

    body {
        padding-top: 0;
    }

    .content-wrapper {
        padding: 0;
    }
}