/* ============================================================
   RAJEEV DAIRY FARM — Responsive Stylesheet
   Desktop: sidebar fixed-left + scrollable content
   Mobile:  fixed topbar + slide-in sidebar drawer
   ============================================================ */

:root {
    --primary:          #16a34a;
    --primary-dark:     #15803d;
    --sidebar-w:        260px;
    --sidebar-bg:       #1a2332;
    --sidebar-text:     #c8d6e5;
    --sidebar-hover:    rgba(255,255,255,.07);
    --sidebar-active:   rgba(22,163,74,.22);
    --topbar-h:         56px;
}

/* ── Reset / Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Inter', sans-serif;
    background: #f4f6f9;
    color: #1e293b;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ── Root layout wrapper ───────────────────────── */
/* Each page: <div class="app-layout d-flex"> ... </div>  */
/* The sidebar is the first flex child, main-content second */

/* ═══════════════════════════════════════
   SIDEBAR  (Desktop)
   ═══════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    min-height: 100vh;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.sidebar-logo  { width:36px; height:36px; border-radius:50%; object-fit:cover; background:#fff; flex-shrink:0; }
.sidebar-title { color:#fff; font-weight:700; font-size:.85rem; letter-spacing:.5px; text-transform:uppercase; }

.sidebar-nav {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: all .18s;
    min-height: 44px;
}
.sidebar-link:hover  { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left: 3px solid var(--primary);
    font-weight: 600;
    padding-left: 13px;
}
.sidebar-link i { width: 18px; text-align: center; font-size: .95rem; flex-shrink: 0; }

/* Sidebar open state — set globally so JS toggle always works */
.sidebar.open { transform: translateX(0) !important; }

