/* ==========================================
   POTAGER - STYLES COMPLETS
   ========================================== */

/* ==========================================
   1. VARIABLES & RESET
   ========================================== */
:root {
    /* Couleurs principales */
    --primary: #2d6a4f;
    --primary-light: #40916c;
    --primary-dark: #1b4332;
    --primary-bg: rgba(45, 106, 79, 0.1);
    
    /* Couleurs d'état */
    --success: #52b788;
    --success-bg: #d8f3dc;
    --warning: #f9c74f;
    --warning-bg: #fff3cd;
    --danger: #e63946;
    --danger-bg: #f8d7da;
    --info: #4895ef;
    --info-bg: #cfe2ff;
    
    /* Couleurs neutres */
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    
    /* Effets */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --transition: all 0.25s ease;
    --transition-fast: all 0.15s ease;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: 1rem;
}

img {
    max-width: 100%;
    height: auto;
}

/* ==========================================
   2. SIDEBAR
   ========================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    min-height: var(--topbar-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    transition: var(--transition-fast);
    display: none;
}

.sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--primary);
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-section {
    padding: 1rem 1.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--gray-700);
    transition: var(--transition-fast);
    border-left: 3px solid transparent;
}

.nav-item a:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.nav-item.active a {
    background: var(--primary-bg);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Sidebar collapsed */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .user-info {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .nav-item a {
    justify-content: center;
    padding: 0.85rem;
}

.sidebar.collapsed .user-avatar {
    margin: 0 auto;
}

/* ==========================================
   3. MAIN CONTENT
   ========================================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--topbar-height);
    padding: 0 1.5rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    z-index: 100;
}

.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
}

.topbar-search {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.topbar-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.topbar-search input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.75rem;
    background: var(--gray-100);
    border: 2px solid transparent;
    border-radius: var(--radius);
    transition: var(--transition-fast);
}

.topbar-search input:focus {
    outline: none;
    background: var(--white);
    border-color: var(--primary);
}

.topbar-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.topbar-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    transition: var(--transition-fast);
}

.topbar-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.badge-notif {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page Content */
.page-content {
    padding: 1.5rem;
}

/* ==========================================
   4. COMPOSANTS COMMUNS
   ========================================== */

/* Page Header */
.page-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.page-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header p {
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.stat-item {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    text-align: center;
    min-width: 80px;
}

.stat-value {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.7rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.card-header h2,
.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--white);
    color: var(--primary);
}

.btn-primary:hover {
    background: var(--gray-50);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--primary);
    color: var(--white);
}

.btn-success:hover {
    background: var(--primary-dark);
}

.btn-outline {
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
    background: var(--white);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #c5303c;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: capitalize;
}

.badge-seme {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-germe {
    background: #fff3e0;
    color: #ef6c00;
}

.badge-repique {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-recolte {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge-echoue {
    background: #ffebee;
    color: #c62828;
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: var(--success-bg);
    color: #155724;
}

.alert-danger {
    background: var(--danger-bg);
    color: #721c24;
}

.alert-warning {
    background: var(--warning-bg);
    color: #856404;
}

.alert-info {
    background: var(--info-bg);
    color: #0c5460;
}

.alert-close {
    margin-left: auto;
    font-size: 1.25rem;
    opacity: 0.5;
    cursor: pointer;
}

.alert-close:hover {
    opacity: 1;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-section {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--gray-300);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.form-section h3 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-50);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--gray-600);
}

.table tbody tr {
    transition: var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table-actions {
    display: flex;
    gap: 0.35rem;
}

/* ==========================================
   5. FILTERS BAR
   ========================================== */
.filters-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.search-box input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    transition: var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.filters-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-select {
    padding: 0.65rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--white);
    min-width: 130px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.view-toggle {
    display: flex;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-left: auto;
}

.view-btn {
    padding: 0.65rem 0.85rem;
    background: var(--white);
    color: var(--gray-500);
    transition: var(--transition-fast);
}

.view-btn:hover {
    color: var(--primary);
}

.view-btn.active {
    background: var(--primary);
    color: var(--white);
}

/* ==========================================
   6. GRIDS
   ========================================== */
.grid {
    display: grid;
    gap: 1.25rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.grid-auto {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* ==========================================
   7. SEMIS CARDS
   ========================================== */
.semis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.semis-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

.semis-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.semis-card .card-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
}

.semis-card .card-header {
    padding: 1rem 1rem 0.65rem;
    border-bottom: none;
    display: block;
}

.semis-card .variete-nom {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.15rem;
    padding-right: 70px;
}

.semis-card .variete-detail {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.semis-card .card-body {
    padding: 0.65rem 1rem;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.info-row i {
    color: var(--primary);
    width: 16px;
    text-align: center;
    font-size: 0.9rem;
}

/* Taux de germination */
.taux-germination {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--gray-200);
}

.taux-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.taux-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.taux-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
}

.taux-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.taux-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--primary-light));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Timeline */
.card-timeline {
    padding: 0.75rem 1rem;
    background: var(--gray-50);
}

.timeline-track {
    height: 5px;
    background: var(--gray-300);
    border-radius: 3px;
    margin-bottom: 0.4rem;
    overflow: hidden;
}

.timeline-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 3px;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--gray-500);
}

