/* AgriCoop Custom Styles - Professional & Mobile-Responsive */

/* ========== Root Variables ========== */
:root {
    --primary-green: #28a745;
    --primary-blue: #007bff;
    --light-bg: #f8f9fa;
    --border-radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

/* ========== General Layout ========== */
body {
    font-size: 16px;
    line-height: 1.6;
}

/* Improve card styling */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-body {
    padding: 1.5rem;
}

/* ========== Typography ========== */
h4 {
    font-weight: 600;
    margin-bottom: 1rem;
    color: #2c3e50;
}

h5 {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #34495e;
}

h6 {
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

/* ========== Form Elements ========== */
.form-label, label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 0.95rem;
}

.form-control, .Select-control {
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .Select-control:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

/* ========== Buttons ========== */
.btn {
    border-radius: 6px;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
    font-size: 1rem;
    min-height: 44px; /* Accessibility: minimum touch target */
}

.btn-success {
    background-color: var(--primary-green);
    border-color: var(--primary-green);
}

.btn-success:hover {
    background-color: #218838;
    border-color: #1e7e34;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(40,167,69,0.3);
}

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

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #004085;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

/* ========== Alerts ========== */
.alert {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.alert-heading {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

/* ========== Storage Instructions Special Styling ========== */
#egg-storage-instruction .alert {
    border-left: 4px solid;
    padding: 1.25rem 1.5rem;
    animation: slideIn 0.3s ease;
}

#egg-storage-instruction .alert-success {
    border-left-color: var(--primary-green);
}

#egg-storage-instruction .alert-info {
    border-left-color: #17a2b8;
}

#egg-storage-instruction .alert-warning {
    border-left-color: #ffc107;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== Statistics Cards ========== */
.card-body h4 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-green);
    margin: 0;
}

.card-body .text-muted {
    color: #6c757d !important;
    font-size: 0.875rem;
}