.nav-divider { padding: 14px 16px 4px; color: rgba(255,255,255,.35); font-size: .7rem; letter-spacing: 1px; list-style: none; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.user-avatar    { width:34px; height:34px; background:var(--primary); color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:.85rem; flex-shrink:0; }
.user-avatar-sm { width:28px; height:28px; background:var(--primary); color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:.75rem; flex-shrink:0; }
.user-info  { flex:1; min-width:0; overflow:hidden; }
.user-name  { color:#fff; font-size:.8rem; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-role  { color:var(--sidebar-text); font-size:.7rem; }

/* Sidebar close button — visible only on mobile via d-flex d-md-none Bootstrap class */
.sidebar-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background .2s;
    z-index: 1;
}
.sidebar-close-btn:hover { background: rgba(255,255,255,.25); }

/* ── Sidebar Overlay (mobile backdrop) ─ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1039;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ═══════════════════════════════════════
   MOBILE TOPBAR  (hidden on desktop via Bootstrap d-md-none)
   ═══════════════════════════════════════ */
.mobile-topbar {
    /* Bootstrap d-flex d-md-none on the element handles show/hide */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--sidebar-bg);
    z-index: 1050;
    align-items: center;
    padding: 0 14px;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.mobile-topbar .brand-name {
    color: #fff;
    font-weight: 700;
    font-size: .88rem;
    letter-spacing: .4px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.mobile-topbar .topbar-logo {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.hamburger-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    flex-shrink: 0;
    min-width: 36px;
    min-height: 36px;
}
.hamburger-btn:hover { background: rgba(255,255,255,.12); }

/* ═══════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════ */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 24px;
    min-height: 100vh;
}

/* ── Cards ─────────────────────────────── */
.card { border: none; box-shadow: 0 1px 4px rgba(0,0,0,.08); border-radius: 12px; }
.card-header { border-radius: 12px 12px 0 0 !important; }

/* ── Stat Cards ─────────────────────────── */
.stat-value { font-size: 1.6rem; font-weight: 700; color: #1e293b; }
.stat-label { font-size: .78rem; color: #64748b; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-icon  { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }

/* ── Color utilities ────────────────────── */
.bg-primary-soft { background: rgba(22,163,74,.12) !important; }
.bg-success-soft { background: rgba(34,197,94,.12) !important; }
.bg-danger-soft  { background: rgba(239,68,68,.12) !important; }
.bg-warning-soft { background: rgba(234,179,8,.12) !important; }
.bg-info-soft    { background: rgba(59,130,246,.12) !important; }
.text-primary    { color: var(--primary) !important; }
.btn-primary     { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.badge.bg-primary { background: var(--primary) !important; }

/* ── Tables ─────────────────────────────── */
.table th { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; background: #f8fafc; }
.table td  { font-size: .875rem; vertical-align: middle; }
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ── Forms ──────────────────────────────── */
.form-label { font-size: .85rem; margin-bottom: .3rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(22,163,74,.18);
}
.page-header { padding-bottom: 16px; border-bottom: 1px solid #e2e8f0; margin-bottom: 24px; }

/* ── Login ──────────────────────────────── */
.login-body { background: linear-gradient(135deg,#f0fdf4,#dcfce7); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 420px; padding: 20px; }
.login-card { border: none; border-radius: 20px; }
.login-header { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-radius: 20px 20px 0 0; }
.login-logo { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 4px solid rgba(255,255,255,.3); }

/* ── Splash ─────────────────────────────── */
.splash-screen { position: fixed; inset: 0; background: #f0fdf4; display: flex; align-items: center; justify-content: center; z-index: 9999; }
.splash-logo { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; box-shadow: 0 4px 20px rgba(22,163,74,.3); border: 4px solid #fff; }
.splash-title { font-size: 2rem; font-weight: 700; color: #1a2332; letter-spacing: 2px; }
.splash-subtitle { color: #64748b; font-size: 1rem; }
.loader-bar { width: 200px; height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin: 0 auto; }
.loader-progress { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 99px; width: 0%; transition: width .05s linear; }

/* ── Footer ─────────────────────────────── */
.footer { font-size: .8rem; }

/* ══════════════════════════════════════════════════════════
   MOBILE  ≤ 767px  (Bootstrap md breakpoint = 768px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {

    /* Main content: push below the fixed topbar */
    .main-content {
        padding-top: calc(var(--topbar-h) + 16px);
        padding-left: 14px;
        padding-right: 14px;
        padding-bottom: 24px;
    }

    /* Sidebar becomes a slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        width: var(--sidebar-w);
        transform: translateX(-100%);
        box-shadow: 4px 0 32px rgba(0,0,0,.4);
        z-index: 1040;
    }
    .sidebar.open { transform: translateX(0); }

    /* Page header: wrap on small screens */
    .page-header { flex-wrap: wrap; gap: 10px; }
    .page-header h4, .page-header h5 { font-size: 1.05rem; }

    /* Tables: ensure horizontal scroll */
    .card table:not(.no-mobile-scroll),
    .main-content table:not(.no-mobile-scroll) {
        min-width: 500px;
    }
    .table th, .table td { white-space: nowrap; padding: .45rem .55rem; }
    .table { font-size: .82rem; }

    /* Inputs: 16px prevents iOS auto-zoom */
    .form-control,
    .form-select {
        font-size: 16px !important;
        min-height: 44px;
    }
    textarea.form-control { min-height: auto; }
    .form-label { font-size: .88rem; font-weight: 600; }

    /* Touch target size for buttons */
    .btn { min-height: 42px; }

    /* Card padding: tighter on mobile */
    .card-body { padding: 14px !important; }

    /* Stat card numbers */
    .stat-value { font-size: 1.25rem; }
    .stat-icon  { width: 40px; height: 40px; }

    /* Alert */
    .alert { font-size: .88rem; }

    /* Breadcrumb */
    .breadcrumb { font-size: .82rem; }

    /* Modals */
    .modal-dialog { margin: 10px; }
    .modal-body   { padding: 14px; }

    /* Login */
    .login-container { padding: 12px; }
    .login-logo { width: 64px; height: 64px; }

    /* Milk table special */
    .milk-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .milk-table-wrap table { min-width: 580px; }
}

/* ── Extra small (< 400px) ────────────── */
@media (max-width: 399.98px) {
    .main-content { padding-left: 10px; padding-right: 10px; }
    .stat-value { font-size: 1.05rem; }
    .table { font-size: .78rem; }
}

/* ── Tablet (768px – 991px) ─────────────
   Sidebar is visible but slightly narrower */
@media (min-width: 768px) and (max-width: 991.98px) {
    :root { --sidebar-w: 220px; }
    .sidebar-title { font-size: .78rem; }
    .sidebar-link  { font-size: .82rem; padding: 10px 13px; }
    .main-content  { padding: 18px; }
    .stat-value    { font-size: 1.35rem; }
}
