@import url('avima.css');
@import url('view/main-view.css');
@import url('view/main-view-top-menu.css');
@import url('view/login-view.css');
@import url('components/section.css');

/* ── Dashboard Container Styles ──────────────────────────────────────────── */
.dashboard-container {
    width: 100%;
    padding: var(--lumo-space-m);
}

/* Dashboard cards wrapper - responsive grid layout */
.dashboard-cards-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 0;
    margin: 0;
    width: 100%;
    align-items: flex-start;
}

/* Individual dashboard card */
.dashboard-card {
    flex: 0 0 calc(50% - 8px);
    min-width: 300px;
    max-width: 50%;
}

/* Responsive: Tablet (max-width 960px) */
@media (max-width: 960px) {
    .dashboard-card {
        flex: 0 0 calc(50% - 8px);
    }
}

/* Responsive: Mobile (max-width 600px) */
@media (max-width: 600px) {
    .dashboard-card {
        flex: 0 0 100%;
    }

    .dashboard-container {
        padding: var(--lumo-space-s);
    }
}

/* ── Error dialog — red header ───────────────────────────────────────────── */
vaadin-dialog-overlay[theme~="error-dialog"]::part(overlay) {
    border: 2px solid #b91c1c;
    border-radius: var(--lumo-border-radius-l);
    overflow: hidden;
}

vaadin-dialog-overlay[theme~="error-dialog"]::part(header) {
    background-color: #b91c1c;
    color: white;
    padding: var(--lumo-space-m) var(--lumo-space-l);
}

vaadin-dialog-overlay[theme~="error-dialog"] h2 {
    color: white !important;
    font-size: var(--lumo-font-size-l);
}

vaadin-dialog-overlay[theme~="error-dialog"]::part(content) {
    padding: var(--lumo-space-l);
    white-space: pre-line;
}


/* Supplier group headers in ComboBox dropdown — non-selectable */
vaadin-combo-box-item.supplier-group-header {
    pointer-events: none !important;
    cursor: default !important;
    background: transparent !important;
}

vaadin-combo-box-item.supplier-group-header::part(content) {
    padding: 0;
}

/* Stock movement row colors */
vaadin-grid-cell-content .stock-movement-entree,
vaadin-grid tr.stock-movement-entree td {
    background-color: #f0fff4 !important;
}

vaadin-grid-cell-content .stock-movement-sortie,
vaadin-grid tr.stock-movement-sortie td {
    background-color: #fff5f5 !important;
}

/* Indirect rows — muted background + left border accent */
vaadin-grid-cell-content .stock-movement-indirect,
vaadin-grid tr.stock-movement-indirect td {
    background-color: #f8f8f8 !important;
}

vaadin-grid::part(row).stock-movement-entree {
    background: #f0fff4;
}

vaadin-grid::part(row).stock-movement-sortie {
    background: #fff5f5;
}

vaadin-grid::part(row).stock-movement-indirect {
    background: #f5f5f5;
    opacity: 0.85;
}

/* ── Filters Panel ─────────────────────────────────────────────────────── */
.filters-panel {
    background-color: var(--lumo-contrast-5pct);
    border-radius: var(--lumo-border-radius-m);
    margin-bottom: var(--lumo-space-s);
    border: 1px solid var(--lumo-contrast-10pct);
    padding: var(--lumo-space-s) !important;
}

.filters-panel h3 {
    margin-top: 0;
    margin-bottom: var(--lumo-space-xs);
    color: var(--lumo-primary-text-color);
    font-weight: 600;
    font-size: var(--lumo-font-size-m);
}

.buttons-panel {
    margin-bottom: var(--lumo-space-xs);
}

/* ── Compact Filter Forms ─────────────────────────────────────────────────── */
.filters-panel vaadin-form-layout {
    --lumo-space-s: 0.25rem;
    margin-bottom: 0;
    margin-top :auto
}

.filters-panel vaadin-select,
.filters-panel vaadin-combo-box,
.filters-panel vaadin-date-picker {
    --lumo-text-field-size: var(--lumo-size-s);
    font-size: var(--lumo-font-size-s);
}


/* ── Stock Movement Type Badges ───────────────────────────────────────────── */
.stock-movement-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--lumo-border-radius-s);
    font-size: var(--lumo-font-size-s);
    font-weight: 500;
    color: white;
}

.stock-movement-type-entree {
    background-color: #2e7d32;
}

.stock-movement-type-sortie {
    background-color: #c62828;
}

/* ── Company Styled Fields ────────────────────────────────────────────────── */
.company-styled {
    background-color: #e0e0e0;
    padding: 2px 8px;
    border-radius: var(--lumo-border-radius-s);
    font-size: var(--lumo-font-size-s);
}

/* ── Clickable Links ───────────────────────────────────────────────────────── */
.clickable-link {
    color: var(--lumo-primary-color);
    cursor: pointer;
    text-decoration: underline;
}

.clickable-link:hover {
    text-decoration: none;
}