/* ========== Navigation ========== */
.nav-link {
    font-weight: 500;
    padding: 0.45rem 0.75rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.nav-link.active {
    font-weight: 600;
}

/* ========== Spacing Utilities ========== */
.mb-4 {
    margin-bottom: 1.5rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

/* ========== Date Picker Styling ========== */
.DateInput_input {
    padding: 0.5rem 0.75rem !important;
    font-size: 1rem !important;
    border-radius: 6px !important;
}

/* ========== Mobile Navigation ========== */
#mobile-navigation {
    display: none;
}

/* ========== Mobile Responsive Styles (Samsung A23: 360-412px) ========== */
@media (max-width: 768px) {
    /* ===== LAYOUT FIXES ===== */
    /* Hide desktop sidebar */
    [style*="position: fixed"][style*="width: 16rem"] {
        display: none !important;
    }
    
    /* Fix main content container - only when sidebar margin exists */
    [style*="margin-left: 18rem"] {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0.75rem !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Page content adjustments */
    #page-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    /* Prevent horizontal scrolling without breaking position:sticky */
    body {
        max-width: 100vw;
    }
    
    /* Better box model for mobile */
    .card, .form-control, .btn, input, select, textarea {
        box-sizing: border-box !important;
    }
    
    /* ===== MOBILE NAVIGATION ===== */
    #mobile-navigation {
        display: block !important;
        margin: 0.75rem;
        padding: 0.75rem;
        background-color: #ffffff;
        border-radius: 8px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.15);
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    #mobile-navigation select {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 16px !important;
        padding: 0.875rem;
        border: 2px solid #dee2e6;
        border-radius: 8px;
        background-color: #fff;
        font-weight: 500;
    }
    
    /* Fix dropdown positioning */
    #mobile-navigation .dropdown-menu,
    .Select-menu-outer {
        position: fixed !important;
        left: 0.75rem !important;
        right: 0.75rem !important;
        width: auto !important;
        max-width: calc(100vw - 1.5rem) !important;
        z-index: 9999 !important;
    }
    
    /* ===== TYPOGRAPHY ===== */
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    h1 {
        font-size: 1.75rem !important;
        margin-bottom: 1rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.875rem !important;
    }
    
    h3 {
        font-size: 1.35rem !important;
    }
    
    h4 {
        font-size: 1.25rem !important;
        line-height: 1.3;
    }
    
    h5 {
        font-size: 1.1rem !important;
    }
    
    h6 {
        font-size: 0.95rem !important;
    }
    
    p {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    /* ===== CARDS ===== */
    .card {
        margin-bottom: 1rem !important;
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
    }
    
    .card-body {
        padding: 0.875rem !important;
    }
    
    .card-header {
        padding: 0.75rem !important;
        font-size: 1rem;
    }
    
    /* Statistics cards */
    .card-body h4 {
        font-size: 1.5rem !important;
    }
    
    .card-body h6 {
        font-size: 0.85rem !important;
    }
    
    /* ===== FORMS ===== */
    /* Stack all columns vertically */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .row:not(.dashboard-metrics-row):not(.responsive-row) > .col,
    .row:not(.dashboard-metrics-row):not(.responsive-row) > [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-bottom: 0.75rem !important;
    }

    /* Dashboard metric cards: keep 2 per row even on mobile */
    .dashboard-metrics-row,
    .responsive-row {
        margin-left: -0.5rem !important;
        margin-right: -0.5rem !important;
    }
    .dashboard-metrics-row > [class*="col-"],
    .responsive-row > [class*="col-"] {
        width: 50% !important;
        max-width: 50% !important;
        flex: 0 0 50% !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Form labels */
    label, .form-label {
        font-size: 0.9rem !important;
        font-weight: 600;
        margin-bottom: 0.4rem !important;
    }
    
    /* Form inputs */
    .form-control,
    .Select-control,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 6px !important;
        min-height: 44px !important; /* Touch-friendly */
    }
    
    /* Dropdowns */
    .Select-menu-outer {
        font-size: 15px !important;
    }
    
    /* Date picker */
    .DateInput_input {
        font-size: 16px !important;
        padding: 0.75rem !important;
    }
    
    /* ===== BUTTONS =====
       NOTE: do NOT force .btn { width:100% } globally — it stretches header
       and row-action buttons. Buttons that should stretch on mobile must
       opt in via the `w-100` class or a `d-grid` parent.
    */
    .btn {
        padding: 0.6rem 0.9rem !important;
        font-size: 0.95rem !important;
        min-height: 40px !important;
        border-radius: 8px !important;
    }

    .table td .btn,
    .table td .btn-sm {
        min-height: 32px !important;
        padding: 0.15rem 0.35rem !important;
        font-size: 0.75rem !important;
        margin-bottom: 0 !important;
    }
    
    /* ===== ALERTS ===== */
    .alert {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
        margin-bottom: 0.875rem !important;
        border-radius: 6px !important;
    }
    
    .alert-heading {
        font-size: 1rem !important;
        margin-bottom: 0.4rem !important;
    }
    
    #egg-storage-instruction .alert,
    #egg-storage-instruction .card {
        padding: 0.875rem !important;
    }
    
    /* ===== TABLES ===== */
    .table {
        font-size: 0.8rem !important;
    }
    
    .table thead th {
        padding: 0.5rem !important;
        font-size: 0.75rem !important;
    }
    
    .table tbody td {
        padding: 0.5rem !important;
        font-size: 0.8rem !important;
    }
    
    /* Make tables scroll horizontally if needed */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* ===== TABS ===== */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-bottom: 2px solid #dee2e6 !important;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap !important;
        font-size: 0.9rem !important;
        padding: 0.6rem 1rem !important;
        min-width: auto !important;
    }
    
    /* ===== SPACING ===== */
    .mb-4, .my-4 {
        margin-bottom: 1rem !important;
    }
    
    .mt-4, .my-4 {
        margin-top: 1rem !important;
    }
    
    .mb-3, .my-3 {
        margin-bottom: 0.75rem !important;
    }
    
    .mt-3, .my-3 {
        margin-top: 0.75rem !important;
    }
    
    .p-4 {
        padding: 0.875rem !important;
    }
    
    .p-3 {
        padding: 0.75rem !important;
    }
}

