/* ============================================================
   DairyFam – Custom Stylesheet  (nitara.farm inspired)
   ============================================================ */

:root {
    --primary: #1565C0;
    --primary-light: #1E88E5;
    --primary-bg: #E3F2FD;
    --sidebar-bg: #ffffff;
    --sidebar-width: 240px;
    --header-h: 60px;
    --accent-green: #2E7D32;
    --accent-orange: #E65100;
    --accent-amber: #F9A825;
    --text-muted: #78909C;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --border-color: #E0E0E0;
}

/* --- Base --- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', sans-serif; background: #F5F7FA; color: #263238; }
a { text-decoration: none; color: inherit; }

/* --- Layout --- */
.df-wrapper { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.df-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform .25s ease;
}
.df-sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--primary);
    color: white;
}
.df-sidebar-logo .logo-icon {
    width: 36px; height: 36px; background: white;
    border-radius: 8px; display: grid; place-items: center;
    font-size: 20px;
}
.df-sidebar-logo .logo-text { font-weight: 700; font-size: 15px; line-height: 1.2; }
.df-sidebar-logo .logo-text small { font-size: 10px; opacity: .8; display: block; font-weight: 400; }

.df-nav { padding: 8px 0; flex: 1; }
.df-nav-group { margin-bottom: 2px; }
.df-nav-group-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px;
    font-size: 13px; font-weight: 600; color: #37474F;
    cursor: pointer;
    border-radius: 0;
    transition: background .15s;
    user-select: none;
}
.df-nav-group-header:hover { background: #F5F7FA; }
.df-nav-group-header .group-icon { font-size: 16px; margin-right: 8px; }
.df-nav-group-header .chevron { font-size: 11px; transition: transform .2s; }
.df-nav-group-header.active .chevron { transform: rotate(180deg); }
.df-nav-group-header.active { color: var(--primary); background: var(--primary-bg); }

.df-nav-sub { display: none; padding: 0 0 4px 0; }
.df-nav-sub.open { display: block; }
.df-nav-sub a {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 20px 8px 44px;
    font-size: 13px; color: #546E7A;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.df-nav-sub a:hover { color: var(--primary); background: #EEF5FF; }
.df-nav-sub a.active {
    color: var(--primary); background: var(--primary-bg);
    border-left-color: var(--primary); font-weight: 600;
}

/* --- Main Content --- */
.df-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Top Header --- */
.df-header {
    height: var(--header-h);
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.df-header .page-title { font-size: 18px; font-weight: 600; color: #263238; }
.df-header .header-right { display: flex; align-items: center; gap: 16px; }
.df-header .user-badge {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 500;
}
.df-header .user-badge .avatar {
    width: 34px; height: 34px; background: var(--primary);
    border-radius: 50%; display: grid; place-items: center;
    color: white; font-size: 13px; font-weight: 700;
}

/* --- Page Content --- */
.df-content { padding: 24px; flex: 1; }

/* --- Cards --- */
.stat-card {
    background: white; border-radius: 12px;
    padding: 20px 22px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: #263238; margin: 6px 0 0; }
.stat-card .stat-value.green { color: var(--accent-green); }
.stat-card .stat-value.blue { color: var(--primary); }
.stat-card .stat-value.orange { color: var(--accent-orange); }

.herd-card {
    background: white; border-radius: 12px;
    padding: 20px; box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}
.herd-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 20px;
    font-size: 13px; font-weight: 600;
    background: var(--primary-bg); color: var(--primary);
}

/* --- Tables --- */
.df-table {
    width: 100%; border-collapse: collapse;
    background: white; border-radius: 12px;
    overflow: hidden; box-shadow: var(--card-shadow);
}
.df-table thead th {
    background: #F8FAFF; color: #546E7A;
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    padding: 12px 16px; text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.df-table tbody td {
    padding: 12px 16px; font-size: 13px; color: #37474F;
    border-bottom: 1px solid #F5F5F5;
}
.df-table tbody tr:last-child td { border-bottom: none; }
.df-table tbody tr:hover td { background: #FAFBFF; }

/* --- Badges --- */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
}
.badge-milking  { background: #E8F5E9; color: #2E7D32; }
.badge-dry      { background: #FFF3E0; color: #E65100; }
.badge-heifer   { background: #F3E5F5; color: #7B1FA2; }
.badge-bull     { background: #E3F2FD; color: #1565C0; }
.badge-calf     { background: #FFF8E1; color: #F57F17; }
.badge-female   { background: #FCE4EC; color: #C62828; }
.badge-male     { background: #E3F2FD; color: #1565C0; }

/* --- Buttons --- */
.btn-primary {
    background: var(--primary); color: white;
    border: none; border-radius: 8px; padding: 8px 18px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background .15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { background: #0D47A1; }
.btn-outline {
    background: white; color: var(--primary);
    border: 1px solid var(--primary); border-radius: 8px;
    padding: 7px 16px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all .15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-outline:hover { background: var(--primary-bg); }
.btn-danger {
    background: #EF5350; color: white;
    border: none; border-radius: 8px; padding: 7px 14px;
    font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* --- Forms --- */
.df-form-group { margin-bottom: 16px; }
.df-form-group label { display: block; font-size: 12px; font-weight: 600; color: #546E7A; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.df-form-group input, .df-form-group select, .df-form-group textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #CFD8DC;
    border-radius: 8px; font-size: 14px; color: #263238;
    transition: border-color .15s;
    background: white;
}
.df-form-group input:focus, .df-form-group select:focus, .df-form-group textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,.12);
}

/* --- Dashboard welcome banner --- */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, #1976D2 100%);
    color: white; border-radius: 14px; padding: 24px 28px;
    margin-bottom: 20px;
    display: flex; align-items: center; justify-content: space-between;
}
.welcome-banner h2 { margin: 0 0 4px; font-size: 22px; }
.welcome-banner p { margin: 0; opacity: .85; font-size: 14px; }

/* --- Alert cards --- */
.alert-card {
    background: #FFF8E1; border-left: 4px solid var(--accent-amber);
    border-radius: 8px; padding: 12px 16px; font-size: 13px; color: #37474F;
    margin-bottom: 12px;
}
.alert-card.danger { background: #FFEBEE; border-left-color: #EF5350; }

/* --- Page header toolbar --- */
.page-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-toolbar h4 { margin: 0; font-size: 16px; font-weight: 600; }

/* --- Modal --- */
.df-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    z-index: 200; display: none; align-items: center; justify-content: center;
}
.df-modal-overlay.show { display: flex; }
.df-modal {
    background: white; border-radius: 14px; padding: 28px;
    width: 520px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.df-modal h3 { margin: 0 0 20px; font-size: 17px; }

/* --- Misc --- */
.section-title { font-size: 15px; font-weight: 600; color: #37474F; margin: 0 0 14px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.align-center { align-items: center; } .justify-between { justify-content: space-between; }

@media (max-width: 900px) {
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .df-sidebar { transform: translateX(-100%); }
    .df-main { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
