:root {
    --primary: #2c5e2e;
    /* Deep Vine Green */
    --primary-light: #4c8c4e;
    --accent: #d4af37;
    --info: #3498db;

    /* Gold/Terroir */

    /* Modal and Overlay */
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-heading: 'Outfit',
        sans-serif;
    --font-body: 'Inter',
        sans-serif;
    --header-height: 60px;

    /* Missing Design Tokens */
    --surface: #f1f3f5;
    --text-secondary: #636e72;
    --border: #e2e8f0;
    --radius: 12px;
    --badge-border: #1d7200;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    padding-bottom: 80px;
    /* Space for bottom nav/actions if needed */
}

/* Typography */
h1,
h2,
h3 {
    font-family: var(--font-heading);
    color: var(--primary);
    font-weight: 700;
}

h1 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.app-header {
    background: var(--primary);
    color: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.app-header .logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
}

.app-header .user-menu {
    font-size: 0.95rem;
    opacity: 1;
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.nav-link:hover {
    opacity: 0.9;
}

.nav-link-admin {
    color: #ffeb3b;
    font-weight: 700;
}

.nav-link-logout {
    color: white;
    opacity: 0.7;
}

/* Components */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: transform 0.1s, box-shadow 0.2s;
    font-family: var(--font-heading);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-main);
}

.btn-danger {
    background: #e53e3e;
    color: white;
}

.btn-edit {
    text-decoration: none;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 94, 46, 0.1);
}

/* Custom Inputs for Mobile */
/* Date Filter Form */
.date-filter-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.form-control-sm {
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85rem;
}

@media (max-width: 480px) {
    .date-filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
}

.rating-input {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 1rem 0;
}

.rating-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
}

.rating-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Plant Profile Specifics */
.plant-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.plant-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: var(--shadow);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    background: #e2e8f0;
    color: var(--text-muted);
}

.profile-details {
    margin-top: 10px;
    font-weight: 600;
    color: var(--text-main);
}

