/* Health 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;
}

.health-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;
}

.health-container > * {
    box-sizing: border-box;
}

.health-container .content-container {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    background: transparent;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
}

.health-page-hero,
.quick-actions,
.health-actions,
.health-workspace,
.health-activity-grid,
.health-management-actions {
    width: 100%;
}

.app-page-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.health-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);
}

.health-page-hero__brand {
    display: flex;
    align-items: center;
    justify-content: center;
}

.health-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;
}

.health-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;
}

.health-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,
.health-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,
.health-quick-actions .action-button {
    min-height: 52px;
    font-size: 1rem;
}

.health-actions,
.action-buttons.health-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 1rem;
    background: var(--fm-surface);
    border: 1px solid var(--fm-border);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 10px 24px rgba(31, 37, 32, 0.06);
}

.health-workspace {
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
}

.stat-card,
.health-card,
.health-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;
}

.health-activity-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
    gap: 1.5rem;
    align-items: start;
}

.health-activity-grid .stat-card {
    margin-bottom: 0;
    padding: 1.35rem;
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.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,
.btn-info {
    background: var(--fm-surface);
    color: var(--fm-green-dark);
    border-color: var(--fm-border);
}

.btn-secondary:hover,
.btn-info: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);
}

.health-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;
}

.health-management-actions::before,
.management-actions::before {
    content: none !important;
}

.health-management-actions .action-button {
    min-height: 48px;
}

/* Record items */
.record-item,
.health-record,
.health-item,
.treatment-item,
.vaccination-item,
.medication-item {
    background: var(--fm-surface-soft);
    border: 1px solid var(--fm-border);
    border-radius: 16px;
    padding: 1rem 1.1rem;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.record-item.health-record,
.record-item.health {
    border-left: 4px solid var(--fm-green-dark);
}

.record-item.vaccination {
    border-left: 4px solid var(--fm-green);
}

.record-item.treatment {
    border-left: 4px solid var(--fm-amber);
}

.record-item.medication {
    border-left: 4px solid var(--fm-green);
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.record-category,
.record-title,
.health-category {
    color: var(--fm-green-dark);
    font-weight: 850;
}

.record-date,
.end-date,
.due-date {
    color: var(--fm-muted);
    font-size: 0.85rem;
}

.record-details,
.health-details,
.description,
.dosage {
    color: var(--fm-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.record-next-date {
    margin-top: 0.5rem;
    font-weight: 800;
    color: #7a5200;
}

.empty-state {
    text-align: center;
    color: var(--fm-muted);
    padding: 1rem 0;
    margin: 0;
}

.severity-badge,
.status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 800;
    background: var(--fm-green-soft);
    color: var(--fm-green-dark);
    border: 1px solid rgba(47, 107, 47, 0.22);
}

.severity-mild,
.status-good {
    color: var(--fm-green);
}

.severity-moderate,
.status-warning {
    color: #7a5200;
}

.severity-severe,
.status-danger {
    color: var(--fm-alert);
}

/* 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;
    margin-bottom: 15px;
    color: var(--fm-green-dark);
    font-weight: 850;
    text-align: center;
    text-shadow: none;
    text-transform: none;
}

.popup-content h3::after {
    display: none;
}

.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;
}

.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);
}

/* Brand overrides – beat legacy main.css rules on this page */
.health-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;
}

.health-container .action-button:before {
    display: none;
}

.health-container .action-button:active {
    transform: none;
    box-shadow: none;
    border-bottom: none;
}

.health-container .button-row .action-button {
    width: auto;
}

.health-container .stat-card h3 {
    background: transparent;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
    padding: 0;
}

/* Responsive layout */
@media (max-width: 1100px) {
    .health-actions,
    .action-buttons.health-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .health-activity-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .health-page-hero {
        grid-template-columns: 1fr;
        gap: 1.1rem;
        padding: 1.35rem 1.25rem;
        text-align: center;
    }

    .health-page-hero__copy {
        text-align: center;
        align-items: center;
    }

    .health-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) {
    .health-container {
        width: min(calc(100% - 1rem), 100%);
        padding-top: 0.9rem;
        padding-bottom: 7.75rem;
    }
}

@media (max-width: 560px) {
    .quick-actions,
    .health-quick-actions,
    .health-actions,
    .action-buttons.health-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;
    }

    .record-header {
        flex-wrap: wrap;
    }

    .record-header .record-date {
        width: 100%;
        margin-top: 4px;
    }
}

@media (orientation: landscape) {
    .popup-content {
        width: 80%;
        max-height: 80vh;
    }

    .popup-content form {
        overflow-y: auto;
        max-height: calc(80vh - 80px);
    }

    .form-actions {
        position: sticky;
        bottom: 0;
        background-color: var(--fm-surface);
        padding-top: 10px;
        margin-top: 10px;
        border-top: 1px solid var(--fm-border);
    }
}