/* Styles pour le dialogue de production journalière */
/* En-tête avec informations de la bande */
.band-info-header {
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #d1e7ff;
    margin-bottom: var(--lumo-space-s);
}

.band-info-dates {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 6px;
    padding: 8px;
    border: 1px solid #dee2e6;
    margin-bottom: var(--lumo-space-m);
}

/* Labels des informations */
.info-label {
    font-weight: bold;
    color: #1976d2;
    font-size: 12px;
    margin-bottom: var(--lumo-space-xs);
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.date-label {
    font-weight: bold;
    color: #495057;
    font-size: 12px;
    margin-bottom: var(--lumo-space-xs);
}

.date-value {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

/* Styles pour les champs d'input de production */
/* Champ mortalité - rouge clair */
vaadin-integer-field[theme~="mortality-field"] {
    --vaadin-input-field-background: #ffe6e6;
}

/* Champs production principale - bleu clair */
vaadin-integer-field[theme~="production-main-field"] {
    --vaadin-input-field-background: #e6f3ff;
}

/* Champs production secondaire - vert clair */
vaadin-integer-field[theme~="production-secondary-field"] {
    --vaadin-input-field-background: #e8f5e8;
}

/* ── Vente Detail Styles ──────────────────────────────────────────────── */
/* Section d'en-tête de vente */
.vente-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: var(--lumo-space-m);
    border: 1px solid #dee2e6;
    margin-bottom: var(--lumo-space-m);
}

/* Total de vente en surbrillance */
.vente-total {
    font-size: 1.5em;
    font-weight: bold;
    color: #28a745;
    text-align: center;
    padding: var(--lumo-space-s);
    background-color: #f8fff9;
    border-radius: var(--lumo-border-radius-m);
    border: 2px solid #28a745;
    margin: var(--lumo-space-m) 0;
}

.vente-total-value {
    color: #28a745 !important;
    font-weight: bold !important;
    font-size: 1.2em !important;
}

/* DataGrid pour la saisie des ventes */
.vente-items-grid {
    border: 1px solid var(--lumo-contrast-20pct);
    border-radius: var(--lumo-border-radius-m);
}

.vente-items-grid vaadin-grid-cell-content {
    padding: var(--lumo-space-xs);
}

/* Colonnes spécifiques du grid de vente */
.vente-type-column {
    font-weight: 600;
    color: var(--lumo-primary-text-color);
    background-color: var(--lumo-contrast-5pct);
}

.vente-stock-column {
    font-weight: 500;
    color: var(--lumo-secondary-text-color);
    background-color: #f0f8ff;
    text-align: right;
}

/* Styles pour alertes de stock */
.stock-warning {
    background-color: #fff3cd !important;
    color: #856404 !important;
}

.stock-danger {
    background-color: #f8d7da !important;
    color: #721c24 !important;
}

.quantity-invalid {
    background-color: #f8d7da !important;
    border: 2px solid #dc3545 !important;
}

.vente-quantity-column input,
.vente-price-column input {
    text-align: right;
}

.vente-total-column {
    font-weight: bold;
    color: var(--lumo-success-color);
    text-align: right;
    background-color: #f8fff9;
}

/* Styles pour les champs éditables dans le grid */
.vente-items-grid vaadin-integer-field,
.vente-items-grid vaadin-number-field {
    --vaadin-input-field-border-width: 1px;
    --vaadin-input-field-border-color: var(--lumo-contrast-30pct);
}

.vente-items-grid vaadin-integer-field:focus-within,
.vente-items-grid vaadin-number-field:focus-within {
    --vaadin-input-field-border-color: var(--lumo-primary-color);
    --vaadin-input-field-background: #f0f8ff;
}

/* Actions du DataGrid */
.vente-grid-actions {
    text-align: center;
}

.vente-grid-actions vaadin-button {
    min-width: auto;
    padding: var(--lumo-space-xs) var(--lumo-space-s);
}

/* Responsive pour les ventes */
@media (max-width: 768px) {
    .vente-header {
        padding: var(--lumo-space-s);
    }

    .vente-total {
        font-size: 1.2em;
    }
}

/* Search and Filter Panel Styles */
.filter-panel {
    background-color: var(--lumo-contrast-5pct);
    border-radius: var(--lumo-border-radius-m);
    padding: var(--lumo-space-m);
    margin-bottom: var(--lumo-space-m);
    border: 1px solid var(--lumo-contrast-10pct);
}

.filter-panel vaadin-text-field {
    --lumo-text-field-size: var(--lumo-size-m);
}

.filter-panel vaadin-text-field::part(input-field) {
    background-color: var(--lumo-base-color);
    border: 1px solid var(--lumo-contrast-20pct);
    border-radius: var(--lumo-border-radius-s);
}

.filter-panel vaadin-text-field:focus-within::part(input-field) {
    border-color: var(--lumo-primary-color);
    box-shadow: 0 0 0 2px var(--lumo-primary-color-10pct);
}

/* Real-time search visual feedback */
.filter-panel vaadin-text-field[searching]::part(input-field) {
    border-color: var(--lumo-primary-color);
    background-color: var(--lumo-primary-color-10pct);
}

.filter-panel vaadin-text-field[searching] vaadin-icon {
    color: var(--lumo-primary-color);
    animation: search-pulse 1s ease-in-out infinite;
}

@keyframes search-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Search field focus improvements */
.filter-panel vaadin-text-field::part(input-field):focus {
    outline: 2px solid var(--lumo-primary-color-50pct);
    outline-offset: 2px;
}

/* Smooth transitions */
.filter-panel vaadin-text-field::part(input-field) {
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-panel vaadin-icon {
    transition: color 0.2s ease, opacity 0.2s ease;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-panel {
        padding: var(--lumo-space-s);
        margin-bottom: var(--lumo-space-s);
    }

    .filter-panel vaadin-text-field {
        width: 100% !important;
        max-width: none !important;
    }
}

/* ── Bande Detail View - Expenses Tab Styles ────────────────────────────── */

/* Container principal de l'onglet dépenses */
.expenses-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Titre des dépenses */
.expenses-title {
    margin: 0;
    padding: 8px 16px;
    font-size: var(--lumo-font-size-l);
    font-weight: 500;
}

/* Pagination des dépenses */
.expenses-pagination {
    padding: 4px 16px;
    margin: 0;
    gap: 8px;
}

/* Wrapper des 3 cards - Responsive Flexbox */
.costs-cards-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    margin: 8px;
}

/* Chaque card de coût */
.costs-card {
    flex: 1 1 auto;
    min-width: 200px;
    max-width: 100%;
}

/* En-tête de la card */
.costs-header {
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Titre des coûts */
.costs-title {
    margin: 0;
    padding: 0;
    font-size: var(--lumo-font-size-m);
    font-weight: 600;
    color: var(--lumo-primary-text-color);
}

/* Valeur de coût standard */
.cost-value {
    font-size: var(--lumo-font-size-l);
    font-weight: 600;
    white-space: nowrap;
}

/* Coût total avec couleur primaire */
.cost-total {
   font-size: var(--lumo-font-size-l);
    font-weight: 600;
    white-space: nowrap;
}

/* Responsive: Tablet (max-width 960px) */
@media (max-width: 960px) {
    .costs-card {
        flex: 1 1 calc(50% - 6px);
    }
}

/* Responsive: Mobile (max-width 600px) */
@media (max-width: 600px) {
    .costs-card {
        flex: 1 1 100%;
    }

    .costs-cards-wrapper {
        padding: 8px;
        margin: 4px;
        gap: 8px;
    }
}

/* Card couleurs par phase */
/* Card Élevage - Vert */
#elevageCostCard {
    --lumo-primary-border-color: #E8F5E9;
    border-color: #1B5E20 !important;
}

#elevageCostCard::part(header) {
    background-color: #E8F5E9;
    border-bottom: 2px solid #1B5E20;
}

