/* ==========================================================================
   Poultry Farm Management System -- shared theme
   ========================================================================== */

:root {
    --pf-brand-900: #0f2e1d;
    --pf-brand-800: #163d27;
    --pf-brand-700: #1b4d32;
    --pf-brand-600: #23643f;
    --pf-brand-500: #2d7a4d;
    --pf-brand-400: #3f9563;
    --pf-accent: #e0a94a;
    --pf-accent-dark: #c8912f;
    --pf-bg: #f4f6f5;
    --pf-surface: #ffffff;
    --pf-border: #e4e8e6;
    --pf-text-muted: #6c7873;
    --pf-sidebar-width: 260px;
    --pf-topbar-height: 56px;

    /* Fixed status palette -- never themed, used for alert/threshold states */
    --pf-status-good: #0ca30c;
    --pf-status-warning: #fab219;
    --pf-status-serious: #ec835a;
    --pf-status-critical: #d03b3b;
    --pf-delta-up-good: #006300;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--pf-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #26312c;
}

a {
    color: var(--pf-brand-600);
}
a:hover {
    color: var(--pf-brand-700);
}

/* ---------------------------------------------------------------------
   Buttons, links, focus states -- brand color instead of Bootstrap blue
   --------------------------------------------------------------------- */
.btn-primary {
    background-color: var(--pf-brand-600);
    border-color: var(--pf-brand-600);
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--pf-brand-700);
    border-color: var(--pf-brand-700);
}
.btn-primary:active {
    background-color: var(--pf-brand-800) !important;
    border-color: var(--pf-brand-800) !important;
}
.btn-outline-primary {
    color: var(--pf-brand-600);
    border-color: var(--pf-brand-600);
}
.btn-outline-primary:hover {
    background-color: var(--pf-brand-600);
    border-color: var(--pf-brand-600);
}
.btn-check:checked + .btn-outline-primary,
.btn-outline-primary:active {
    background-color: var(--pf-brand-700) !important;
    border-color: var(--pf-brand-700) !important;
}
.text-primary { color: var(--pf-brand-600) !important; }
.border-primary { border-color: var(--pf-brand-600) !important; }
.form-control:focus,
.form-select:focus {
    border-color: var(--pf-brand-400);
    box-shadow: 0 0 0 0.2rem rgba(45, 122, 77, 0.15);
}
.form-check-input:checked {
    background-color: var(--pf-brand-600);
    border-color: var(--pf-brand-600);
}

/* ---------------------------------------------------------------------
   Layout shell: fixed sidebar + top bar + content
   --------------------------------------------------------------------- */
.pf-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--pf-sidebar-width);
    background: linear-gradient(180deg, var(--pf-brand-800) 0%, var(--pf-brand-900) 100%);
    color: #dcefe3;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.2s ease;
}

.pf-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.1rem 1.25rem;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.pf-sidebar-brand .pf-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 0.6rem;
    background: var(--pf-accent);
    color: var(--pf-brand-900);
    font-size: 1.05rem;
}
.pf-sidebar-brand:hover {
    color: #fff;
}

.pf-sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.75rem 0.6rem;
}
.pf-sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.pf-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.pf-nav-section {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(220, 239, 227, 0.45);
    padding: 0.9rem 0.75rem 0.3rem;
}

.pf-nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.5rem;
    color: rgba(220, 239, 227, 0.85);
    text-decoration: none;
    font-size: 0.92rem;
    margin-bottom: 0.15rem;
}
.pf-nav-link i {
    font-size: 1.05rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}
.pf-nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.pf-nav-link.active {
    background: var(--pf-brand-600);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--pf-accent);
}

.pf-nav-group > .pf-nav-link::after {
    content: "\F282"; /* bi-chevron-down */
    font-family: "bootstrap-icons";
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}
.pf-nav-group.open > .pf-nav-link::after {
    transform: rotate(180deg);
}
.pf-nav-submenu {
    display: none;
    padding-left: 1.9rem;
}
.pf-nav-group.open .pf-nav-submenu {
    display: block;
}
.pf-nav-submenu .pf-nav-link {
    font-size: 0.86rem;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.pf-sidebar-footer {
    padding: 0.85rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.pf-user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}
.pf-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--pf-brand-600);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.pf-user-meta {
    line-height: 1.2;
    overflow: hidden;
}
.pf-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pf-user-role {
    font-size: 0.72rem;
    color: rgba(220, 239, 227, 0.6);
}

.pf-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--pf-topbar-height);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    background: var(--pf-surface);
    border-bottom: 1px solid var(--pf-border);
}
.pf-topbar-toggle {
    display: none;
    border: none;
    background: transparent;
    font-size: 1.3rem;
    color: var(--pf-brand-700);
    padding: 0.25rem 0.4rem;
}
.pf-topbar-title {
    font-weight: 600;
    color: #26312c;
    font-size: 1rem;
}

