/**
 * Master UI modernisation overrides. Uses variables.css.
 * Only overrides visuals; no change to PHP or behaviour.
 */

/* ========== 1. TYPOGRAPHY ========== */
body {
	font-family: "DM Sans", sans-serif;
	font-size: 14px;
	color: var(--text-mid);
	line-height: 1.6;
	letter-spacing: 0.02em;
	background: var(--bg);
	transition: var(--transition);
}

h1, .display-6.page-title, .welcome-business-name {
	font-family: "DM Sans", sans-serif;
	font-size: 26px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--text-dark);
}

h1:not(.welcome-business-name):not(.display-6) {
	font-family: "DM Sans", sans-serif;
	font-size: 26px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--text-dark);
}

h2, h3 {
	font-family: "DM Sans", sans-serif;
	font-size: 15px;
	font-weight: 700;
	color: var(--text-dark);
}

.card-title, .modal-title {
	font-family: "DM Sans", sans-serif;
	font-size: 16px;
	font-weight: 700;
	color: var(--text-dark);
}

small, .text-muted, .page-subtitle, .detail-field-label {
	font-size: 12px;
	color: var(--text-muted);
	letter-spacing: 0.02em;
}

.page-subtitle {
	margin-top: 3px;
}

/* Card labels / table headers (all tables) — match inventory list table */
.detail-field-label,
.table thead th {
	font-size: 10.5px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #495057;
	font-weight: 600;
}

/* ========== 2. BUTTONS ========== */
.btn-primary, .btn.btn-primary {
	padding: 10px 20px;
	background: var(--primary);
	color: #fff;
	border-radius: var(--radius-sm);
	font-size: 13px;
	font-weight: 600;
	border: none;
	transition: var(--transition);
	box-shadow: 0 2px 8px rgba(26, 74, 74, 0.25);
}

.btn-primary:hover, .btn.btn-primary:hover {
	background: var(--primary-light);
	color: #fff;
	transform: translateY(-1px);
	box-shadow: 0 4px 16px rgba(26, 74, 74, 0.3);
}

.btn-secondary, .btn-outline-primary, .btn-outline-secondary {
	padding: 9px 18px;
	border: 1.5px solid var(--primary);
	color: var(--primary);
	background: transparent;
	border-radius: var(--radius-sm);
	font-size: 13px;
	font-weight: 600;
	transition: var(--transition);
}

.btn-secondary:hover, .btn-outline-primary:hover, .btn-outline-secondary:hover {
	background: var(--primary);
	color: #fff;
	border-color: var(--primary);
}

.btn-danger, .btn.btn-danger {
	background: var(--danger-soft);
	color: var(--danger);
	border: 1.5px solid rgba(229, 62, 62, 0.3);
	border-radius: var(--radius-sm);
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 600;
	transition: var(--transition);
}

.btn-danger:hover, .btn.btn-danger:hover {
	background: var(--danger);
	color: #fff;
	border-color: var(--danger);
}

/* Ghost / icon-only (table actions) */
.btn-ghost, .table .btn-sm:not(.btn-primary):not(.btn-danger) {
	width: 32px;
	height: 32px;
	min-width: 32px;
	padding: 0;
	border-radius: var(--radius-xs);
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text-muted);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: var(--transition);
}

.btn-ghost:hover, .table .btn-sm:not(.btn-primary):not(.btn-danger):hover {
	border-color: var(--primary);
	color: var(--primary);
	background: var(--primary-ghost);
}

/* Sidebar logout */
.sidebar-user-card .btn-danger,
.dashboard-sidebar .sidebar-user-card .btn-danger {
	background: rgba(229, 62, 62, 0.12);
	border: 1px solid rgba(229, 62, 62, 0.25);
	color: #fc8181;
	border-radius: var(--radius-xs);
	padding: 7px 0;
	width: 100%;
	font-size: 12px;
	font-weight: 600;
	box-shadow: none;
}

.sidebar-user-card .btn-danger:hover,
.dashboard-sidebar .sidebar-user-card .btn-danger:hover {
	background: rgba(229, 62, 62, 0.22);
	color: #fff;
	transform: none;
}

/* Success → primary */
.btn-success {
	background: var(--primary);
	color: #fff;
	border: none;
}

.btn-success:hover {
	background: var(--primary-light);
	color: #fff;
}

/* ========== 3. CARDS — consistent everywhere ========== */
.card, .business-card, .welcome-card, .upload-zone-card {
	background: var(--surface);
	border-radius: var(--radius);
	border: 1px solid var(--border);
	box-shadow: var(--shadow);
	overflow: hidden;
	transition: var(--transition);
}

