/* ============================================================
   QUAILS FARM MANAGEMENT SYSTEM - MAIN STYLESHEET
   ============================================================ */

:root {
    --primary: #2d6a4f;
    --primary-light: #40916c;
    --primary-dark: #1a472a;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topnav-height: 60px;
    --sidebar-bg: #1a2332;
    --sidebar-text: rgba(255,255,255,0.75);
    --sidebar-hover: rgba(255,255,255,0.1);
    --sidebar-active: rgba(64,145,108,0.25);
    --sidebar-active-text: #6fcf97;
    --card-radius: 12px;
    --transition: all 0.25s ease;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

/* ── App Layout ─────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }
.content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    min-width: 0;
}
.main-content { flex: 1; overflow-x: hidden; }

body.sidebar-collapsed .content-wrapper { margin-left: var(--sidebar-collapsed-width); }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: var(--topnav-height);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}
.brand-text { transition: var(--transition); }
body.sidebar-collapsed .brand-text { opacity: 0; width: 0; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem;
    margin: 0.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    overflow: hidden;
}
.user-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-info { overflow: hidden; }
.user-name { color: #fff; font-weight: 600; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.65rem; }
body.sidebar-collapsed .user-info { display: none; }

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-item { position: relative; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    margin: 1px 8px;
    font-size: 0.855rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}
.sidebar-link i:first-child { width: 20px; text-align: center; flex-shrink: 0; font-size: 0.95rem; }
.sidebar-link span { overflow: hidden; transition: var(--transition); }
body.sidebar-collapsed .sidebar-link span { opacity: 0; width: 0; }
body.sidebar-collapsed .sidebar-link .ms-auto { display: none; }

.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-item.active > .sidebar-link { background: var(--sidebar-active); color: var(--sidebar-active-text); }

.sidebar-subnav {
    list-style: none;
    padding: 4px 0 4px 40px;
    margin: 0;
}
.sidebar-subnav li a {
    display: block;
    padding: 6px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.82rem;
    transition: var(--transition);
}
.sidebar-subnav li a:hover { color: #fff; background: var(--sidebar-hover); }
body.sidebar-collapsed .sidebar-subnav { display: none; }

.sidebar-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 8px 16px; }

/* ── Top Navbar ──────────────────────────────────────────────── */
.topnav {
    height: var(--topnav-height);
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    position: sticky;
    top: 0;
    z-index: 999;
    padding: 0 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
[data-bs-theme="dark"] .topnav { background: #1e293b; border-color: rgba(255,255,255,0.07); }

.sidebar-toggle-btn { padding: 6px 8px; border-radius: 8px; }

/* Notifications */
.badge-notif {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 10px;
}

.notification-dropdown { width: 340px; max-height: 480px; overflow: hidden; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    transition: background .15s;
}
.notif-item:hover { background: #f8f9fa; }
.notif-item.unread { background: #fffbf0; }
.notif-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-title { font-size: 0.82rem; font-weight: 500; line-height: 1.3; }
.notif-time { font-size: 0.72rem; margin-top: 2px; }
.dropdown-header { border-bottom: 1px solid rgba(0,0,0,0.07); }
.dropdown-footer { border-top: 1px solid rgba(0,0,0,0.07); background: #f8f9fa; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.78rem; color: #6c757d; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.stat-sub { font-size: 0.76rem; margin-top: 4px; }

[data-bs-theme="dark"] .stat-card { background: #1e293b; }

/* ── Cards ────────────────────────────────────────────────────── */
.card { border-radius: var(--card-radius); border: 1px solid rgba(0,0,0,0.07); }
[data-bs-theme="dark"] .card { border-color: rgba(255,255,255,0.07); }
.card-header { padding: 1rem 1.25rem; font-size: 0.875rem; border-bottom: 1px solid rgba(0,0,0,0.06); }

/* ── Tables ──────────────────────────────────────────────────── */
.table th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; color: #6c757d; white-space: nowrap; }
.table > :not(caption) > * > * { padding: 0.75rem 1rem; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 8px;
    font-size: 0.875rem;
    border-color: #dee2e6;
}
.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 3px rgba(45,106,79,0.2);
    border-color: var(--primary-light);
}
.form-label { font-size: 0.82rem; font-weight: 500; margin-bottom: 0.35rem; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { border-radius: 8px; font-size: 0.85rem; font-weight: 500; }
.btn-success { background: var(--primary-light); border-color: var(--primary-light); }
.btn-success:hover { background: var(--primary); border-color: var(--primary); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { font-weight: 500; letter-spacing: 0.02em; }

/* ── Upload Preview ──────────────────────────────────────────── */
.upload-preview img { border-radius: 10px; max-width: 100%; }

/* ── Dark Mode ──────────────────────────────────────────────── */
[data-bs-theme="dark"] body { background: #0f172a; color: #e2e8f0; }
[data-bs-theme="dark"] .stat-card { background: #1e293b; }
[data-bs-theme="dark"] .table-light { background: #1e293b; }
[data-bs-theme="dark"] .notif-item:hover { background: #1e293b; }
[data-bs-theme="dark"] .notif-item.unread { background: #1e2d1e; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1045;
    }
    .sidebar.show { transform: translateX(0); }
    .content-wrapper { margin-left: 0 !important; }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1044;
        display: none;
    }
    .sidebar-overlay.show { display: block; }
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }

/* ── Print ───────────────────────────────────────────────────── */
@media print {
    .sidebar, .topnav, .btn, .card-footer { display: none !important; }
    .content-wrapper { margin: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.4s ease both; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container .toast { min-width: 280px; border-radius: 10px; }