.profile-details-secondary {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.status-aeroponie {
    background: #e3f2fd;
    color: #1565c0;
}

.status-pepiniere {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-mort_parcelle {
    background: #ffebee;
    color: #c62828;
}

.status-mort_pepiniere {
    background: #fff5f5;
    color: #e53935;
}

.status-vivant {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.status-mort {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Utilities */
.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 1rem;
}

.full-width {
    width: 100%;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 14px 20px;
        width: 100%;
        display: block;
        margin-bottom: 10px;
    }

    .plant-header {
        flex-direction: column;
        text-align: center;
    }
}

/* Dashboard Specifics */
.dashboard-header {
    margin-bottom: 30px;
}

.subtitle {
    color: var(--text-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 160px;
}

.stat-value {
    font-size: 3rem;
    margin-bottom: 0;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 600;
}

.chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chart-donut {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: #eee;
    margin-bottom: 10px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    font-size: 0.75rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.list-item-border {
    display: flex;
    justify-content: space-between;
    padding: 12px 10px;
    border-bottom: 1px solid #f1f1f1;
}

.filters-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.filters-group {
    display: flex;
    gap: 10px;
}

/* Advanced Filter Accordion */
.filter-accordion {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.filter-accordion summary {
    padding: 15px 20px;
    font-weight: 600;
    cursor: pointer;
    background: #f8f9fa;
    border-bottom: 1px solid #ebebeb;
    display: flex;
    align-items: center;
    list-style: none;
    /* Hide default arrow in some browsers */
}

/* Custom arrow for summary */
.filter-accordion summary::-webkit-details-marker {
    display: none;
}

.filter-accordion summary::after {
    content: "▼";
    margin-left: auto;
    font-size: 0.8em;
    color: #666;
    transition: transform 0.2s ease-in-out;
}

.filter-accordion[open] summary::after {
    transform: rotate(180deg);
}

.filter-content {
    padding: 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 768px) {
    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .filter-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.table-card {
    overflow-x: auto;
    padding: 0;
    max-height: 75vh;
    overflow-y: auto;
    border-bottom: 3px solid var(--primary);
    /* Visual cue for scrolling */
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table-header {
    padding: 15px 20px;
    font-weight: 600;
}

.data-table thead tr {
    border-bottom: 2px solid #f1f1f1;
    background-color: var(--primary-light);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.table-row {
    border-bottom: 1px solid #f1f1f1;
    cursor: pointer;
}

.table-cell {
    padding: 15px 20px;
}

/* Admin Specifics */
.admin-table-container {
    overflow-x: auto;
    padding: 0;
}

.admin-badge {
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    display: inline-block;
}

.admin-badge-admin {
    background: #e3f2fd;
    color: #1565c0;
    font-weight: 700;
}

.text-right {
    text-align: right;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
    line-height: 1.2;
}

.gap-small {
    gap: 5px;
}

/* Edit Form Specifics */
.edit-card-container {
    max-width: 600px;
    margin: 20px auto;
}

.form-title {
    color: var(--primary);
    text-align: center;
    margin-bottom: 20px;
}

.rfid-display {
    background: #f1f1f1;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

.form-row {
    display: flex;
    gap: 15px;
}

.flex-1 {
    flex: 1;
}

.flex-2 {
    flex: 2;
}

.form-section-title {
    font-size: 1.1rem;
    margin-top: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    color: var(--primary);
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Final Utilities & Fixes */
.logo-link {
    color: white;
    text-decoration: none;
}

.stat-value-primary {
    color: var(--primary);
    margin-bottom: 0;
    font-size: 3rem;
}

.stat-value-accent {
    color: var(--accent);
    margin-bottom: 0;
    font-size: 3rem;
}

.stat-value-info {
    color: #3498db;
    margin-bottom: 0;
    font-size: 3rem;
}

.legend-item {
    font-weight: bold;
}

.rfid-detected-box {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.rfid-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.rfid-value {
    font-size: 1.5rem;
    color: #1565c0;
    font-weight: bold;
}

.list-none {
    list-style: none;
    padding: 0;
}

.text-primary {
    color: var(--primary);
}

.sort-link {
    color: white;
    text-decoration: none;
}

.table-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
}

.font-bold {
    font-weight: 600;
}

/* History Images */
.history-thumb {
    max-width: 320px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    margin-bottom: 10px;
}

/* Lightbox */
.lightbox-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    align-items: center;
    justify-content: center;
}

.lightbox-img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Profile Measurements */
.profile-measurements {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.badge-vigueur {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

.badge-mesure {
    background: #e1f5fe;
    color: #0277bd;
    border: 1px solid #b3e5fc;
}

.badge-link {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--badge-border);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.badge-link:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Passports Gallery Improvements */
.gallery-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(45, 45, 45, 0.5);
    color: white;
    border: none;
    font-size: 2.5rem;
    padding: 15px 12px;
    cursor: pointer;
    z-index: 1010;
    transition: all 0.2s;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.gallery-arrow:active {
    background: rgba(255, 255, 255, 0.2);
}

.gallery-arrow-prev {
    left: 15px;
}

.gallery-arrow-next {
    right: 15px;
}

.gallery-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.gallery-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.1s ease-out;
    user-select: none;
    -webkit-user-drag: none;
}

/* Accordion */
.accordion-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    overflow: hidden;
}

.accordion-header {
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.accordion-header:hover {
    background: var(--surface);
}

.accordion-header h3 {
    margin: 0;
    font-size: 1rem;
}

.accordion-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.accordion-body {
    padding: 0 20px 20px;
}

.form-section-subtitle {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 16px 0 8px;
}


.auth-wrapper {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-logo {
    max-width: 180px;
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.auth-title {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.dev-branding {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0.8;
}

.dev-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.dev-logo {
    height: 30px;
    width: auto;
    filter: grayscale(100%);
    transition: filter 0.3s;
}

.dev-logo:hover {
    filter: grayscale(0%);
}

/* Mobile Layout Fixes (< 450px) */
@media (max-width: 450px) {

    /* Header Stack */
    .app-header {
        flex-direction: column;
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .app-header .logo {
        margin-right: 0;
        margin-bottom: 5px;
    }

    .app-header .user-menu {
        width: 100%;
        justify-content: center;
        gap: 15px;
    }

    /* Profile Badges Layout */
    .profile-measurements {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .badge-vigueur {
        width: 100%;
        margin-bottom: 8px;
        text-align: center;
        display: block;
    }
}

/* Lightbox Enhancements */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.lightbox-img {
    transition: transform 0.1s;
    /* Smooth zoom */
    transform-origin: center center;
}

/* Label Printing Configuration Layout */
.label-config-row {
    display: flex;
    gap: 15px;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
}

.label-format-col {
    flex: 0 0 65%;
}

.label-speed-col {
    flex: 1;
}

@media (max-width: 767px) {
    .label-config-row {
        flex-direction: column;
        gap: 0;
    }

    .label-format-col,
    .label-speed-col {
        flex: 1 1 100%;
        width: 100%;
    }
}