#elevageCostCard::part(header) .costs-title {
    color: #1B5E20;
}

/* Card Production - Orange */
#productioncostsCard {
    --lumo-primary-border-color: #FFF3E0;
    border-color: #E65100 !important;
}

#productioncostsCard::part(header) {
    background-color: #FFF3E0;
    border-bottom: 2px solid #E65100;
}

#productioncostsCard::part(header) .costs-title {
    color: #E65100;
}

/* Card Total - Couleur primaire */
#totalCostCard {
    border-color: var(--lumo-primary-color) !important;
}

#totalCostCard::part(header) {
    background-color: var(--lumo-primary-color-10pct);
    border-bottom: 2px solid var(--lumo-primary-color);
}

#totalCostCard::part(header) .costs-title {
    color: var(--lumo-primary-color);
}

/* Large Desktop (min-width 1400px) */
@media (min-width: 1400px) {
    .costs-card {
        flex: 0 1 calc(33.333% - 8px);
    }
}

/* ── Statistics Tab Styles ────────────────────────────────────────────── */

/* Container de l'onglet statistiques */
.statistics-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Header de la section statistiques */
.statistics-header {
    padding: 8px 16px;
}

/* Titre des statistiques */
.statistics-title {
    margin: 0;
    padding: 0;
    font-size: var(--lumo-font-size-l);
    font-weight: 500;
}

/* Pagination des statistiques */
.statistics-pagination {
    padding: 4px 16px;
    margin: 0;
    gap: 8px;
}

/* ── Band Status Badge Styles (Farm Detail - Bandes Tab) ────────────── */
.band-status-not_started {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    background-color: #f3f3f3;
    color: #333333;
    font-weight: 500;
    font-size: var(--lumo-font-size-s);
}

.band-status-elevage {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    background-color: #fff3cd;
    color: #856404;
    font-weight: 500;
    font-size: var(--lumo-font-size-s);
}

.band-status-production {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    background-color: #d4edda;
    color: #155724;
    font-weight: 500;
    font-size: var(--lumo-font-size-s);
}

.band-status-finished {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    background-color: #f8d7da;
    color: #721c24;
    font-weight: 500;
    font-size: var(--lumo-font-size-s);
}