@media (max-width: 480px) {
    /* Extra small phones (Samsung A23 at 360px) */
    body {
        font-size: 13px !important;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.3rem !important;
    }
    
    h3 {
        font-size: 1.2rem !important;
    }
    
    h4 {
        font-size: 1.15rem !important;
    }
    
    h5 {
        font-size: 1rem !important;
    }
    
    /* Even more compact cards */
    .card-body {
        padding: 0.65rem !important;
    }
    
    .card-header {
        padding: 0.65rem !important;
        font-size: 0.95rem !important;
    }
    
    /* Statistics cards */
    .card-body h4 {
        font-size: 1.35rem !important;
    }
    
    .card-body h6 {
        font-size: 0.8rem !important;
    }
    
    /* Mobile navigation */
    #mobile-navigation {
        margin: 0.5rem;
        padding: 0.65rem;
    }
    
    #mobile-navigation select {
        padding: 0.75rem;
        font-size: 15px !important;
    }
    
    /* Tighter spacing for very small screens */
    .mb-3, .my-3 {
        margin-bottom: 0.65rem !important;
    }
    
    .mt-3, .my-3 {
        margin-top: 0.65rem !important;
    }
    
    .mb-4, .my-4 {
        margin-bottom: 0.875rem !important;
    }
    
    .mt-4, .my-4 {
        margin-top: 0.875rem !important;
    }
    
    /* Buttons */
    .btn {
        padding: 0.75rem 0.875rem !important;
        font-size: 0.95rem !important;
    }
    
    /* Forms */
    .form-control,
    input,
    select,
    textarea {
        font-size: 15px !important;
        padding: 0.65rem !important;
    }
    
    /* Alerts */
    .alert {
        padding: 0.65rem !important;
        font-size: 0.85rem !important;
    }
}

/* ========== Touch-Friendly Improvements ========== */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .btn {
        min-height: 44px; /* Apple's recommended touch target */
        padding: 0.75rem 1rem;
    }
    
    .form-control, .Select-control {
        min-height: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ========== Dropdown Menu Improvements ========== */
/* Fix double scrollbar: dash-dropdown-content AND dash-dropdown-options both have overflow-y:auto.
   Keep scroll only on the outer content container. */
.dash-dropdown-options {
    overflow-y: visible !important;
    overflow-x: visible !important;
}
.dash-dropdown-option {
    display: flex !important;
    align-items: center !important;
    padding: 6px 12px !important;
    min-height: 32px !important;
}

/* Hide search input on small dropdowns */
.no-search-dropdown .dash-dropdown-search-container {
    display: none !important;
}
.no-search-dropdown .dash-dropdown-search {
    display: none !important;
}

/* ========== Loading States ========== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========== Accessibility ========== */
.btn:focus, .form-control:focus, .Select-control:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* ========== Print Styles ========== */
@page {
    margin: 8mm;
}

@media print {
    .btn, .nav, .sidebar {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .no-print {
        display: none !important;
    }

}


.btn-action-compact {
    padding: 0px 4px !important;
    line-height: 1 !important;
    font-size: 0.65rem !important;
    height: 20px !important;
    min-height: 20px !important;
    max-height: 20px !important;
}

.btn-action-compact-md {
    padding: 0px 10px !important;
    line-height: 1 !important;
    font-size: 11px !important;
    height: 20px !important;
    min-height: 20px !important;
    max-height: 20px !important;
}

#edit-production-unit-modal .modal-body,
#edit-breeding-unit-modal .modal-body {
    font-size: 13px !important;
}
#edit-production-unit-modal .modal-body label,
#edit-breeding-unit-modal .modal-body label {
    font-size: 13px !important;
    font-weight: 500 !important;
    margin-bottom: 2px !important;
}
#edit-production-unit-modal .modal-body .form-control,
#edit-breeding-unit-modal .modal-body .form-control,
#edit-production-unit-modal .modal-body input,
#edit-breeding-unit-modal .modal-body input {
    font-size: 13px !important;
    height: 36px !important;
}
#edit-production-unit-modal .modal-body .Select-value-label,
#edit-breeding-unit-modal .modal-body .Select-value-label,
#edit-production-unit-modal .modal-body .Select-placeholder,
#edit-breeding-unit-modal .modal-body .Select-placeholder,
#edit-production-unit-modal .modal-body .Select-option,
#edit-breeding-unit-modal .modal-body .Select-option,
#edit-production-unit-modal .modal-body .Select-input input,
#edit-breeding-unit-modal .modal-body .Select-input input {
    font-size: 13px !important;
}
#edit-production-unit-modal .modal-body .Select-control,
#edit-breeding-unit-modal .modal-body .Select-control {
    height: 36px !important;
    min-height: 36px !important;
}
#edit-production-unit-modal .modal-body .Select-value,
#edit-breeding-unit-modal .modal-body .Select-value,
#edit-production-unit-modal .modal-body .Select-placeholder,
#edit-breeding-unit-modal .modal-body .Select-placeholder {
    line-height: 34px !important;
}
#edit-production-unit-modal .btn-action-compact,
#edit-breeding-unit-modal .btn-action-compact {
    padding: 0px 4px !important;
    line-height: 1 !important;
    font-size: 0.65rem !important;
    height: 20px !important;
    min-height: 20px !important;
    max-height: 20px !important;
    width: auto !important;
    min-width: auto !important;
}

