* { box-sizing: border-box; }
body { font-family: Segoe UI, Arial, sans-serif; margin: 0; background: #f4f6f8; color: #222; }

:root { --sidebar-width: 230px; --sidebar-collapsed-width: 64px; --topbar-height: 56px; }

/* Top bar */
.topbar { background: #1f2937; color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 16px; height: var(--topbar-height); position: fixed; top: 0; left: 0; right: 0; z-index: 30; }
.topbar.topbar-guest { justify-content: center; }
.topbar .brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.topbar .logout-form { margin-left: auto; }
.topbar .link-button { color: #d1d5db; background: none; border: none; cursor: pointer; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; }
.topbar .link-button:hover { color: #fff; }
.topbar .link-button svg { width: 16px; height: 16px; }

/* Burger button */
.burger-btn { background: none; border: none; cursor: pointer; padding: 8px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.burger-btn span { display: block; width: 20px; height: 2px; background: #fff; border-radius: 1px; }

/* Sidebar (AdminLTE-style) */
.sidebar { position: fixed; top: var(--topbar-height); left: 0; bottom: 0; width: var(--sidebar-width); background: #111827; overflow-y: auto; overflow-x: hidden; transition: width 0.2s ease, transform 0.2s ease; z-index: 25; }
.sidebar-links { display: flex; flex-direction: column; padding: 10px 0; }
.sidebar-links a { color: #d1d5db; text-decoration: none; padding: 12px 20px; font-size: 0.95rem; white-space: nowrap; border-left: 3px solid transparent; display: flex; align-items: center; gap: 12px; }
.sidebar-links a:hover { color: #fff; background: #1f2937; border-left-color: #2563eb; }
.sidebar-links a.active { color: #fff; background: #1f2937; border-left-color: #2563eb; font-weight: 600; }
.sidebar-links a svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Main content shifts to make room for the fixed sidebar/topbar when logged in */
body.has-sidebar .container { margin-top: calc(var(--topbar-height) + 24px); margin-left: calc(var(--sidebar-width) + 24px); transition: margin-left 0.2s ease; max-width: none; }
body.has-sidebar.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
body.has-sidebar.sidebar-collapsed .sidebar-links a { justify-content: center; padding: 14px 0; }
body.has-sidebar.sidebar-collapsed .sidebar-links a span { display: none; }
body.has-sidebar.sidebar-collapsed .container { margin-left: calc(var(--sidebar-collapsed-width) + 24px); }

.sidebar-overlay { display: none; }

/* Mobile: sidebar becomes an off-canvas drawer over the content */
@media (max-width: 900px) {
    body.has-sidebar .container { margin-left: 24px; }
    body.has-sidebar.sidebar-collapsed .container { margin-left: 24px; }
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-links a { justify-content: flex-start !important; padding: 12px 20px !important; }
    body.sidebar-open .sidebar-links a span { display: inline !important; }
    body.sidebar-open .sidebar-overlay { display: block; position: fixed; inset: 0; top: var(--topbar-height); background: rgba(0,0,0,0.4); z-index: 20; }
}

.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.alert { padding: 10px 16px; border-radius: 4px; margin-bottom: 16px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger { background: #fee2e2; color: #991b1b; }
table { width: 100%; border-collapse: collapse; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #e5e7eb; }
th { background: #f9fafb; }
.btn { display: inline-block; padding: 8px 14px; background: #2563eb; color: #fff; border-radius: 4px; text-decoration: none; border: none; cursor: pointer; font-size: 0.9rem; }
.btn-secondary { background: #6b7280; }
.btn-danger { background: #dc2626; }
.card { background: #fff; padding: 20px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; padding: 18px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); text-align: center; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: #2563eb; }
form.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
form.inline-form label { display: flex; flex-direction: column; font-size: 0.85rem; color: #444; }
input, select { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 4px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 0.9rem; }
.text-danger { color: #dc2626; font-size: 0.85rem; }
.login-box { max-width: 380px; margin: 60px auto; }

/* Dashboard quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-bottom: 24px; }
.quick-action { background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); padding: 18px 10px; text-align: center; text-decoration: none; color: #222; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: transform 0.1s ease, box-shadow 0.1s ease; }
.quick-action:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.12); }
.quick-action .icon-circle { width: 42px; height: 42px; border-radius: 50%; background: #eef2ff; color: #2563eb; display: flex; align-items: center; justify-content: center; }
.quick-action .icon-circle svg { width: 22px; height: 22px; }
.quick-action span { font-size: 0.85rem; font-weight: 600; }

/* Dashboard alert list */
.dash-alerts { list-style: none; padding: 0; margin: 0; }
.dash-alerts li { padding: 10px 0; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dash-alerts li:last-child { border-bottom: none; }
.dash-alerts .badge { background: #fee2e2; color: #991b1b; border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.dash-alerts .badge.ok { background: #d1fae5; color: #065f46; }
.dashboard-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* Searchable combobox (employee picker, etc.) */
.combo { position: relative; }
.combo input[type="text"] { width: 100%; }
.combo-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #d1d5db; border-radius: 4px; max-height: 240px; overflow-y: auto; z-index: 40; box-shadow: 0 4px 10px rgba(0,0,0,0.12); margin-top: 2px; }
.combo-dropdown.show { display: block; }
.combo-option { padding: 8px 10px; cursor: pointer; font-size: 0.9rem; }
.combo-option:hover, .combo-option.highlighted { background: #eef2ff; }
.combo-option .en { font-weight: 500; }
.combo-option .ar { color: #666; margin-left: 6px; }
.combo-option .type { color: #999; font-size: 0.8em; display: block; }
.combo-empty { padding: 8px 10px; color: #999; font-size: 0.85rem; }
