/**
 * KARESA Global AgTech Visual Design System
 * SSOT: brain/Architecture/design-skill.md
 */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Mukta:wght@400;500;600;700;800&family=Noto+Sans+Devanagari:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    /* 1. Global Color Palette */
    --sidebar-bg: #0F3822;              /* Deep Forest Green */
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: rgba(255, 255, 255, 0.10);
    --sidebar-active-border: #4ADE80;  /* Sharp accent green line */
    --sidebar-text: rgba(255, 255, 255, 0.90);
    --sidebar-text-muted: #94A3B8;      /* Muted slate for English sub-labels */

    --bg: #F8FAFB;                      /* Warm soft off-white background */
    --surface: #FFFFFF;                 /* Pure white surface */
    --surface-subtle: #F1F5F9;          /* Slightly tinted sub-box */
    --surface-hover: #F8FAF8;
    --border: #E2E8F0;                  /* Modern crisp border */
    --border-subtle: #EDF2F7;           /* Hairline divider */

    --primary: #166534;                 /* Rich Dark Forest Green */
    --primary-hover: #14532D;
    --primary-light: #F0FDF4;           /* Soft green alert backdrop */
    --primary-border: #BBF7D0;          /* Soft green alert border */
    --accent-lime: #4ADE80;
    --accent-emerald: #10B981;

    --text-main: #0F172A;               /* Deep slate */
    --text-muted: #64748B;              /* Slate-500 */
    --text-light: #94A3B8;              /* Slate-400 */

    --amber: #D97706;
    --amber-bg: #FEF3C7;
    --amber-border: #FDE68A;
    --amber-text: #92400E;

    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;

    --shadow-card: 0 2px 8px -2px rgba(0, 0, 0, 0.05);
    --shadow-btn: 0 4px 10px rgba(22, 101, 52, 0.20);
    --shadow-hover: 0 10px 25px -5px rgba(15, 56, 34, 0.10);

    --sidebar-w: 248px;
    --max-content-w: 1140px;
}

/* Base Reset & English Typography */
*, *::before, *::after {
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* 2. Devanagari Typography Optimization */
:lang(ne), 
.nav-ne, 
[data-i18n], 
h1, h2, h3, h4, h5, h6,
.field-crops-line, 
.field-harvest-line, 
.field-card-title, 
.kpi-label, 
.kpi-value, 
.kpi-unit, 
.alert-banner,
.bilingual-label,
.form-label,
.nav-item .nav-ne,
.page-header h1,
.card-title-group h2,
.stat-label,
.tab-btn span {
    font-family: 'Mukta', 'Noto Sans Devanagari', 'Plus Jakarta Sans', sans-serif !important;
}

:lang(ne), 
.nav-ne, 
[data-i18n], 
.field-crops-line, 
.field-harvest-line, 
.field-card-title, 
.alert-banner,
.form-label,
.section-title,
.table-cell-ne {
    line-height: 1.7 !important;
    font-size: 1.05em;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* 3. Layout Spacing Fixes (Reduced Vertical Layout Gaps) */
.main-content,
.dashboard-content,
.fields-content,
.container {
    padding: 1.5rem !important;
    max-width: var(--max-content-w);
    margin: 0 auto;
    width: 100%;
}

.dash-row-1,
.dash-row-2,
.dash-row-3,
.fields-grid,
.kpi-metrics-grid,
.form-card {
    gap: 1.25rem !important;
    margin-bottom: 1.25rem !important;
}

.page-header,
.action-bar,
.field-hero-card,
.card-header-bar,
.tab-panel-header {
    margin-bottom: 1.25rem !important;
}

/* 4. Sidebar & Brand Logo Integration */
.app-sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg) !important;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
}

.sidebar-brand-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 6px 4px 16px !important;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 16px !important;
}

.sidebar-brand-card img {
    height: 36px;
    width: auto;
    max-width: 170px;
    object-fit: contain;
    filter: brightness(0) invert(1) !important;
    opacity: 0.95;
    transition: opacity 0.2s ease;
}

.sidebar-brand-card:hover img {
    opacity: 1;
}

/* Sidebar Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 600;
    border-left: 4px solid transparent;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: var(--sidebar-hover) !important;
    color: #FFFFFF;
}

.nav-item.active {
    background: var(--sidebar-active-bg) !important;
    border-left: 4px solid var(--sidebar-active-border) !important;
    color: #FFFFFF !important;
    box-shadow: none !important;
}

.nav-item .nav-en {
    font-size: 0.75rem !important;
    color: var(--sidebar-text-muted) !important;
    font-weight: 500;
    line-height: 1.2;
}

.nav-item.active .nav-en {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* 5. Standardized Top Navigation Bar (Single Flex Row, Height 48px Controls) */
.top-bar {
    height: 64px !important;
    padding: 0 1.5rem !important;
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

.top-bar-right,
.top-bar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
}

.top-search-wrap {
    position: relative;
    width: 320px;
    height: 48px;
    display: flex;
    align-items: center;
}