/* Farm modal — calibration row small buttons match input height */
#edit-farm-modal .modal-body .btn-sm {
    min-height: 31px !important;
    height: 31px !important;
    padding: 0 8px !important;
    line-height: 29px !important;
}

/* ========== Normalize dcc.Dropdown height to match Bootstrap inputs (38px) ========== */
.Select-control {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 8px !important;
    display: flex !important;
    align-items: center !important;
    overflow: hidden !important;
}
.Select-multi-value-container {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    padding: 0 !important;
}
.Select-value,
.Select-placeholder {
    line-height: 36px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
.Select-input {
    height: 36px !important;
    line-height: 36px !important;
    padding: 0 !important;
}
.Select-arrow-zone {
    display: flex !important;
    align-items: center !important;
    padding-right: 4px !important;
}

/* ============================================================
   Mobile optimizations (≤576px): compact buttons & badges
   Logged-in app only — does not affect landing page.
   ============================================================ */
@media (max-width: 576px) {
    /* General buttons */
    .btn {
        font-size: 12px !important;
        padding: 6px 10px !important;
        line-height: 1.2 !important;
    }
    .btn-sm {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }
    .btn-lg {
        font-size: 14px !important;
        padding: 8px 14px !important;
    }

    /* Compact row-action icon buttons (✏️ 🗑️ ⊘ 📊 🔄 etc.) */
    .btn-action-compact,
    td .btn,
    .table .btn,
    .btn-icon {
        min-width: 30px !important;
        min-height: 30px !important;
        padding: 4px 6px !important;
        font-size: 12px !important;
        line-height: 1 !important;
    }

    /* Badges */
    .badge {
        font-size: 10px !important;
        padding: 3px 6px !important;
        font-weight: 500 !important;
    }

    /* Tab labels — keep tappable but tighter */
    .nav-tabs .nav-link {
        font-size: 12px !important;
        padding: 6px 8px !important;
    }
}

/* ===== Sale form — uniform 36px control height ===== */
.sale-form .btn,
.sale-form .form-control,
.sale-form input.form-control {
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    line-height: 36px !important;
    font-size: 13px !important;
}

/* react-select (dcc.Dropdown) inner control */
.sale-form .Select--single > .Select-control,
.sale-form .Select-control,
.sale-form .dash-dropdown .VirtualizedSelectFocusedOption,
.sale-form .dropdown .Select-control {
    height: 36px !important;
    min-height: 36px !important;
}
.sale-form .Select-placeholder,
.sale-form .Select-value,
.sale-form .Select-input {
    line-height: 34px !important;
}
/* Dash 4 / react-select v5 class names */
.sale-form .dash-dropdown > div:first-child,
.sale-form .dash-dropdown [class$="-control"],
.sale-form .dash-dropdown [class*="-control"] {
    min-height: 36px !important;
    height: 36px !important;
}
.sale-form .dash-dropdown [class$="-ValueContainer"],
.sale-form .dash-dropdown [class*="-ValueContainer"] {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
.sale-form .dash-dropdown [class$="-IndicatorsContainer"],
.sale-form .dash-dropdown [class*="-IndicatorsContainer"] {
    height: 36px !important;
}

/* Keep outline buttons from going solid on focus/active (breeding registration cards) */
.btn-outline-success:focus, .btn-outline-success:active,
.btn-outline-success:focus-visible, .btn-outline-success.active {
    background-color: transparent !important;
    color: #198754 !important;
    box-shadow: 0 0 0 0.2rem rgba(25,135,84,.25) !important;
}
.btn-outline-warning:focus, .btn-outline-warning:active,
.btn-outline-warning:focus-visible, .btn-outline-warning.active {
    background-color: transparent !important;
    color: #fd7e14 !important;
    box-shadow: 0 0 0 0.2rem rgba(255,193,7,.25) !important;
}
