/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: #111; background: #f9fafb; line-height: 1.5; }
a { color: inherit; text-decoration: none; }

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-muted { color: #6b7280; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.overflow-x-auto { overflow-x: auto; }
.hidden { display: none !important; }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ===== Cards ===== */
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 0.5rem; overflow: hidden; }
.card-header { padding: 1.25rem 1.5rem 0.75rem; }
.card-header h2, .card-header h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.25rem; }
.card-body { padding: 1rem 1.5rem 1.5rem; }
.card-no-border { border: none; box-shadow: 0 4px 15px rgba(0,0,0,0.08); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 0.375rem; font-size: 0.875rem; font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: #facc15; color: #111; border-color: #facc15; }
.btn-primary:hover:not(:disabled) { background: #eab308; }
.btn-outline { background: transparent; color: #374151; border-color: #d1d5db; }
.btn-outline:hover:not(:disabled) { background: #f3f4f6; }
.btn-danger { background: transparent; color: #dc2626; border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-ghost { background: transparent; color: #374151; border: none; }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 0.4rem; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; color: #374151; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"],
select, textarea {
    width: 100%; padding: 0.5rem 0.75rem; border: 1px solid #d1d5db; border-radius: 0.375rem;
    font-size: 0.875rem; line-height: 1.5; transition: border-color 0.15s;
    background: #fff; color: #111;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #facc15; box-shadow: 0 0 0 3px rgba(250,204,21,0.15); }
textarea { resize: vertical; min-height: 80px; }

.input-icon-wrap { position: relative; }
.input-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: #9ca3af; pointer-events: none; }
.input-with-icon { padding-left: 2.5rem; }

.input-with-btn { display: flex; gap: 0.5rem; }
.input-with-btn input, .input-with-btn select { flex: 1; }

/* ===== Alerts ===== */
.alert { padding: 0.75rem 1rem; border-radius: 0.375rem; font-size: 0.875rem; margin-bottom: 1rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; white-space: nowrap; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-indigo { background: #e0e7ff; color: #3730a3; }
.badge-cyan { background: #cffafe; color: #155e75; }
.badge-emerald { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { background: #f9fafb; }
th { text-align: left; padding: 0.75rem 1rem; font-weight: 600; color: #374151; border-bottom: 2px solid #e5e7eb; white-space: nowrap; }
td { padding: 0.75rem 1rem; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tr:hover { background: #f9fafb; }
th .sortable { cursor: pointer; display: inline-flex; align-items: center; gap: 0.25rem; }

/* ===== Featured Cards Drag & Drop ===== */
.featured-list { display: flex; flex-direction: column; gap: 0.25rem; }
.featured-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 0.375rem; cursor: default; transition: box-shadow 0.15s, opacity 0.15s; font-size: 0.8125rem; }
.featured-item.dragging, .featured-card-item.dragging { opacity: 0.4; }
.featured-item.drag-over, .featured-card-item.drag-over { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,0.3); }
.drag-handle { cursor: grab; font-size: 0.875rem; color: #9ca3af; user-select: none; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }
.featured-order { font-weight: 700; font-size: 0.7rem; color: #92400e; background: #fef3c7; width: 1.25rem; height: 1.25rem; display: flex; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; }
.featured-thumb { display: block !important; width: 28px !important; height: 28px !important; min-width: 28px !important; max-width: 28px !important; min-height: 28px !important; max-height: 28px !important; border-radius: 0.2rem; object-fit: cover !important; flex-shrink: 0; }
.featured-thumb-placeholder { display: block; width: 28px; height: 28px; min-width: 28px; border-radius: 0.2rem; background: #f3f4f6; flex-shrink: 0; }
.featured-role { font-weight: 500; font-size: 0.8125rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* View Toggle */
.view-toggle { display: inline-flex; border: 1px solid #d1d5db; border-radius: 0.375rem; overflow: hidden; }
.view-btn { background: #fff; border: none; padding: 0.25rem 0.5rem; cursor: pointer; font-size: 0.8rem; color: #6b7280; transition: all 0.15s; line-height: 1; }
.view-btn:not(:last-child) { border-right: 1px solid #d1d5db; }
.view-btn:hover { background: #f9fafb; }
.view-btn.active { background: #fef3c7; color: #92400e; }

/* Featured Grid Views */
.featured-grid { display: grid; gap: 0.5rem; flex-direction: unset; }
.featured-grid-sm { grid-template-columns: repeat(3, 1fr); }
.featured-grid-md { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1024px) { .featured-grid-sm { grid-template-columns: repeat(2, 1fr); } .featured-grid-md { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .featured-grid-sm { grid-template-columns: 1fr; } .featured-grid-md { grid-template-columns: 1fr; } }

.featured-card-item { background: #fffbeb; border: 1px solid #fde68a; border-radius: 0.375rem; overflow: hidden; cursor: default; transition: box-shadow 0.15s, opacity 0.15s; }
.featured-card-top { display: flex; align-items: center; justify-content: space-between; padding: 0.25rem 0.4rem; }
.featured-card-top .drag-handle { margin-left: auto; }
.featured-card-remove { margin-left: 0; padding: 0.1rem 0.25rem; }
.featured-card-img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }
.featured-card-img-empty { width: 100%; aspect-ratio: 16/10; background: #f3f4f6; }
.featured-card-info { padding: 0.35rem 0.5rem; }
.featured-card-role { font-weight: 500; font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.featured-grid-md .featured-card-role { font-size: 0.8125rem; }
.featured-grid-md .featured-card-info { padding: 0.5rem 0.6rem; }

/* Small card view - compact with 36x36 thumbnail */
.featured-card-sm { display: flex !important; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; overflow: visible; }
.featured-card-thumb { display: block !important; width: 36px !important; height: 36px !important; min-width: 36px !important; max-width: 36px !important; min-height: 36px !important; max-height: 36px !important; border-radius: 0.25rem; object-fit: cover !important; flex-shrink: 0; }
.featured-card-thumb-empty { display: block; width: 36px; height: 36px; min-width: 36px; border-radius: 0.25rem; background: #f3f4f6; flex-shrink: 0; }
.featured-card-sm-info { flex: 1; min-width: 0; overflow: hidden; }
.featured-card-sm-info .featured-card-role { font-size: 0.8125rem; }

.btn-star { background: none; border: none; cursor: pointer; font-size: 1.2rem; padding: 0.25rem; line-height: 1; transition: transform 0.15s; }
.btn-star:hover { transform: scale(1.2); }
.btn-star.active { color: #f59e0b; }

/* ===== Login Page ===== */
.login-body { background: #f3f4f6; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-wrapper { width: 100%; max-width: 420px; }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon { width: 64px; height: 64px; background: #facc15; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; color: #1f2937; }
.login-header h1 { font-size: 1.5rem; font-weight: 700; color: #111827; }
.login-header p { color: #6b7280; margin-top: 0.25rem; }

/* ===== Layout: Sidebar + Content ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: #fff; border-right: 1px solid #e5e7eb; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; transition: transform 0.3s ease; }
.sidebar-header { padding: 1.25rem; display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid #f3f4f6; }
.sidebar-logo { width: 36px; height: 36px; background: #facc15; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.sidebar-logo svg { width: 18px; height: 18px; color: #1f2937; }
.sidebar-brand h2 { font-size: 1.1rem; font-weight: 600; }
.sidebar-brand p { font-size: 0.75rem; color: #6b7280; }

.sidebar-nav { flex: 1; padding: 1rem; }
.sidebar-nav a { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem; border-radius: 0.375rem; color: #374151; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; transition: all 0.15s; }
.sidebar-nav a:hover { background: #f3f4f6; }
.sidebar-nav a.active { background: #fef9c3; color: #854d0e; }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer { padding: 1rem; border-top: 1px solid #f3f4f6; }
.sidebar-footer a { color: #dc2626; }
.sidebar-footer a:hover { background: #fef2f2; }

.main-area { flex: 1; margin-left: 260px; display: flex; flex-direction: column; transition: margin-left 0.3s ease; }

/* Sidebar collapsed state (desktop) */
.layout.sidebar-collapsed .sidebar { transform: translateX(-100%); }
.layout.sidebar-collapsed .main-area { margin-left: 0; }
.top-header { background: #fff; border-bottom: 1px solid #e5e7eb; padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40; }
.top-header h1 { font-size: 1.25rem; font-weight: 600; }
.top-header .header-right { display: flex; align-items: center; gap: 1rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e5e7eb; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.8rem; color: #374151; }
.main-content { flex: 1; padding: 1.5rem; }

/* Sidebar toggle button - always visible */
.sidebar-toggle { display: block; background: none; border: none; cursor: pointer; padding: 0.5rem; border-radius: 0.375rem; transition: background 0.15s; }
.sidebar-toggle:hover { background: #f3f4f6; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 45; }
    .sidebar.open + .sidebar-overlay { display: block; }
    .main-area { margin-left: 0; }
    /* On mobile, undo desktop collapsed state */
    .layout.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    .layout.sidebar-collapsed .sidebar.open { transform: translateX(0); }
    .layout.sidebar-collapsed .main-area { margin-left: 0; }
}

/* ===== Dashboard Stats ===== */
.stat-card { border: none; box-shadow: 0 4px 15px rgba(0,0,0,0.06); border-radius: 0.75rem; padding: 1.5rem; }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-card .stat-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; margin-top: 0.5rem; }
.stat-card .stat-sub { font-size: 0.8rem; margin-top: 0.25rem; }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.stat-card .stat-icon svg { width: 28px; height: 28px; }

.stat-blue { background: linear-gradient(135deg, #eff6ff, #dbeafe); }
.stat-blue .stat-label { color: #2563eb; }
.stat-blue .stat-value { color: #1e3a5f; }
.stat-blue .stat-sub { color: #1d4ed8; }
.stat-blue .stat-icon { background: #bfdbfe; }
.stat-blue .stat-icon svg { color: #1d4ed8; }

.stat-green { background: linear-gradient(135deg, #f0fdf4, #dcfce7); }
.stat-green .stat-label { color: #16a34a; }
.stat-green .stat-value { color: #14532d; }
.stat-green .stat-sub { color: #15803d; }
.stat-green .stat-icon { background: #bbf7d0; }
.stat-green .stat-icon svg { color: #15803d; }

.stat-purple { background: linear-gradient(135deg, #faf5ff, #f3e8ff); }
.stat-purple .stat-label { color: #9333ea; }
.stat-purple .stat-value { color: #3b0764; }
.stat-purple .stat-sub { color: #7e22ce; }
.stat-purple .stat-icon { background: #e9d5ff; }
.stat-purple .stat-icon svg { color: #7e22ce; }

.stat-red { background: linear-gradient(135deg, #fef2f2, #fee2e2); }
.stat-red .stat-label { color: #dc2626; }
.stat-red .stat-value { color: #450a0a; }
.stat-red .stat-sub { color: #b91c1c; }
.stat-red .stat-icon { background: #fecaca; }
.stat-red .stat-icon svg { color: #b91c1c; }

/* Pipeline items */
.pipeline-item { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem; border-radius: 0.5rem; margin-bottom: 0.5rem; }
.pipeline-count { padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.8rem; font-weight: 600; }

/* Progress bar */
.progress-bar { width: 100%; height: 8px; background: #e5e7eb; border-radius: 9999px; overflow: hidden; }
.progress-fill { height: 100%; background: #16a34a; border-radius: 9999px; transition: width 0.5s; }

/* Recent activity cards */
.activity-card { padding: 1rem; border: 1px solid #e5e7eb; border-radius: 0.5rem; transition: box-shadow 0.15s; }
.activity-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* ===== Modal / Dialog ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: 0.5rem; width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.5rem; color: #6b7280; line-height: 1; }

/* ===== Page-specific ===== */
.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.page-desc { color: #6b7280; margin-bottom: 1.5rem; }

.filter-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.filter-row .form-group { flex: 1; min-width: 200px; margin-bottom: 0; }

.actions-cell { display: flex; gap: 0.5rem; }

code { background: #f3f4f6; padding: 0.15rem 0.4rem; border-radius: 0.25rem; font-size: 0.8rem; }

/* History box on edit page */
.history-box { background: #f9fafb; padding: 1rem; border-radius: 0.5rem; margin-top: 1rem; }
.history-box p { font-size: 0.875rem; color: #4b5563; margin-bottom: 0.25rem; }

/* ===== Job Cards: Image styles ===== */
.table-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 0.375rem; border: 1px solid #e5e7eb; }
.image-preview { max-width: 100%; max-height: 160px; object-fit: contain; border-radius: 0.375rem; border: 1px solid #e5e7eb; margin-top: 0.25rem; }