.card.border-0, .business-card.border-0, .upload-zone-card.border-0 {
	border: 1px solid var(--border);
}

/* All card bodies get same padding (override p-0, p-3, etc.) */
.card .card-body,
.card-body {
	padding: 20px 24px !important;
}

.card-header {
	padding: 14px 20px !important;
	border-bottom: 1px solid var(--border);
	font-size: 13px;
	font-weight: 700;
	color: var(--text-dark);
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: var(--surface);
}

.welcome-action-card:hover,
.card[href]:hover, .card.clickable:hover {
	transform: translateY(-3px);
	box-shadow: var(--shadow-md);
}

/* ========== 4. TABLES — same look as inventory across entire app ========== */
.table-responsive {
	background: var(--surface);
	border-radius: var(--radius);
	border: 1px solid var(--border);
	box-shadow: var(--shadow);
	overflow: hidden;
}

.table-responsive .table {
	margin-bottom: 0;
}

/* Apply to every table (list-table, table-striped, table-hover, etc.) */
.table thead,
.table.list-table thead,
.list-table thead {
	background: var(--bg);
	border-bottom: 1px solid var(--border);
}

.table thead th,
.table.list-table thead th,
.list-table thead th {
	font-size: 10.5px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #495057;
	font-weight: 600;
	padding: 12px 16px;
	border-bottom: 2px solid var(--border);
}

.table tbody tr,
.table.list-table tbody tr,
.list-table tbody tr {
	border-bottom: 1px solid var(--border);
	transition: background 0.15s;
}

.table tbody tr:hover,
.table.list-table tbody tr:hover,
.list-table tbody tr:hover {
	background: var(--primary-ghost);
}

.table tbody td,
.table.list-table tbody td,
.list-table tbody td {
	font-size: 14px;
	padding: 13px 16px;
	color: var(--text-mid);
	vertical-align: middle;
	letter-spacing: 0.02em;
}

.table tbody td:last-child > div,
.table.list-table tbody td:last-child > div,
.list-table tbody td:last-child > div {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
}

/* ========== 5. FORMS & INPUTS ========== */
.form-control, .form-select, input[type="text"], input[type="email"], input[type="search"],
input[type="password"], input[type="number"], select, textarea {
	padding: 10px 14px;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 14px;
	color: var(--text-dark);
	background: var(--surface);
	font-family: "DM Sans", sans-serif;
	letter-spacing: 0.02em;
	transition: border-color 0.2s, box-shadow 0.2s;
	width: 100%;
}

/* Prevent select option text from being vertically cropped */
.form-select, select {
	min-height: 42px;
	line-height: 1.5;
	padding-top: 10px;
	padding-bottom: 10px;
}

.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
	border-color: var(--primary-light);
	box-shadow: 0 0 0 3px rgba(45, 122, 122, 0.12);
	outline: none;
}