.pf-content-wrap {
    margin-left: var(--pf-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.pf-content {
    padding: 1.5rem;
    flex: 1 1 auto;
}

.pf-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 46, 29, 0.35);
    z-index: 1035;
}

@media (max-width: 991.98px) {
    .pf-sidebar {
        transform: translateX(-100%);
    }
    body.pf-sidebar-open .pf-sidebar {
        transform: translateX(0);
    }
    body.pf-sidebar-open .pf-sidebar-backdrop {
        display: block;
    }
    .pf-content-wrap {
        margin-left: 0;
    }
    .pf-topbar-toggle {
        display: inline-flex;
        align-items: center;
    }
}

/* ---------------------------------------------------------------------
   Card & table polish
   --------------------------------------------------------------------- */
.card {
    border: 1px solid var(--pf-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 46, 29, 0.04);
}
.card-header {
    background-color: #fafbfa;
    font-weight: 600;
    border-bottom: 1px solid var(--pf-border);
    border-top-left-radius: 0.75rem !important;
    border-top-right-radius: 0.75rem !important;
}
.table thead th {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--pf-text-muted);
    font-weight: 700;
    border-bottom-width: 1px;
}
.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}
.dropdown-menu {
    border-radius: 0.6rem;
    border: 1px solid var(--pf-border);
    box-shadow: 0 8px 24px rgba(15, 46, 29, 0.1);
}

/* ---------------------------------------------------------------------
   Dashboard: greeting header, stat tiles, quick actions
   --------------------------------------------------------------------- */
.pf-dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.pf-dash-greeting {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1c261f;
    margin-bottom: 0.15rem;
}
.pf-dash-subtitle {
    color: var(--pf-text-muted);
    font-size: 0.9rem;
}
.pf-dash-date {
    text-align: right;
    color: var(--pf-text-muted);
    font-size: 0.85rem;
}
.pf-dash-date strong {
    display: block;
    color: #1c261f;
    font-size: 0.95rem;
}

.pf-stat-tile {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1.1rem 1.15rem;
    height: 100%;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}
.pf-stat-tile:hover {
    box-shadow: 0 4px 16px rgba(15, 46, 29, 0.1);
    transform: translateY(-1px);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    color: inherit;
}
.pf-stat-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 0.65rem;
    background: rgba(45, 122, 77, 0.1);
    color: var(--pf-brand-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.pf-stat-tile.status-warning .pf-stat-icon {
    background: rgba(250, 178, 25, 0.16);
    color: #96690a;
}
.pf-stat-tile.status-serious .pf-stat-icon {
    background: rgba(236, 131, 90, 0.16);
    color: #b8471e;
}
.pf-stat-tile.status-critical .pf-stat-icon {
    background: rgba(208, 59, 59, 0.14);
    color: var(--pf-status-critical);
}
.pf-stat-body {
    flex: 1 1 auto;
    min-width: 0;
}
.pf-stat-label {
    font-size: 0.8rem;
    color: var(--pf-text-muted);
    margin-bottom: 0.15rem;
}
.pf-stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    color: #1c261f;
    line-height: 1.15;
}
.pf-stat-sub {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--pf-text-muted);
    margin-top: 0.3rem;
}
.pf-stat-delta {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-weight: 600;
    font-size: 0.76rem;
}
.pf-stat-delta.up-good { color: var(--pf-delta-up-good); }
.pf-stat-delta.up-bad { color: var(--pf-status-critical); }
.pf-stat-delta.down-good { color: var(--pf-delta-up-good); }
.pf-stat-delta.down-bad { color: var(--pf-status-critical); }
.pf-stat-delta.neutral { color: var(--pf-text-muted); }

.pf-stat-status-dot {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    width: 9px;
    height: 9px;
    border-radius: 50%;
}
.pf-stat-status-dot.good { background: var(--pf-status-good); }
.pf-stat-status-dot.warning { background: var(--pf-status-warning); }
.pf-stat-status-dot.serious { background: var(--pf-status-serious); }
.pf-stat-status-dot.critical { background: var(--pf-status-critical); }

.pf-sparkline {
    position: absolute;
    right: 0.9rem;
    bottom: 0.85rem;
    opacity: 0.9;
}

.pf-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.pf-quick-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.95rem;
    border-radius: 0.6rem;
    background: var(--pf-surface);
    border: 1px solid var(--pf-border);
    color: #1c261f;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}
.pf-quick-action i {
    color: var(--pf-brand-600);
    font-size: 1rem;
}
.pf-quick-action:hover {
    border-color: var(--pf-brand-400);
    background: rgba(45, 122, 77, 0.06);
    color: #1c261f;
}
