/* app/assets/stylesheets/harvest_report.css */

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --primary-green: #10b981;
    --dark-green: #047857;
    --light-green-bg: #d1fae5;
    --text-dark: #1f2937;
    --text-gray: #6b7280;
    --bg-color: #f3f4f6;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --border-color: #e5e7eb;
}

body {
    background-color: var(--bg-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-dark);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.report-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* =========================================
   2. HEADER
   ========================================= */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 20px;
    flex-wrap: wrap;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Back Button */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-gray);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}
.btn-back:hover { color: var(--primary-green); }

/* Title */
.title-group h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #111827;
}

.count-badge {
    background-color: #e5e7eb;
    color: var(--text-gray);
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 99px;
    vertical-align: middle;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* =========================================
   3. BUTTONS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.2;
}

.btn-white {
    background: white;
    border-color: var(--border-color);
    color: var(--text-dark);
}
.btn-white:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-dark {
    background: #064e3b; /* Deep Green */
    color: white;
}
.btn-dark:hover {
    background: #065f46;
}

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

.btn-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-gray);
    padding: 0 16px;
    border-radius: 8px;
    height: 42px; /* Matches input height */
    text-decoration: none;
    font-size: 0.9rem;
}
.btn-reset:hover { background: #f9fafb; }

/* =========================================
   4. SUMMARY CARDS
   ========================================= */
.summary-cards {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap; /* Allows wrapping on tablet */
}

.card-stat {
    flex: 1;
    min-width: 240px; /* Prevents card from getting too thin */
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid transparent;
}

.card-stat.highlight {
    border-color: var(--primary-green);
    background-color: #ecfdf5;
}

.icon-box {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.icon-box.green { background: var(--light-green-bg); color: var(--dark-green); }
.icon-box.blue { background: #dbeafe; color: #1e40af; }

.stat-content h3 {
    margin: 0 0 6px 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-gray);
    letter-spacing: 0.05em;
    font-weight: 600;
}
.stat-content p {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* =========================================
   5. ANALYSIS CHARTS
   ========================================= */
.charts-container {
    display: flex;
    gap: 24px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.chart-card {
    flex: 1;
    min-width: 300px; /* Stacks vertically if screen < 600px */
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: #f9fafb;
}
.chart-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
}

.chart-body {
    padding: 20px;
    height: 280px;
    position: relative;
    background: white;
}

/* =========================================
   6. FILTER FORM
   ========================================= */
.filter-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.filter-form {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 180px; /* Wraps items nicely */
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-gray);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    box-sizing: border-box;
    color: #374151;
    height: 42px;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* =========================================
   7. TABLE
   ========================================= */
.table-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Responsive Wrapper for Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px; /* Forces scroll on small screens */
}

.custom-table th {
    background: #f9fafb;
    text-align: left;
    padding: 16px 24px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-gray);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.custom-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.land-info { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--primary-green); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.9rem; flex-shrink: 0;
}
.avatar.orange { background: #f97316; }
.avatar.blue { background: #3b82f6; }

.info-text h4 { margin: 0; font-size: 0.95rem; color: #111827; }
.info-text p { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-gray); }

.date-text { display: flex; align-items: center; gap: 8px; color: #374151; font-weight: 500;}
.amount-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; color: #111827; }

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}
.status-badge.completed { background: var(--light-green-bg); color: var(--dark-green); }

/* =========================================
   8. PAGINATION FOOTER
   ========================================= */
.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: white;
    flex-wrap: wrap;
    gap: 16px;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-gray);
    font-weight: 500;
}

.pagination-links nav { display: flex; gap: 6px; align-items: center; }

.pagination-links span, .pagination-links a {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    font-size: 0.9rem; font-weight: 500; border-radius: 6px;
    text-decoration: none; box-sizing: border-box; transition: all 0.2s;
}

.pagination-links a, .pagination-links span.gap {
    background-color: white; border: 1px solid #e5e7eb; color: #374151;
}
.pagination-links a:hover { background-color: #f9fafb; border-color: #d1d5db; }
.pagination-links span.current {
    background-color: var(--primary-green); color: white; border: 1px solid var(--primary-green);
}
.pagination-links span.disabled { opacity: 0.5; cursor: not-allowed; border-color: #e5e7eb; }


/* =========================================
   9. MOBILE RESPONSIVENESS (The Magic)
   ========================================= */

/* Tablets and Mobile (< 768px) */
@media (max-width: 768px) {
    .report-container { padding: 16px; }

    /* Header: Stack title and actions */
    .report-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between; /* Buttons span full width */
    }
    .header-actions .btn {
        flex: 1; /* Buttons grow to fill space */
    }

    /* Filters: Stack vertically */
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-group:last-child {
        flex-direction: row; /* Keep Filter/Reset buttons side-by-side */
        margin-top: 10px;
    }
    .filter-group .btn { flex: 1; }

    /* Pagination: Center on mobile */
    .pagination-footer {
        justify-content: center;
        flex-direction: column;
    }
}

/* Very Small Screens (< 480px) */
@media (max-width: 480px) {
    /* Summary cards stack 1 per row */
    .card-stat { min-width: 100%; }
}