/* Coffee Farm Management System - application styles */
:root {
    --coffee-900: #2b1a12;
    --coffee-800: #3b2418;
    --coffee-700: #4e3122;
    --coffee-600: #6b4430;
    --coffee-400: #a07a63;
    --coffee-100: #efe6dd;
    --cream: #f7f3ee;
    --green: #5f7f52;
    --green-soft: #e6eedf;
    --amber: #b7862b;
    --amber-soft: #f8eed8;
    --red: #a8473a;
    --red-soft: #f6e2de;
    --text: #2f2723;
    --muted: #7a6d65;
    --border: #e7ddd3;
    --sidebar-width: 250px;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(43, 26, 18, .05), 0 4px 14px rgba(43, 26, 18, .06);

    --bs-primary: var(--coffee-700);
    --bs-primary-rgb: 78, 49, 34;
    --bs-success: var(--green);
    --bs-success-rgb: 95, 127, 82;
    --bs-body-color: var(--text);
    --bs-body-bg: var(--cream);
    --bs-border-color: var(--border);
    --bs-link-color: var(--coffee-600);
    --bs-link-color-rgb: 107, 68, 48;
    --bs-link-hover-color: var(--coffee-900);
}

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--cream);
    color: var(--text);
    font-size: .925rem;
}

a { text-decoration: none; }

/* ---------- Buttons ---------- */
.btn-primary {
    --bs-btn-bg: var(--coffee-700);
    --bs-btn-border-color: var(--coffee-700);
    --bs-btn-hover-bg: var(--coffee-800);
    --bs-btn-hover-border-color: var(--coffee-800);
    --bs-btn-active-bg: var(--coffee-900);
    --bs-btn-active-border-color: var(--coffee-900);
    --bs-btn-disabled-bg: var(--coffee-400);
    --bs-btn-disabled-border-color: var(--coffee-400);
}
.btn-outline-primary {
    --bs-btn-color: var(--coffee-700);
    --bs-btn-border-color: var(--coffee-400);
    --bs-btn-hover-bg: var(--coffee-700);
    --bs-btn-hover-border-color: var(--coffee-700);
    --bs-btn-active-bg: var(--coffee-800);
}
.btn-success {
    --bs-btn-bg: var(--green);
    --bs-btn-border-color: var(--green);
    --bs-btn-hover-bg: #4d6a42;
    --bs-btn-hover-border-color: #4d6a42;
}
.btn { border-radius: 8px; }
.text-primary { color: var(--coffee-700) !important; }
.text-success { color: var(--green) !important; }
.bg-primary { background-color: var(--coffee-700) !important; }

/* ---------- Layout ---------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--coffee-900);
    color: #e8dcd1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .2s ease, width .2s ease;
}
.app-sidebar .brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.1rem 1.25rem;
    color: #fff;
    font-weight: 600;
    line-height: 1.15;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.app-sidebar .brand-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--coffee-600);
    display: grid; place-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.app-sidebar .brand small { display: block; font-weight: 400; color: #bba796; font-size: .72rem; }
.app-sidebar nav { overflow-y: auto; padding: .75rem .65rem 1.5rem; flex: 1; }
.app-sidebar .nav-section {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    color: #9c8676; padding: .9rem .75rem .35rem;
}
.app-sidebar .nav-link {
    display: flex; align-items: center; gap: .7rem;
    color: #e0d2c6;
    padding: .55rem .75rem;
    border-radius: 8px;
    margin-bottom: 2px;
    white-space: nowrap;
}
.app-sidebar .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; }
.app-sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.app-sidebar .nav-link.active { background: var(--coffee-600); color: #fff; }

.app-main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin .2s ease; }

.app-topbar {
    height: 62px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 1030;
}
.app-topbar .sidebar-toggle { border: 0; background: transparent; font-size: 1.4rem; color: var(--coffee-700); padding: .25rem .4rem; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--coffee-100); color: var(--coffee-700);
    display: grid; place-items: center; font-weight: 600; font-size: .85rem;
}
.app-content { padding: 1.5rem; flex: 1; }
.app-footer { padding: 1rem 1.5rem; color: var(--muted); font-size: .8rem; }

/* Collapsed sidebar on desktop */
body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .app-main { margin-left: 0; }

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0; }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 1035;
    }
    .app-content { padding: 1rem; }
    .app-topbar { padding: 0 1rem; }
}

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.45rem; font-weight: 650; margin: 0; color: var(--coffee-900); }
.breadcrumb { margin-bottom: .3rem; font-size: .8rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb-item.active { color: var(--coffee-600); }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    --bs-card-cap-bg: #fff;
}
.card-header { background: #fff; border-bottom: 1px solid var(--border); padding: .9rem 1.15rem; font-weight: 600; }
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-body { padding: 1.15rem; }

.stat-card { height: 100%; }
.stat-card .card-body { display: flex; align-items: center; gap: 1rem; }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0;
    background: var(--coffee-100); color: var(--coffee-700);
}
.stat-card .stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-card .stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-card .stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-card .stat-label { color: var(--muted); font-size: .8rem; margin-bottom: .15rem; }
.stat-card .stat-value { font-size: 1.3rem; font-weight: 650; color: var(--coffee-900); line-height: 1.2; word-break: break-word; }