.timeline-labels span.active {
    color: var(--primary);
    font-weight: 600;
}

/* Card Actions */
.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--gray-100);
}

.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.action-btn:hover {
    background: var(--primary);
    color: var(--white);
}

.action-btn.action-danger:hover {
    background: var(--danger);
}

/* ==========================================
   8. MODALS
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(-20px) scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-sm { max-width: 450px; }
.modal-lg { max-width: 800px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 0.5px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--gray-500);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Statut Options (dans modal) */
.statut-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.statut-option {
    cursor: pointer;
}

.statut-option input {
    display: none;
}

.statut-card {
    padding: 1rem;
    text-align: center;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    transition: var(--transition-fast);
}

.statut-card i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.35rem;
}

.statut-option input:checked + .statut-card {
    border-color: var(--primary);
    background: var(--primary-bg);
}

/* ==========================================
   9. DASHBOARD
   ========================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.stat-card-icon.primary {
    background: var(--primary-bg);
    color: var(--primary);
}

.stat-card-icon.success {
    background: var(--success-bg);
    color: var(--success);
}

.stat-card-icon.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-card-icon.info {
    background: var(--info-bg);
    color: var(--info);
}

.stat-card-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card-content p {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* ==========================================
   10. EMPTY STATE
   ========================================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* ==========================================
   11. NOTIFICATIONS
   ========================================== */
.notification {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(120%);
    transition: var(--transition);
    z-index: 3000;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--success);
}

.notification-success i {
    color: var(--success);
}

.notification-error {
    border-left: 4px solid var(--danger);
}

.notification-error i {
    color: var(--danger);
}

/* ==========================================
   12. RESPONSIVE
   ========================================== */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    .sidebar-toggle {
        display: flex;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-row-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 1rem;
    }
    
    .page-header {
        padding: 1.25rem;
    }
    
    .page-header h1 {
        font-size: 1.25rem;
    }
    
    .page-header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-bar {
        width: 100%;
    }
    
    .stat-item {
        flex: 1;
        min-width: 0;
    }
    
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        width: 100%;
    }
    
    .filters-group {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .filter-select {
        flex-shrink: 0;
    }
    
    .view-toggle {
        margin-left: 0;
    }
    
    .semis-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .statut-options {
        grid-template-columns: 1fr;
    }
    
    .topbar-search {
        display: none;
    }
    
    .table th,
    .table td {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .btn span:not(.btn-icon span) {
        display: none;
    }
    
    .btn {
        padding: 0.6rem;
    }
    
    .card-actions {
        justify-content: space-around;
    }
    
    .modal {
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* ==========================================
   13. DARK MODE (optionnel)
   ========================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --white: #1a1a2e;
        --gray-50: #16213e;
        --gray-100: #1f2940;
        --gray-200: #2a3550;
        --gray-300: #3d4a63;
        --gray-400: #5a6a85;
        --gray-500: #8892a8;
        --gray-600: #a8b2c4;
        --gray-700: #c8d0e0;
        --gray-800: #e8ecf4;
        --gray-900: #f8fafc;
    }
    
    .sidebar,
    .topbar,
    .card,
    .semis-card,
    .modal,
    .notification {
        background: var(--white);
    }
    
    .form-control,
    .filter-select,
    .search-box input {
        background: var(--gray-100);
        color: var(--gray-800);
    }
}

/* ==========================================
   14. UTILITAIRES
   ========================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }
.visible { display: block !important; }

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    display: none;
    z-index: 1000;
}

.dropdown-menu.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    transition: var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item.dropdown-danger {
    color: #991b1b;
    background: #fef2f2;
}

.badge-notif.danger {
    background: var(--danger);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
.nav-badge {
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    margin-left: auto;
}

/* ==========================================
   15. SEMIS - CORRECTIONS ET AJOUTS
   ========================================== */

/* Badge type culture repositionné dans le header */
.semis-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.semis-card .card-header-left {
    flex: 1;
    min-width: 0;
    padding-right: 80px; /* Espace pour le badge statut */
}

.semis-card .variete-nom {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badge Direct en ligne avec le header, pas en absolute */
.culture-type-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 0.35rem;
    white-space: nowrap;
}

.culture-type-inline i {
    font-size: 0.65rem;
}

/* Jours restants - sous les infos dans le card-body */
.jours-restants-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.75rem;
}

