/* ==================================================================
   style.css — Leafscape CSR Platform
   Clean, modern, card-based UI. Mobile view mimics a native app
   (bottom tab bar, rounded cards, soft shadows, no bulky borders).
   ================================================================== */

:root {
    --primary: #549c1f;
    --primary-dark: #3f7817;
    --secondary: #a94a10;
    --bg: #ffffff;
    --surface: #f6f8f5;
    --text-main: #1f2a1a;
    --text-muted: #7c8a76;
    --radius-lg: 20px;
    --radius-md: 14px;
    --shadow-soft: 0 8px 24px rgba(30, 40, 20, 0.06);
}

* { box-sizing: border-box; }

body {
    font-family: 'League Spartan', sans-serif;
    background-color: var(--surface);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-family: 'League Spartan', sans-serif; font-weight: 700; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------ */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}
.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}
.btn-secondary:hover { background-color: #8a3c0d; border-color: #8a3c0d; color: #fff; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background-color: var(--primary); border-color: var(--primary); }

.text-primary-brand { color: var(--primary) !important; }
.text-secondary-brand { color: var(--secondary) !important; }
.bg-primary-brand { background-color: var(--primary) !important; }
.bg-secondary-brand { background-color: var(--secondary) !important; }

/* ------------------------------------------------------------------
   App Shell Layout (sidebar + main)
   ------------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 250px;
    background: #fff;
    border-right: 1px solid #eef1ec;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-sidebar .brand-logo { height: 36px; margin-bottom: 28px; }

.app-sidebar .nav-link {
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-sidebar .nav-link i { width: 20px; text-align: center; }
.app-sidebar .nav-link.active,
.app-sidebar .nav-link:hover {
    background-color: rgba(84, 156, 31, 0.1);
    color: var(--primary);
}

.app-main { flex: 1; min-width: 0; padding: 24px; padding-bottom: 90px; }

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

/* ------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------ */
.card-app {
    background: #fff;
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 20px;
}

.stat-card {
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}
.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    color: #fff;
    background: var(--primary);
    margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 26px; font-weight: 700; }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; }

.table-card { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-soft); background: #fff; }
.table-card table { margin-bottom: 0; }
.table-card thead th { border-bottom: 1px solid #eef1ec; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.table-card td, .table-card th { vertical-align: middle; padding: 14px 16px; }

/* ------------------------------------------------------------------
   Login page
   ------------------------------------------------------------------ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #eef6e6 0%, #ffffff 60%);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 36px 30px;
}
.auth-card .brand-logo { height: 42px; margin-bottom: 18px; }

/* ------------------------------------------------------------------
   Mobile Bottom Nav — mimics a native mobile app tab bar
   ------------------------------------------------------------------ */
.mobile-tabbar {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #eef1ec;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    z-index: 1030;
    box-shadow: 0 -6px 20px rgba(30,40,20,0.06);
}
.mobile-tabbar .tab-item {
    flex: 1;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 0;
}
.mobile-tabbar .tab-item i { display: block; font-size: 18px; margin-bottom: 2px; }
.mobile-tabbar .tab-item.active { color: var(--primary); }

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
    border-bottom: 1px solid #eef1ec;
}
.mobile-topbar .brand-logo { height: 28px; }

@media (max-width: 767.98px) {
    /* Stack the mobile top bar above the main content — the shell is a
       row on desktop, so without this the w-100 top bar squeezes
       .app-main to zero width. */
    .app-shell { flex-direction: column; }
    .app-sidebar { display: none; }
    .mobile-tabbar { display: flex; }
    .mobile-topbar { display: flex; }
    .app-main { padding: 16px; padding-bottom: 96px; }
    .app-topbar { display: none; }
    .card-app, .stat-card { border-radius: 18px; }
    .stat-card { padding: 14px 16px; }
    .stat-card .stat-value { font-size: 20px; overflow-wrap: anywhere; }
    .stat-card .stat-icon { width: 38px; height: 38px; font-size: 16px; }
    /* Card headers with actions should wrap instead of overflowing. */
    .table-card .p-3.d-flex, .card-app.d-flex { flex-wrap: wrap; gap: 8px; }
}

/* ------------------------------------------------------------------
   Filter bars — selects/inputs share a row on desktop and wrap to
   full-width rows on small screens.
   ------------------------------------------------------------------ */
.filter-bar .form-select,
.filter-bar .form-control {
    width: auto;
    flex: 1 1 160px;
    min-width: 0;
}
.filter-bar .btn { flex: 0 0 auto; }

/* ------------------------------------------------------------------
   Mobile "More" nav sheet (offcanvas bottom)
   ------------------------------------------------------------------ */
.mobile-nav-sheet { height: auto !important; max-height: 75vh; border-radius: 20px 20px 0 0; }
.mobile-nav-sheet .nav-link {
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
}
.mobile-nav-sheet .nav-link i { width: 20px; text-align: center; }
.mobile-nav-sheet .nav-link.active,
.mobile-nav-sheet .nav-link:hover {
    background-color: rgba(84, 156, 31, 0.1);
    color: var(--primary);
}

/* ------------------------------------------------------------------
   AI-generated report rendering (report_master.php)
   ------------------------------------------------------------------ */
.report-rendered { font-size: 14px; line-height: 1.6; }
.report-rendered h1 { font-size: 22px; }
.report-rendered h2 { font-size: 18px; margin-top: 24px; }
.report-rendered h3 { font-size: 15px; margin-top: 18px; }
.report-rendered table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.report-rendered th, .report-rendered td { border: 1px solid #e2e6de; padding: 7px 10px; text-align: left; }
.report-rendered th { background: #f1f4ee; font-weight: 700; }
.report-rendered hr { border-color: #e2e6de; margin: 20px 0; }
.report-rendered blockquote { border-left: 3px solid var(--primary); padding-left: 12px; color: var(--text-muted); }

/* ------------------------------------------------------------------
   Misc
   ------------------------------------------------------------------ */
.badge { font-weight: 600; font-size: 11px; padding: 6px 10px; }
.kanban-column { background: #f1f4ee; border-radius: var(--radius-lg); padding: 12px; min-height: 300px; }
.kanban-card { background: #fff; border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-soft); cursor: grab; }
.kanban-card.dragging { opacity: 0.5; }

.form-control, .form-select {
    border-radius: var(--radius-md);
    border-color: #e3e8de;
    padding: 10px 14px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(84, 156, 31, 0.15);
}
label.form-label { font-weight: 600; font-size: 13px; color: var(--text-main); }