.price-hero {
    background: var(--coffee-800);
    color: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
}
.price-hero .amount { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.price-hero .label { color: #d9c7b8; font-size: .85rem; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th {
    background: #faf6f2;
    color: var(--muted);
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    padding: .7rem .85rem;
}
.table > tbody td { padding: .7rem .85rem; vertical-align: middle; border-color: #f0e9e2; }
.table > tfoot td, .table > tfoot th { padding: .7rem .85rem; background: #faf6f2; font-weight: 600; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #fbf8f5; }
.card .table-responsive:last-child .table { border-radius: 0 0 var(--radius) var(--radius); }
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; border-radius: 6px; padding: .35em .6em; }
.badge-soft-success { background: var(--green-soft); color: #3f5a35; }
.badge-soft-danger { background: var(--red-soft); color: var(--red); }
.badge-soft-warning { background: var(--amber-soft); color: #8a6219; }
.badge-soft-secondary { background: #eee9e4; color: var(--muted); }
.badge-soft-primary { background: var(--coffee-100); color: var(--coffee-700); }

/* ---------- Forms ---------- */
.form-label { font-weight: 550; font-size: .85rem; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: 8px; border-color: #ddd1c5; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--coffee-400);
    box-shadow: 0 0 0 .2rem rgba(107, 68, 48, .15);
}
.form-check-input:checked { background-color: var(--coffee-700); border-color: var(--coffee-700); }
.required::after { content: " *"; color: var(--red); }
.filter-bar { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }

/* ---------- Detail lists ---------- */
.detail-list { margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 500; font-size: .8rem; }
.detail-list dd { margin-bottom: .75rem; font-weight: 500; }

.summary-tile { background: #faf6f2; border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; height: 100%; }
.summary-tile .label { font-size: .75rem; color: var(--muted); }
.summary-tile .value { font-size: 1.1rem; font-weight: 650; color: var(--coffee-900); }
.summary-tile.highlight { background: var(--coffee-800); border-color: var(--coffee-800); }
.summary-tile.highlight .label { color: #d9c7b8; }
.summary-tile.highlight .value { color: #fff; }

/* ---------- Alerts ---------- */
.alert { border-radius: 10px; border: 0; }
.alert-success { background: var(--green-soft); color: #3f5a35; }
.alert-danger { background: var(--red-soft); color: #7e2f25; }
.alert-warning { background: var(--amber-soft); color: #7a5512; }
.alert-info { background: var(--coffee-100); color: var(--coffee-800); }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside {
    background: var(--coffee-900);
    color: #f1e6dc;
    padding: 3rem;
    display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside h2 { font-weight: 700; color: #fff; }
.auth-aside .feature { display: flex; gap: .75rem; margin-bottom: 1rem; color: #d9c7b8; }
.auth-aside .feature i { color: #c9a98f; font-size: 1.2rem; }
.auth-form-wrap { display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 410px; }
@media (max-width: 767.98px) {
    .auth-page { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

/* ---------- Misc ---------- */
.chart-box { position: relative; height: 260px; }
.permission-group { border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; height: 100%; background: #fff; }
.permission-group h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.amount-positive { color: var(--green); }
.amount-negative { color: var(--red); }
.nowrap { white-space: nowrap; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

@media print {
    .app-sidebar, .app-topbar, .no-print, .app-footer { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .card { box-shadow: none; }
    body { background: #fff; }
}

/* ---------- Report tables (shared by screen and print views) ---------- */
.table .num, .num { text-align: right; }
.table .muted, .muted { color: var(--muted); }
.table tr.total > td { font-weight: 600; background: #faf6f2; }
.report-card { transition: border-color .15s ease; }
.report-card:hover { border-color: var(--coffee-400); }
.report-card .report-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--coffee-100); color: var(--coffee-700); font-size: 1.25rem; }
table.summary { width: calc(100% + 16px); border-collapse: separate; border-spacing: 8px; margin: -8px -8px 8px; table-layout: fixed; }
table.summary td { background: #faf6f2; border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem; vertical-align: top; }
table.summary .label { display: block; font-size: .75rem; color: var(--muted); }
table.summary .value { display: block; font-weight: 650; font-size: 1.05rem; color: var(--coffee-900); }
table.summary td.highlight { background: var(--coffee-800); border-color: var(--coffee-800); }
table.summary td.highlight .label { color: #d9c7b8; }
table.summary td.highlight .value { color: #fff; }
.card-body h3 { font-size: 1rem; font-weight: 600; color: var(--coffee-700); margin: 1.25rem 0 .5rem; }
@media (max-width: 767.98px) { table.summary, table.summary tbody, table.summary tr, table.summary td { display: block; width: 100%; margin: 0 0 8px; } }
