/* Feed page – Farm Manager brand palette */

:root {
    --fm-green-dark: #234f2e;
    --fm-green: #2f6b2f;
    --fm-text: #1f2520;
    --fm-muted: #566052;
    --fm-page-bg: #eef1e6;
    --fm-green-soft: #e6efe2;
    --fm-surface: #ffffff;
    --fm-surface-soft: #f8f9f4;
    --fm-border: #cfd8c6;
    --fm-amber: #d99a24;
    --fm-alert: #b42318;
}

body {
    background: var(--fm-page-bg);
    background-image: none;
    color: var(--fm-text);
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

body::before {
    display: none;
}

@supports (padding: max(0px)) {
    body {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }
}

#app-content {
    padding-left: 0;
    padding-right: 0;
    padding-top: 0.75rem;
}

.feed-container {
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
    width: min(calc(100% - 1.5rem), 1440px);
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.25rem 0 7.5rem;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    box-sizing: border-box;
}

.feed-container > * {
    box-sizing: border-box;
}

.feed-container .content-container {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    background: transparent;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
}

.feed-page-hero,
.quick-actions,
.feed-actions,
.feed-workspace,
.feed-activity-grid,
.feed-management-actions {
    width: 100%;
}

.app-page-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.feed-page-hero {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
    gap: 2rem;
    align-items: center;
    background: linear-gradient(135deg, #ffffff 0%, #e6efe2 100%);
    border: 1px solid var(--fm-border);
    border-radius: 24px;
    padding: 1.6rem 2rem;
    box-shadow: 0 14px 30px rgba(31, 37, 32, 0.08);
}

.feed-page-hero__brand {
    display: flex;
    align-items: center;
    justify-content: center;
}

.feed-page-hero__copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
}

.brand-logo--app-page {
    display: block;
    max-width: 220px;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.page-kicker {
    margin: 0 0 0.35rem;
    color: var(--fm-green);
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

.feed-page-title {
    margin: 0;
    padding-bottom: 0;
    color: var(--fm-green-dark);
    font-size: clamp(2.4rem, 5vw, 4rem);
    font-weight: 900;
    letter-spacing: -0.055em;
    line-height: 0.95;
    text-align: left;
    text-shadow: none;
    text-transform: none;
    display: block;
}

.feed-page-title::after {
    display: none;
}

.page-subtitle {
    margin: 0.75rem 0 0;
    color: var(--fm-muted);
    font-size: clamp(0.98rem, 1.5vw, 1.08rem);
    line-height: 1.5;
    font-weight: 400;
    max-width: 720px;
}

.quick-actions,
.feed-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 1rem;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
}

.quick-actions .action-button,
.feed-quick-actions .action-button {
    min-height: 52px;
    font-size: 1rem;
}

.feed-actions,
.action-buttons.feed-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 1rem;
    background: #ffffff;
    border: 1px solid var(--fm-border);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 10px 24px rgba(31, 37, 32, 0.06);
}

.feed-workspace {
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
}

.stat-card,
.feed-card,
.feed-section {
    background: var(--fm-surface);
    border: 1px solid var(--fm-border);
    border-radius: 20px;
    box-shadow: 0 10px 24px rgba(31, 37, 32, 0.07);
    overflow: hidden;
    margin-bottom: 0;
    padding: 1.35rem;
}

.stat-card h3 {
    margin: 0 0 1.1rem;
    color: var(--fm-green-dark);
    font-weight: 850;
    font-size: 1.15rem;
    text-shadow: none;
    text-transform: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.stat-card h3::after {
    display: none;
}

.feed-stock-grid,
.feed-status-grid,
#feed-inventory,
#thresholds-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

#feed-inventory > p,
#thresholds-list > p,
#calculations-list > p,
#usage-list > p,
#alerts-list > p {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--fm-muted);
}

.feed-activity-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
    gap: 1.5rem;
    align-items: start;
}

.feed-activity-grid .stat-card {
    margin-bottom: 0;
    padding: 1.35rem;
}