.jours-restants-box i {
    font-size: 0.9rem;
    width: auto;
}

.jours-restants-box.attente {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.jours-restants-box.imminent {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    animation: pulse-subtle 2s infinite;
}

.jours-restants-box.pret {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.jours-restants-box.retard {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    animation: pulse-subtle 1.5s infinite;
}

@keyframes pulse-subtle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Nombre de graines en évidence */
.graines-count {
    color: var(--primary);
    font-weight: 600;
}

/* Raison échec */
.echec-raison {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #fee2e2;
    border-radius: var(--radius-sm);
    color: #991b1b;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* Carte échec */
.semis-card.card-echec {
    opacity: 0.7;
    border-left: 4px solid var(--danger);
}

.semis-card.card-echec:hover {
    opacity: 0.85;
}

/* Timeline échec */
.timeline-progress.progress-echec {
    background: var(--danger);
}

/* Bouton échec */
.action-btn.btn-echec {
    background: #fef3c7;
    color: #92400e;
}

.action-btn.btn-echec:hover {
    background: #fde68a;
    color: #92400e;
}

/* Bouton next step */
.action-btn.btn-next-step {
    background: var(--success);
    color: var(--white);
}

.action-btn.btn-next-step:hover {
    background: #16a34a;
    color: var(--white);
}

/* Row échec dans tableau */
.row-echec {
    background-color: #fef2f2;
}

/* Stat danger */
.stat-item.stat-danger .stat-value {
    color: var(--danger);
}

/* Modal header danger */
.modal-header-danger {
    background: var(--danger);
    color: white;
}

.modal-header-danger .modal-close {
    color: white;
}

.modal-header-danger .modal-close:hover {
    background: rgba(255,255,255,0.2);
}

/* Info estimation jours dans modal */
.info-estimation {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #1e40af;
    font-size: 0.9rem;
}

/* Workflow legend */
.workflow-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--white);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
}

.workflow-step.optional {
    opacity: 0.7;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    background: var(--gray-50);
}

.workflow-step .step-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.workflow-step .step-label {
    font-size: 0.8rem;
    font-weight: 500;
}

.workflow-step small {
    font-size: 0.65rem;
    color: var(--gray-500);
}

.workflow-arrow {
    font-size: 1.25rem;
    color: var(--gray-400);
}

/* Type culture options dans modal */
.type-culture-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.type-option input {
    display: none;
}

.type-option .type-card {
    padding: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
}

.type-option .type-card:hover {
    border-color: var(--primary);
}

.type-option input:checked + .type-card {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.type-icons {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.type-option .type-card strong {
    display: block;
    margin-bottom: 0.25rem;
}

.type-option .type-card small {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Step form section dans modals */
.step-form-section {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.step-form-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.step-form-section h4 .step-emoji {
    font-size: 1.5rem;
}

/* Responsive pour type culture */
@media (max-width: 768px) {
    .type-culture-options {
        grid-template-columns: 1fr;
    }
    
    .workflow-legend {
        gap: 0.25rem;
        padding: 0.75rem;
    }
    
    .workflow-step {
        padding: 0.25rem 0.5rem;
    }
    
    .workflow-step .step-icon {
        font-size: 1.25rem;
    }
    
    .workflow-step .step-label {
        font-size: 0.7rem;
    }
}

/* ==========================================
   BADGE JOURS RESTANTS - SOUS LE STATUT
   ========================================== */

/* Container pour les badges en haut à droite */
.card-badges-top {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    z-index: 5;
}

/* Badge jours restants compact */
.badge-jours {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-jours i {
    font-size: 0.6rem;
}

.badge-jours.attente {
    background: #dbeafe;
    color: #1e40af;
}

.badge-jours.imminent {
    background: #fef3c7;
    color: #92400e;
    animation: pulse-badge 2s infinite;
}

.badge-jours.pret {
    background: #dcfce7;
    color: #166534;
}

.badge-jours.retard {
    background: #fee2e2;
    color: #991b1b;
    animation: pulse-badge 1.5s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.02); opacity: 0.85; }
}

/* Ajuster le padding du nom de variété pour laisser place aux badges */
.semis-card .variete-nom {
    padding-right: 90px;
}

/* Form row 3 colonnes */
.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    .form-row-3 {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 992px) {
    .form-row-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row-3 .form-group:last-child {
        grid-column: span 2;
    }
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
}

/* --- ICONES TYPES DE CULTURE --- */

/* Type 1 : Plaque -> Godet -> Terre (Orange/Terre cuite) */
.culture-icon.type-plaque_godet_terre i {
    color: #ea580c; /* Orange brûlé */
}
.culture-icon.type-plaque_godet_terre {
    background: #fff7ed;
    border: 1px solid #fdba74;
}

/* Type 2 : Plaque -> Terre (Bleu/Teal) */
.culture-icon.type-plaque_terre i {
    color: #0d9488; /* Teal */
}
.culture-icon.type-plaque_terre {
    background: #f0fdfa;
    border: 1px solid #99f6e4;
}

/* Type 3 : Direct (Vert) */
.culture-icon.type-semis_direct i {
    color: #16a34a; /* Vert */
}
.culture-icon.type-semis_direct {
    background: #dcfce7;
    border: 1px solid #86efac;
}

/* Style commun du badge icône */
.culture-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: transform 0.2s;
}
.culture-icon:hover {
    transform: scale(1.1);
}

/* Timeline Verticale pour Détails */
.timeline-vertical {
    position: relative;
    padding-left: 20px;
    margin-top: 10px;
}
.timeline-vertical:before {
    content: '';
    position: absolute;
    left: 9px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}
.timeline-item {
    position: relative;
    padding-bottom: 20px;
    padding-left: 25px;
}
.timeline-item:last-child { padding-bottom: 0; }
.tl-icon {
    position: absolute;
    left: -11px;
    width: 40px;
    height: 40px;
    background: white;
    border: 2px solid var(--gray-300);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    font-size: 1.2rem;
}
.timeline-item.done .tl-icon {
    border-color: var(--success);
    background: #f0fdf4;
}
.timeline-item.done:before {
    /* Ligne colorée si fait */
    content: '';
    position: absolute;
    left: -11px; /* Ajuster selon le parent */
    /* ... nécessite structure plus complexe pour colorer la ligne, on reste simple ici */
}
.tl-content {
    background: var(--gray-50);
    padding: 10px;
    border-radius: 8px;
}
.d-block { display: block; }

.filters-group {
    display: flex;
    flex-wrap: wrap; /* Permet le retour à la ligne */
    gap: 0.5rem;
    align-items: center;
}

.filter-select {
    max-width: 150px; /* Limite la largeur pour en mettre plus */
    font-size: 0.85rem;
    padding: 0.4rem;
}

/* Toggle Vues */
.view-toggle {
    display: flex;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    margin-left: auto; /* Pousse à droite si flex */
}

.view-btn {
    padding: 0.5rem 0.8rem;
    background: white;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.view-btn.active {
    background: #eef2ff; /* Bleu très clair */
    color: #4f46e5;      /* Bleu indigo */
    font-weight: bold;
}

/* Ajustement barre filtres */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
/* Badge Taux */
.badge-taux {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 5px;
}

/* Barre de taux */
.taux-bar-container {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    margin-top: 4px;
    margin-bottom: 8px; /* Espace après */
    overflow: hidden;
    width: 100%;
}

.taux-bar {
    height: 100%;
    transition: width 0.5s ease;
}

/* Couleurs utilitaires */
.bg-success { background-color: #22c55e; }
.bg-warning { background-color: #f59e0b; }
.bg-danger { background-color: #ef4444; }
.text-success { color: #166534; }
.text-warning { color: #b45309; }
.text-danger { color: #b91c1c; }