/* AgriProject ERP - Responsive Styles */
:root {
    --primary: #198754;
    --primary-dark: #146c43;
    --primary-light: #d1e7dd;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --bg-body: #f4f6f9;
    --sidebar-bg: #1a3a2a;
    --text-muted: #6c757d;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: #212529;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
}

.logo i {
    font-size: 1.5rem;
    color: #75b798;
}
.logo-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
}
.login-logo-img {
    width: 120px;
    height: auto;
    max-width: 80%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
.logo-large {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
}

.btn-close-sidebar {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-link.active {
    border-left: 3px solid #75b798;
    padding-left: calc(1.25rem - 3px);
}

.nav-link i {
    font-size: 1.15rem;
    width: 1.4rem;
    text-align: center;
}

.submenu {
    list-style: none;
    background: rgba(0,0,0,0.2);
    display: none;
}

.submenu a {
    display: block;
    padding: 0.5rem 1.25rem 0.5rem 3.2rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.875rem;
}

.submenu a:hover {
    color: #fff;
}

.has-submenu.open .submenu,
.submenu.open {
    display: block;
}

.nav-section-label {
    list-style: none;
    padding: 0.85rem 1.25rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    margin-top: 0.35rem;
}
.nav-section-label:first-child {
    margin-top: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-meta strong {
    font-size: 0.9rem;
}

.user-meta small {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ========== MAIN WRAPPER ========== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #495057;
    display: none;
}

.topbar-search {
    flex: 1;
    max-width: 400px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.btn-icon {
    background: none;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: #495057;
}

.btn-icon:hover {
    background: #f1f3f5;
}

.btn-icon .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.65rem;
    padding: 0.15em 0.4em;
}

.content-area {
    padding: 1.5rem;
}

/* ========== CARDS & COMPONENTS ========== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: #1a3a2a;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e9ecef;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
    border-bottom-width: 1px;
}

.badge-status {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Farmer simple UI helpers */
.farmer-today-card {
    background: linear-gradient(135deg, #198754 0%, #146c43 100%);
    color: #fff;
    border-radius: 16px;
    padding: 1.5rem;
}

.farmer-today-card h5 {
    opacity: 0.9;
    font-weight: 500;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a3a2a 0%, #198754 50%, #0d3b2a 100%);
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .logo-large {
    font-size: 2.5rem;
    color: var(--primary);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .btn-toggle-sidebar {
        display: flex;
    }
    
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1035;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .content-area {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.4rem;
    }
}

/* Utility */
.bg-primary-soft { background: var(--primary-light); color: var(--primary-dark); }
.bg-info-soft { background: #cff4fc; color: #055160; }
.bg-warning-soft { background: #fff3cd; color: #664d03; }
.bg-danger-soft { background: #f8d7da; color: #842029; }
.bg-secondary-soft { background: #e9ecef; color: #41464b; }

/* Print-friendly */
@media print {
  .sidebar, .topbar, .btn, .page-header .btn, form, .nav, .submenu { display: none !important; }
  .main-content, .content-wrapper { margin: 0 !important; padding: 0 !important; width: 100% !important; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  a { text-decoration: none; color: #000; }
}


/* UX: large task action buttons on mobile */
@media (max-width: 768px) {
  .task-actions .btn {
    flex: 1 1 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }
}
#netChip { font-size: 0.75rem; padding: 0.35em 0.65em; }
.my-work-card { border-left: 4px solid #198754; }
.empty-state { text-align: center; padding: 2.5rem 1rem; }
.empty-state .btn { margin-top: 0.75rem; }

/* ========== ALIGNMENT / UX polish ========== */
.page-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}
.page-header .btn,
.page-header a.btn {
    flex-shrink: 0;
}
.page-header .d-flex.gap-2,
.page-header .d-flex.flex-wrap {
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

/* Action button groups in tables */
td .btn-sm {
    margin: 0.1rem;
    vertical-align: middle;
}
.table td {
    vertical-align: middle;
}
.table thead th {
    white-space: nowrap;
    font-size: 0.85rem;
    color: #495057;
}

/* Topbar dropdowns */
.topbar-actions .dropdown-menu {
    max-height: 70vh;
    overflow-y: auto;
}
.topbar-actions .btn-icon.dropdown-toggle::after {
    display: none;
}

/* Forms consistent */
.card .form-label {
    font-weight: 500;
    font-size: 0.875rem;
}
.card .form-control,
.card .form-select {
    border-radius: 8px;
}

/* KYC profile */
.kyc-badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* Groups supervisor table */
.table select.form-select-sm {
    min-width: 160px;
}

/* Sidebar section labels already styled */
.sidebar-nav {
    scrollbar-width: thin;
}

/* Mobile content */
@media (max-width: 991.98px) {
    .main-wrapper {
        margin-left: 0;
    }
    .btn-toggle-sidebar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .content-area {
        padding: 1rem;
    }
    .page-title {
        font-size: 1.25rem;
    }
    .topbar-actions .btn-icon span.d-none {
        display: none !important;
    }
}

/* Print stays clean */
@media print {
    #offlineBanner, #netChip, #offlineQuick { display: none !important; }
}


.app-footer {
    margin-top: auto;
    font-size: 0.8rem;
}
.app-footer a {
    color: #198754;
    text-decoration: none;
    font-weight: 500;
}
.app-footer a:hover {
    text-decoration: underline;
}
.main-wrapper {
    display: flex;
    flex-direction: column;
}
.content-area {
    flex: 1 0 auto;
}


.topbar-logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
    padding: 1px;
}
.topbar-brand { margin-right: 0.5rem; }

/* ========== UI POLISH 2026 ========== */
html { scroll-behavior: smooth; }

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sidebar scroll */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 4px;
}

.nav-link {
    border-radius: 0 8px 8px 0;
    margin-right: 0.5rem;
}
.nav-link:hover {
    background: rgba(117, 183, 152, 0.15);
}
.nav-link.active {
    background: rgba(117, 183, 152, 0.22);
    color: #fff;
    font-weight: 600;
}
.submenu a {
    border-radius: 6px;
    margin: 0.1rem 0.5rem 0.1rem 0.25rem;
}
.submenu a:hover {
    background: rgba(255,255,255,0.06);
}

/* Cards */
.card {
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #eef1f4;
    font-weight: 600;
    padding: 0.85rem 1.15rem;
}
.card-body { padding: 1.15rem; }

/* Tables */
.table {
    margin-bottom: 0;
}
.table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5c6b7a;
    font-weight: 600;
    border-bottom-width: 1px;
    background: #f8fafb;
    white-space: nowrap;
}
.table-sm td, .table-sm th { padding: 0.55rem 0.75rem; }
.table-hover tbody tr:hover { background: rgba(25, 135, 84, 0.04); }

/* Forms */
.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.35rem;
}
.form-control, .form-select {
    border-radius: 8px;
    border-color: #dce3ea;
    padding: 0.5rem 0.75rem;
}
.form-control:focus, .form-select:focus {
    border-color: #75b798;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.15);
}
.form-control-sm, .form-select-sm {
    border-radius: 6px;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
}
.btn-success {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-success:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-outline-success {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-success:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Page header */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: #1a3a2a;
    margin: 0;
    letter-spacing: -0.02em;
}

/* Stat cards */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.15rem 1.25rem;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: #1a3a2a;
    line-height: 1.2;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
}
.alert-info { background: #e8f5ef; color: #0f5132; }
.alert-success { background: #d1e7dd; color: #0f5132; }

/* Badges */
.badge { font-weight: 500; letter-spacing: 0.01em; }

/* Login polish */
.login-card {
    border: 1px solid rgba(255,255,255,0.15);
}
.login-card h3 {
    color: #1a3a2a;
    font-weight: 700;
}
.login-page .form-control {
    padding: 0.65rem 0.85rem;
}
.login-page .btn-success {
    padding: 0.65rem 1rem;
    font-weight: 600;
    width: 100%;
}

/* Topbar */
.topbar {
    box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.btn-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #495057;
}
.btn-icon:hover {
    background: #f0f3f5;
    color: #1a3a2a;
}

/* Footer */
.app-footer {
    margin-top: auto;
    font-size: 0.8rem;
}
.app-footer a {
    color: var(--primary);
    text-decoration: none;
}
.app-footer a:hover { text-decoration: underline; }

/* Content spacing */
.content-area {
    padding: 1.25rem 1.5rem 2rem;
    min-height: calc(100vh - var(--topbar-height) - 48px);
}

/* Empty states */
.text-muted.text-center.py-3,
.text-muted.text-center.py-4 {
    font-size: 0.9rem;
}

/* Impersonation banner already yellow — ensure readable */
.alert-warning {
    border-left: 4px solid #ffc107;
}

@media (max-width: 991.98px) {
    .topbar-brand span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