.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 999px;
    min-height: 50px;
    padding: 0.85rem 1.15rem;
    font-weight: 850;
    line-height: 1.2;
    letter-spacing: -0.01em;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
    text-transform: none;
    box-shadow: none;
}

.action-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(31, 37, 32, 0.10);
}

.btn-primary,
.btn-success {
    background: var(--fm-green-dark);
    color: #ffffff;
    border-color: var(--fm-green-dark);
}

.btn-primary:hover,
.btn-success:hover {
    background: var(--fm-green);
    border-color: var(--fm-green);
}

.btn-secondary {
    background: var(--fm-surface);
    color: var(--fm-green-dark);
    border-color: var(--fm-border);
}

.btn-secondary:hover {
    background: var(--fm-green-soft);
    border-color: var(--fm-green);
}

.btn-warning {
    background: var(--fm-surface);
    color: #7a5200;
    border-color: rgba(217, 154, 36, 0.45);
}

.btn-warning:hover {
    background: var(--fm-green-soft);
    border-color: var(--fm-amber);
}

.btn-danger {
    background: var(--fm-surface);
    color: var(--fm-alert);
    border-color: rgba(180, 35, 24, 0.35);
}

.btn-danger:hover {
    background: var(--fm-surface);
    border-color: var(--fm-alert);
}

.feed-management-actions,
.management-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    background: transparent;
    border: 1px dashed var(--fm-border);
    border-radius: 18px;
    padding: 1rem;
}

.feed-management-actions::before,
.management-actions::before {
    content: none !important;
}

.feed-management-actions .action-button {
    min-height: 48px;
}

/* Inventory and stock items */
.inventory-item,
.threshold-item,
.calculation-item,
.usage-item,
.alert-item,
.feed-item,
.feed-stock-item,
.feed-status-item,
.feed-record-item,
.history-item {
    background: var(--fm-surface-soft);
    border: 1px solid var(--fm-border);
    border-radius: 16px;
    padding: 1rem 1.1rem;
    margin: 0 0 0.9rem;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.inventory-item:last-child,
.threshold-item:last-child,
.calculation-item:last-child,
.usage-item:last-child,
.alert-item:last-child {
    margin-bottom: 0;
}

.inventory-item {
    display: flex;
    flex-direction: column;
}

.inventory-header,
.calculation-header,
.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.feed-name,
.calculation-type,
.threshold-name,
.usage-type {
    color: var(--fm-green-dark);
    font-weight: 850;
}

.feed-quantity {
    color: var(--fm-green-dark);
    font-weight: 900;
    font-size: 1.1rem;
}

.feed-details,
.feed-meta,
.calculation-details,
.usage-details,
.alert-details {
    color: var(--fm-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.feed-details > div,
.calculation-details > div,
.usage-details > div {
    margin-bottom: 0.25rem;
}

.low-stock,
.status-warning,
.quantity-low {
    border-left: 4px solid var(--fm-amber);
}

.good-stock,
.status-good,
.in-stock,
.quantity-good {
    border-left: 4px solid var(--fm-green);
}

.status-danger,
.out-of-stock,
.alert-item,
.threshold-item.critical {
    border-left: 4px solid var(--fm-alert);
}

.threshold-item.warning {
    border-left: 4px solid var(--fm-amber);
}

.threshold-item.good {
    border-left: 4px solid var(--fm-green);
}

.threshold-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.threshold-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
}

.threshold-value {
    color: var(--fm-muted);
    font-size: 0.9rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    display: inline-block;
}

.status-indicator.status-good {
    background-color: var(--fm-green);
}

.status-indicator.status-warning {
    background-color: var(--fm-amber);
}

.status-indicator.status-critical {
    background-color: var(--fm-alert);
}

.calculation-date,
.usage-date {
    color: var(--fm-muted);
    font-size: 0.85rem;
}

.calculation-costs {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--fm-border);
}

.total-cost {
    color: var(--fm-green-dark);
    font-weight: 850;
}

.alert-message {
    color: var(--fm-alert);
    font-weight: 850;
}

.show-more {
    text-align: center;
    font-size: 0.85rem;
    color: var(--fm-muted);
    font-style: italic;
    padding: 0.5rem 0 0;
    margin: 0;
}

/* Popup styles */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow: hidden;
}

