/* Product Hunting & Sourcing Dashboard */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Sidebar layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 240px;
    background: #1f2937;
    color: #e5e7eb;
    flex-shrink: 0;
    position: sticky; top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 20px 16px 16px;
    border-bottom: 1px solid #374151;
}
.brand-title { font-weight: 700; font-size: 15px; color: #fff; }
.brand-sub { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.sidebar-nav { padding: 12px 8px; }
.sidebar-section { margin-bottom: 20px; }
.sidebar-section-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: #6b7280; padding: 8px 12px; font-weight: 600;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 6px;
    color: #d1d5db; font-weight: 500; font-size: 14px;
    margin-bottom: 2px;
}
.sidebar-nav a:hover { background: #374151; text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a .ic { font-size: 16px; width: 20px; display: inline-block; text-align: center; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Top bar (compact, inside main) */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
    padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between;
    height: 56px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 500; font-size: 14px; }

/* Notification bell */
.notif-wrap { position: relative; }
.notif-bell {
    background: transparent; border: none; cursor: pointer;
    font-size: 18px; padding: 6px 10px; border-radius: 6px;
    position: relative;
}
.notif-bell:hover { background: var(--gray-100); }
.notif-badge {
    position: absolute; top: 0; right: 0;
    background: var(--danger); color: #fff;
    border-radius: 10px; padding: 1px 5px;
    font-size: 10px; font-weight: 700; line-height: 1.2;
    min-width: 16px; text-align: center;
}
.notif-panel {
    position: absolute; right: 0; top: calc(100% + 4px);
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    width: 380px; max-height: 480px; overflow-y: auto;
    z-index: 200;
}
.notif-header {
    padding: 10px 14px; border-bottom: 1px solid var(--gray-200);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--gray-50); border-top-left-radius: 8px; border-top-right-radius: 8px;
}
.notif-mark-all { font-size: 12px; color: var(--primary); }
.notif-empty { padding: 30px 16px; text-align: center; color: var(--gray-500); font-size: 13px; }
.notif-list { display: flex; flex-direction: column; }
.notif-item {
    padding: 10px 14px; border-bottom: 1px solid var(--gray-100);
    color: var(--gray-900); text-decoration: none; display: block;
}
.notif-item:hover { background: var(--gray-50); text-decoration: none; }
.notif-item.unread { background: #eff6ff; }
.notif-item.unread:hover { background: #dbeafe; }
.notif-msg { font-size: 13px; line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--gray-500); margin-top: 3px; }
.btn-link { color: var(--gray-500); font-size: 13px; }

.container-narrow { max-width: 480px; }

/* Mobile responsiveness */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .sidebar-nav { padding: 8px; }
    .sidebar-section { margin-bottom: 8px; }
}

/* Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
}

/* Headings */
h1 { font-size: 24px; margin: 0 0 4px 0; }
h2 { font-size: 18px; margin: 0 0 16px 0; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header p { color: var(--gray-500); margin: 0; }

/* Cards */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 18px;
}
.stat-label { color: var(--gray-500); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

/* Forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; color: var(--gray-700); }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.92); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* Tables */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--gray-200); border-radius: 8px; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th, table.data td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}
table.data th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}
table.data tbody tr:hover { background: var(--gray-50); }
table.data tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-not_started { background: var(--gray-200); color: var(--gray-700); }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-sourced { background: #d1fae5; color: #065f46; }
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-super_admin { background: #fce7f3; color: #9d174d; }
.badge-hunting_manager { background: #ddd6fe; color: #5b21b6; }
.badge-manager { background: #dbeafe; color: #1e40af; }
.badge-department_manager { background: #c7d2fe; color: #3730a3; }
.badge-dept_assistant_manager { background: #e0e7ff; color: #4338ca; }
.badge-sourcing { background: #fef3c7; color: #92400e; }
.badge-employee { background: var(--gray-200); color: var(--gray-700); }
.badge-account_manager { background: var(--gray-200); color: var(--gray-700); }
.badge-accountant { background: #fce4ec; color: #880e4f; }
.badge-order_pending { background: #fef3c7; color: #92400e; }
.badge-ordered { background: #dbeafe; color: #1e40af; }
.badge-received { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-not_ordered { background: var(--gray-200); color: var(--gray-700); }

/* Sourcing workflow badges */
.badge-awaiting_sourcing { background: var(--gray-200); color: var(--gray-700); }
.badge-offer_submitted { background: #fef3c7; color: #92400e; }
.badge-offer_approved { background: #d1fae5; color: #065f46; }
.badge-offer_rejected { background: #fee2e2; color: #991b1b; }
.badge-awaiting_admin_approval { background: #fce7f3; color: #9d174d; }
.badge-started_sourcing { background: #dbeafe; color: #1e40af; }
.badge-order_placed { background: #d1fae5; color: #065f46; }

/* Product thumbnails */
.product-thumb {
    border-radius: 4px;
    object-fit: cover;
    cursor: zoom-in;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    vertical-align: middle;
}
.thumb-placeholder {
    display: inline-block;
    border-radius: 4px;
    background: repeating-linear-gradient(45deg, var(--gray-100), var(--gray-100) 4px, var(--gray-50) 4px, var(--gray-50) 8px);
    border: 1px solid var(--gray-200);
    vertical-align: middle;
}

/* Soft-deleted indicator */
.deleted-row { opacity: 0.6; }
.deleted-row td { text-decoration: line-through; }
.deleted-row .actions-cell { text-decoration: none; }

/* Image upload preview */
.img-upload-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    margin-top: 8px;
    border: 1px solid var(--gray-200);
}

/* Department tag */
.dept-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

/* Department switcher */
.dept-switcher select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--gray-300);
    background: var(--gray-50);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.dept-switcher select:focus { outline: none; border-color: var(--primary); }

/* Pool meter */
.pool-meter {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.pool-meter-bar {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}
.pool-meter-fill {
    height: 100%;
    background: var(--success);
    transition: width 0.3s;
}
.pool-meter-fill.warn { background: var(--warning); }
.pool-meter-fill.full { background: var(--danger); }
.pool-meter-text { font-weight: 600; font-size: 13px; white-space: nowrap; }
.pool-meter-text.full { color: var(--danger); }

/* Mini stat tile in row */
.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.mini-stat {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 12px 14px;
}
.mini-stat-label { color: var(--gray-500); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }
.mini-stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; }

/* Employee breakdown table */
.breakdown {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    margin-bottom: 16px;
}
.breakdown-title {
    padding: 14px 18px;
    font-weight: 600;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Alerts */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* Login page */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px;
    width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-card h1 { text-align: center; margin-bottom: 24px; }

/* Filters bar */
.filters {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.filters-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters-row .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--gray-500);
    font-size: 12px;
}

/* Misc */
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; }
.flex { display: flex; gap: 8px; align-items: center; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--gray-500); }
.actions-cell { white-space: nowrap; }

@media (max-width: 768px) {
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 12px; gap: 12px; }
    .nav { order: 3; width: 100%; overflow-x: auto; }
    .form-row { grid-template-columns: 1fr; }
}

/* Bulk action bar */
.bulk-bar {
    display: flex; align-items: center; gap: 12px;
    background: #fef3c7; border: 1px solid #f59e0b;
    padding: 10px 14px; border-radius: 6px;
    margin-bottom: 12px;
    position: sticky; top: 60px; z-index: 40;
}
.bulk-bar strong { font-size: 15px; }

/* Pagination */
.pagination {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 16px; padding: 12px 0; margin-top: 8px;
    border-top: 1px solid var(--gray-200);
}
.pagination-info { color: var(--gray-500); font-size: 13px; flex: 1; min-width: 120px; }
.pagination-size { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--gray-500); }
.pagination-size a {
    padding: 3px 9px; border-radius: 4px; color: var(--gray-700);
    text-decoration: none; border: 1px solid var(--gray-200); background: #fff;
}
.pagination-size a:hover { background: var(--gray-100); }
.pagination-size a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-pages { display: flex; align-items: center; gap: 4px; }
.pagination-pages a {
    padding: 6px 11px; border-radius: 4px; color: var(--gray-700);
    text-decoration: none; border: 1px solid var(--gray-200); background: #fff;
    font-size: 13px; font-weight: 500;
}
.pagination-pages a:hover { background: var(--gray-100); }
.pagination-pages a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-ellipsis { padding: 0 4px; color: var(--gray-500); }