.form-control.is-invalid, input.is-invalid {
	border-color: var(--danger);
	box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

label, .form-label {
	font-size: 12px;
	font-weight: 600;
	color: var(--text-mid);
	margin-bottom: 6px;
	display: block;
}

.mb-3.form-group, .form-group {
	margin-bottom: 18px;
}

/* ========== 6. BADGES & STATUS PILLS ========== */
.badge, .count-pill, .list-count-pill {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 10px;
	border-radius: 20px;
	font-size: 11px;
	font-weight: 600;
}

.badge.bg-success, .badge.text-bg-success { background: var(--success-soft) !important; color: var(--success) !important; }
.badge.bg-warning, .badge.text-bg-warning { background: var(--warning-soft) !important; color: var(--warning) !important; }
.badge.bg-danger, .badge.text-bg-danger { background: var(--danger-soft) !important; color: var(--danger) !important; }
.badge.bg-secondary, .badge.text-bg-secondary { background: var(--primary-ghost) !important; color: var(--primary) !important; }
.badge.bg-info, .badge.text-bg-info { background: var(--primary-ghost) !important; color: var(--primary) !important; }

.count-pill, .list-count-pill {
	font-size: 12px;
	color: var(--text-muted);
	background: var(--surface);
	border: 1px solid var(--border);
	padding: 4px 12px;
	border-radius: 20px;
	font-weight: 500;
}

/* ========== 7. ALERTS ========== */
.alert {
	border-radius: var(--radius-sm);
	padding: 12px 16px;
	font-size: 13px;
	display: flex;
	align-items: center;
	gap: 10px;
	transition: var(--transition);
}

.alert-success {
	background: var(--success-soft);
	border: 1px solid rgba(16, 185, 129, 0.3);
	color: #065f46;
}

.alert-danger, .text-danger.alert {
	background: var(--danger-soft);
	border: 1px solid rgba(229, 62, 62, 0.3);
	color: #991b1b;
}

.alert-warning {
	background: var(--warning-soft);
	border: 1px solid rgba(245, 158, 11, 0.3);
	color: #92400e;
}

.alert-info {
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	color: #1d4ed8;
}

.alert .btn-close {
	opacity: 0.7;
}

/* ========== 8. MODALS ========== */
.modal-content {
	border-radius: var(--radius);
	border: none;
	box-shadow: var(--shadow-lg);
	overflow: hidden;
}

.modal-header {
	padding: 18px 24px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
}

.modal-title {
	font-family: "DM Sans", sans-serif;
	font-size: 16px;
	font-weight: 700;
}

.modal-body {
	padding: 24px;
}

.modal-footer {
	padding: 14px 24px;
	border-top: 1px solid var(--border);
	background: var(--bg);
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

.modal-header .btn-close {
	width: 32px;
	height: 32px;
	border-radius: var(--radius-xs);
	border: 1px solid var(--border);
	background: var(--surface);
	opacity: 1;
	padding: 0;
}

.modal-header .btn-close:hover {
	border-color: var(--primary);
	background: var(--primary-ghost);
}

/* ========== 9. PAGE HEADERS ========== */
.page-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 24px;
}

.page-header h1 {
	margin-bottom: 0;
}

.page-subtitle {
	font-size: 13px;
	color: var(--text-muted);
	margin-top: 3px;
}

.page-header-actions {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* Match existing page title rows */
.d-flex.justify-content-between.align-items-center.mb-4,
.d-flex.flex-wrap.justify-content-between.align-items-center.gap-3.mb-4 {
	margin-bottom: 24px;
}

/* ========== 10. EMPTY STATES ========== */
.empty-state, .list-empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 72px 32px;
	gap: 12px;
	text-align: center;
}

.empty-icon, .list-empty-icon {
	width: 72px;
	height: 72px;
	border-radius: 20px;
	background: var(--bg);
	border: 1.5px dashed var(--border);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 26px;
	color: var(--text-muted);
}

.empty-state h3, .empty-state h2,
.list-empty-heading {
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--text-dark);
	margin: 0;
}

.empty-state p, .list-empty-text {
	font-size: 13px;
	color: var(--text-muted);
	margin: 0;
}

/* ========== 11. TOOLBAR ROWS ========== */
.toolbar, .list-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	margin-bottom: 16px;
	gap: 12px;
}

.search-box {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 9px 14px;
	background: var(--surface);
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	width: 280px;
	max-width: 100%;
}

.search-box input {
	border: none !important;
	outline: none !important;
	font-size: 13px;
	font-family: inherit;
	color: var(--text-dark);
	background: transparent !important;
	width: 100%;
	padding: 0 !important;
}

/* List toolbar search: visible input (border, background, padding) */
.list-toolbar .list-search-input.form-control {
	width: 100%;
	max-width: 280px;
	border: 1.5px solid var(--border) !important;
	outline: none;
	background: var(--surface) !important;
	color: var(--text-dark);
	font-size: 14px;
	font-family: inherit;
	padding: 10px 14px !important;
	border-radius: var(--radius-sm);
	min-height: 42px;
}

.list-toolbar .list-search-input.form-control::placeholder {
	color: var(--text-muted);
}

.list-toolbar .list-search-input.form-control:focus {
	border-color: var(--primary-light) !important;
	box-shadow: 0 0 0 3px rgba(45, 122, 122, 0.12);
}

.list-search-input.form-control {
	width: 100%;
}

.toolbar-right {
	display: flex;
	align-items: center;
	gap: 10px;
}


/* ========== 12. GLOBAL ========== */
body.container-fluid.bg-light,
body.bg-light,
body.container-fluid.bg-white {
	background: var(--bg) !important;
}

body.dashboard-body.dashboard-with-sidebar {
	background: var(--bg);
}

.card .bg-white, .quick-stat-card.bg-white {
	background: var(--surface) !important;
}

/* Detail field value */
.detail-field-value {
	font-size: 13px;
	color: var(--text-mid);
}

/* Welcome / dashboard specific */
.welcome-hero {
	background: linear-gradient(135deg, var(--primary-ghost) 0%, rgba(45, 122, 122, 0.04) 100%);
	border-color: var(--border);
}

.quick-stat-card {
	background: var(--surface) !important;
	border-color: var(--border);
}

.quick-stat-value {
	color: var(--text-dark);
}

.quick-stat-label {
	color: var(--text-muted);
	font-size: 12px;
}

/* Pref chip next number */
.pref-chip-next {
	color: var(--accent);
}

/* Security notice */
.security-notice {
	border-left: 4px solid #3b82f6;
}