.top-search-wrap input {
    width: 100%;
    height: 42px;
    background: #F1F5F9 !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-full) !important;
    padding: 0 16px 0 40px !important;
    font-size: 13.5px;
    color: var(--text-main);
    outline: none;
    transition: all 0.15s ease;
}

.top-search-wrap input:focus {
    background: #FFFFFF !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12) !important;
}

.top-icon-btn {
    width: 42px !important;
    height: 42px !important;
    border-radius: var(--radius-full) !important;
    background: #F1F5F9 !important;
    border: 1px solid var(--border) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.top-icon-btn:hover {
    background: #E2E8F0 !important;
    color: var(--text-main);
}

.lang-pill-wrap {
    display: inline-flex;
    align-items: center;
    height: 42px;
    background: #F1F5F9 !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-full) !important;
    padding: 2px 4px;
    gap: 2px;
}

.lang-pill-btn {
    background: transparent;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.12s ease;
}

.lang-pill-btn.active {
    background: var(--surface) !important;
    color: var(--primary) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

.top-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    background: #F1F5F9;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 2px 14px 2px 4px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
}

.top-user-chip:hover {
    background: #E2E8F0;
}

/* 6. Primary Buttons (Rich Dark Green #166534 + Soft Elevation) */
.btn-primary,
.btn-action-primary,
.btn-create-field,
.btn-submit,
button[type="submit"].btn-forest {
    background-color: var(--primary) !important;
    color: #FFFFFF !important;
    border: none !important;
    border-radius: var(--radius-sm);
    padding: 0.65rem 1.25rem;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-btn) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover,
.btn-action-primary:hover,
.btn-create-field:hover,
.btn-submit:hover {
    background-color: var(--primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(22, 101, 52, 0.28) !important;
}

/* 7. Stat Cards Across All Pages */
.stat-tile,
.dash-stat-tile,
.kpi-card,
.orchard-stat-tile {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 1rem 1.25rem !important;
    box-shadow: var(--shadow-card) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-tile:hover,
.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06) !important;
}

/* Icon Badges in Soft Circular Backdrops */
.kpi-icon-badge,
.stat-icon-badge {
    width: 38px;
    height: 38px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bg-emerald-50, .badge-emerald {
    background-color: #ECFDF5 !important;
    color: #065F46 !important;
}

.bg-amber-50, .badge-amber {
    background-color: #FEF3C7 !important;
    color: #92400E !important;
}

.bg-lime-50, .badge-lime {
    background-color: #F7FEE7 !important;
    color: #4D7C0F !important;
}

.bg-blue-50, .badge-blue {
    background-color: #EFF6FF !important;
    color: #1D4ED8 !important;
}

/* 8. Field Plot Cards & Canvas Container Styling */
.field-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.field-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.field-map-canvas,
.map-viewport-grid,
.leaflet-container-grid-backdrop {
    background-color: #F1F5F9 !important;
    background-image: radial-gradient(#CBD5E1 1px, transparent 1px) !important;
    background-size: 16px 16px !important;
    position: relative;
    overflow: hidden;
}

/* Card Footer Metrics Clean Inline Badges */
.field-card-footer {
    margin-top: auto;
    padding-top: 12px !important;
    padding-bottom: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-top: 1px solid var(--border-subtle, #EDF2F7) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    background: transparent !important;
}

.field-sub-badges {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
    flex: 1 !important;
    min-width: 0 !important;
}

.field-sub-badge,
.card-metric-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    padding: 3px 8px !important;
    border-radius: 6px !important;
    border: 1px solid #E2E8F0;
    background: #F8FAFC;
    color: #475569;
    flex-shrink: 0 !important;
    transition: background-color 0.15s ease, border-color 0.15s ease !important;
}

.field-sub-badge svg,
.card-metric-badge svg {
    flex-shrink: 0 !important;
}

.field-sub-badge.has-items {
    background: #F0FDF4;
    color: #166534;
    border-color: #BBF7D0;
}

.field-sub-badge.badge-trees.has-items {
    background: #F0FDF4;
    color: #166534;
    border-color: #BBF7D0;
}

.field-sub-badge.badge-infra.has-items,
.field-sub-badge.badge-asset.has-items {
    background: #EFF6FF;
    color: #1D4ED8;
    border-color: #BFDBFE;
}

.field-sub-badge.is-empty,
.field-sub-badge:not(.has-items) {
    background: #F8FAFC;
    color: #94A3B8;
    border-color: #E2E8F0;
}

.field-sub-badge .carbon-icon {
    font-size: 11px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
}

.btn-view-arrow {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: var(--primary, #166534) !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
    padding: 3px 0 !important;
    text-decoration: none !important;
    transition: transform 0.15s ease, color 0.15s ease !important;
}

.field-card:hover .btn-view-arrow {
    color: var(--primary-hover, #14532D) !important;
    transform: translateX(3px) !important;
}

/* 9. Soft Green Farmer Alert Banner */
.alert-banner,
.alert-success-soft {
    background: #F0FDF4 !important;
    border: 1px solid #BBF7D0 !important;
    color: #166534 !important;
    border-radius: 12px !important;
    padding: 14px 18px !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