.popup-content {
    background-color: var(--fm-surface);
    border: 1px solid var(--fm-border);
    padding: 20px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-sizing: border-box;
    box-shadow: 0 14px 30px rgba(31, 37, 32, 0.12);
}

.popup-content h3 {
    margin-top: 0;
    color: var(--fm-green-dark);
    font-weight: 850;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label,
label {
    display: block;
    margin-bottom: 5px;
    color: var(--fm-green-dark);
    font-weight: 750;
}

input,
select,
textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 16px;
    border: 1px solid var(--fm-border);
    border-radius: 12px;
    background: #ffffff;
    color: var(--fm-text);
    padding: 0.75rem 0.85rem;
}

input[type="date"] {
    min-height: 44px;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    margin-top: 4px;
}

input:focus,
select:focus,
textarea:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: 2px solid rgba(47, 107, 47, 0.25);
    border-color: var(--fm-green);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.cancel-btn {
    background-color: var(--fm-surface);
    color: var(--fm-muted);
    border: 1px solid var(--fm-border);
    padding: 10px 15px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
}

.save-btn {
    background-color: var(--fm-green-dark);
    color: #ffffff;
    border: 1px solid var(--fm-green-dark);
    padding: 10px 15px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
}

.save-btn:hover {
    background-color: var(--fm-green);
    border-color: var(--fm-green);
}

.input-unit-group {
    display: flex;
    gap: 8px;
}

.input-unit-group input {
    flex: 2;
}

.input-unit-group select {
    flex: 1;
}

.calculator-result {
    background-color: var(--fm-surface-soft);
    border: 1px solid var(--fm-border);
    padding: 15px;
    border-radius: 16px;
    margin-top: 15px;
    margin-bottom: 15px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--fm-border);
    color: var(--fm-text);
}

.result-item:last-child {
    border-bottom: none;
    font-weight: 850;
    color: var(--fm-green-dark);
}

/* Brand overrides – beat legacy main.css on this page */
.feed-container .action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    margin-bottom: 0;
    white-space: normal;
    word-break: break-word;
}

.feed-container .action-button:before {
    display: none;
}

.feed-container .action-button:active {
    transform: none;
    box-shadow: none;
    border-bottom: none;
}

.feed-container .button-row .action-button {
    width: auto;
}

.feed-container .stat-card h3 {
    background: transparent;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
    padding: 0;
}

/* Responsive layout */
@media (max-width: 1100px) {
    .feed-stock-grid,
    .feed-status-grid,
    #feed-inventory,
    #thresholds-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .feed-actions,
    .action-buttons.feed-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .feed-activity-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .feed-page-hero {
        grid-template-columns: 1fr;
        gap: 1.1rem;
        padding: 1.35rem 1.25rem;
        text-align: center;
    }

    .feed-page-hero__copy {
        text-align: center;
        align-items: center;
    }

    .feed-page-title {
        font-size: clamp(2.3rem, 12vw, 3.4rem);
        text-align: center;
    }

    .page-subtitle {
        max-width: 34rem;
    }

    .brand-logo--app-page {
        max-width: 180px;
    }
}

@media (max-width: 700px) {
    .feed-container {
        width: min(calc(100% - 1rem), 100%);
        padding-top: 0.9rem;
        padding-bottom: 7.75rem;
    }
}

@media (max-width: 620px) {
    .feed-stock-grid,
    .feed-status-grid,
    #feed-inventory,
    #thresholds-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .quick-actions,
    .feed-quick-actions,
    .feed-actions,
    .action-buttons.feed-actions {
        grid-template-columns: 1fr;
    }

    .action-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .form-actions {
        flex-direction: column;
    }

    .form-actions button {
        width: 100%;
    }

    .popup-content {
        width: 95%;
        padding: 15px;
    }

    .inventory-header,
    .calculation-header,
    .threshold-info,
    .usage-header {
        flex-wrap: wrap;
    }
}
