:root {
    --bg-dark: #0d1117;
    --bg-panel: #161b22;
    --bg-glass: rgba(22, 27, 34, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;

    --accent-blue: #1f6feb;
    --accent-green: #3fb950;
    --accent-yellow: #d29922;
    --accent-red: #f85149;
    --accent-purple: #a371f7;

    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5 {
    font-family: 'Outfit', sans-serif;
}

/* --- Layout --- */

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.sidebar .logo {
    padding: 0 2rem 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.sidebar .logo h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav li {
    padding: 1rem 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar nav li a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar nav li:hover a,
.sidebar nav li.active a {
    color: var(--text-primary);
}

.sidebar nav li.active {
    background: linear-gradient(90deg, rgba(31, 111, 235, 0.1) 0%, transparent 100%);
    border-left: 3px solid var(--accent-blue);
}

.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem;
    max-width: 1400px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header-left h1 {
    font-size: 2rem;
    margin-bottom: 0.2rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}


/* --- Cards and Glassmorphism --- */

.card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* --- Drag & Drop Upload Section --- */
.upload-section {
    margin-bottom: 2rem;
}

.upload-header {
    margin-bottom: 1rem;
}

.upload-header h3 {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.upload-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --- Pill toggle groups --- */
.option-label,
.choice-bar-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 0.75rem;
    display: inline-block;
    vertical-align: middle;
}

.pill-group {
    display: inline-flex;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.35);
    padding: 3px;
    border: 1px solid var(--border-color);
}

.pill-group .pill {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 999px;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.pill-group .pill:hover {
    color: var(--text-primary);
}

.pill-group input:checked+.pill,
.pill-group .pill.active {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 0 0 1px rgba(31, 111, 235, 0.4);
}

.pill-group .pill-left {
    border-radius: 999px 0 0 999px;
}

.pill-group .pill-mid {
    border-radius: 0;
}

.pill-group .pill-right {
    border-radius: 0 999px 999px 0;
}

.pill-group-view .pill {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
}

/* Choice bar: editable choices at top of results */
.choice-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.choice-bar-collapsed {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.choice-bar-summary {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.btn-change-choice {
    margin-left: auto;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--accent-blue);
    background: transparent;
    border: 1px solid var(--accent-blue);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.btn-change-choice:hover {
    background: rgba(31, 111, 235, 0.15);
}

.btn-apply-choice {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent-green);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.btn-apply-choice:hover {
    background: #22c55e;
    transform: translateY(-1px);
}

.choice-bar-groups {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.choice-bar-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.85;
    margin-left: auto;
}

/* Already sown: crop selector + soil management */
.already-sown-block {
    margin-bottom: 1.5rem;
}

.already-sown-select.card {
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 5;
}

.already-sown-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.already-sown-label i {
    margin-right: 0.35rem;
    color: var(--accent-green);
}

/* Custom crop dropdown (replaces native select so options always visible) */
.custom-crop-dropdown {
    position: relative;
    width: 100%;
    max-width: 320px;
}

.custom-crop-btn {
    width: 100%;
    text-align: left;
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-crop-btn:hover {
    border-color: var(--accent-blue);
}

.custom-crop-btn::after {
    content: "\25BC";
    font-size: 0.6em;
    opacity: 0.7;
    margin-left: 0.5rem;
}

.custom-crop-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.custom-crop-list.is-open {
    display: block;
}

.custom-crop-option {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.custom-crop-option:hover {
    background: rgba(31, 111, 235, 0.2);
}

.custom-crop-option:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.sown-crop-select {
    width: 100%;
    max-width: 280px;
    min-height: 42px;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.already-sown-block,
.sow-specific-block {
    overflow: visible;
}

.soil-mgmt-card .recommendation-content {
    padding: 1rem 0 0;
}

.readiness-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.readiness-table th,
.readiness-table td {
    padding: 0.5rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.readiness-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.readiness-table .advice-cell {
    color: var(--text-secondary);
    font-size: 0.8rem;
    max-width: 220px;
}

.status-ok {
    color: var(--accent-green);
    font-weight: 500;
}

.status-low {
    color: var(--accent-red);
    font-weight: 500;
}

.status-high {
    color: var(--accent-yellow);
    font-weight: 500;
}

.sow-option .pill-group {
    margin-top: 0.25rem;
}

.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--accent-blue);
    background: rgba(31, 111, 235, 0.05);
}

.upload-area.drag-active {
    border-color: var(--accent-green);
    background: rgba(74, 222, 128, 0.05);
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background-color: #1158c7;
    transform: translateY(-1px);
}

.upload-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
}

.upload-status i {
    color: white;
    /* Make the spinner white */
}


/* --- Alerts --- */

.alerts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.alert-card {
    display: flex;
    gap: 1rem;
    padding: 1.2rem;
    border-radius: 8px;
    align-items: flex-start;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
}

.alert-icon {
    font-size: 1.5rem;
}

.alert-card.critical {
    border-left: 4px solid var(--accent-red);
    background: rgba(248, 81, 73, 0.05);
}

.alert-card.warning {
    border-left: 4px solid var(--accent-yellow);
    background: rgba(210, 153, 34, 0.05);
}

.alert-card.success {
    border-left: 4px solid var(--accent-green);
}

/* --- Toggle Switch --- */

.view-toggle {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--bg-panel);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.toggle-label.active {
    color: var(--text-primary);
    font-weight: 600;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #30363d;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent-blue);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}


/* --- AI Intelligence Cards Grid --- */

.intelligence-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.ai-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-glow {
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle at top right, rgba(31, 111, 235, 0.2), transparent 70%);
    pointer-events: none;
}

.window-card .card-glow {
    background: radial-gradient(circle at top right, rgba(163, 113, 247, 0.2), transparent 70%);
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.ai-header i {
    font-size: 1.2rem;
    background: -webkit-linear-gradient(45deg, #79c0ff, #a371f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.window-card .ai-header i {
    background: -webkit-linear-gradient(45deg, #a371f7, #f85149);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.score-card .ai-header i {
    background: -webkit-linear-gradient(45deg, #3fb950, #d29922);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-header h3 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.highlight-text {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.ai-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: auto;
}

.score-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 4px solid var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
}

/* --- Tiny Metric Trend Cards --- */
.metric-card {
    padding: 1rem;
}

.metric-value-row {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.metric-value-row .value {
    font-size: 1.5rem;
    font-weight: 600;
}

.metric-value-row .trend-icon {
    font-size: 1rem;
}


/* ============================================================
   FOCUS VIEW  (.fv-*)  — Farmer-Friendly UI
   All selectors prefixed .fv- to avoid any Expert View clash.
   ============================================================ */

/* Section wrapper */
.fv-section {
    margin-bottom: 2.5rem;
}

.fv-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.fv-section-icon {
    font-size: 1.5rem;
}

/* ---- Section 1: Status Grid ---- */
.fv-status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.fv-status-card {
    border-radius: 16px;
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    border: 2px solid transparent;
    background-color: var(--bg-panel);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fv-status-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.fv-status-card.fv-good {
    border-color: #3fb950;
    background: rgba(63, 185, 80, 0.07);
}

.fv-status-card.fv-warn {
    border-color: #d29922;
    background: rgba(210, 153, 34, 0.07);
}

.fv-status-card.fv-critical {
    border-color: #f85149;
    background: rgba(248, 81, 73, 0.07);
}

.fv-status-emoji {
    font-size: 3rem;
    line-height: 1;
}

.fv-status-category {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.fv-status-label {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
}

.fv-status-card.fv-good .fv-status-label {
    color: #4ade80;
}

.fv-status-card.fv-warn .fv-status-label {
    color: #fbbf24;
}

.fv-status-card.fv-critical .fv-status-label {
    color: #f87171;
}

.fv-status-sublabel {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ---- Section 2: Action Cards ---- */
.fv-action-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--accent-blue);
    border-radius: 14px;
    padding: 1.75rem 1.75rem 1.5rem;
    margin-bottom: 1.25rem;
    position: relative;
}

.fv-action-card.fv-urgency-immediate {
    border-left-color: #f85149;
}

.fv-action-card.fv-urgency-week {
    border-left-color: #d29922;
}

.fv-action-card.fv-urgency-monitor {
    border-left-color: #3fb950;
}

.fv-action-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.fv-action-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fv-urgency-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 0.2rem;
}

.fv-urgency-badge.immediate {
    background: rgba(248, 81, 73, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.fv-urgency-badge.week {
    background: rgba(210, 153, 34, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.fv-urgency-badge.monitor {
    background: rgba(63, 185, 80, 0.15);
    color: #4ade80;
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.fv-action-rows {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.fv-action-row {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.fv-action-row-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.fv-action-row-text {
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.45;
}

/* All-good card in Section 2 */
.fv-all-good {
    background: rgba(63, 185, 80, 0.06);
    border: 2px solid rgba(63, 185, 80, 0.3);
    border-radius: 14px;
    padding: 2rem 1.75rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.fv-all-good-emoji {
    font-size: 2.5rem;
}

.fv-all-good-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: #4ade80;
    margin-bottom: 0.25rem;
}

.fv-all-good-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ---- Section 3: Reasoning ---- */
.fv-reasoning {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 1.75rem;
}

.fv-reasoning-label {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.fv-bullet-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.fv-bullet-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.fv-bullet-list li::before {
    content: '—';
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-top: 0.05rem;
    opacity: 0.5;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .fv-status-grid {
        grid-template-columns: 1fr 1fr;
    }

    .fv-action-rows {
        grid-template-columns: 1fr;
    }

    .fv-reasoning {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .fv-status-grid {
        grid-template-columns: 1fr;
    }
}