/* ==========================================================
   Employee Portal - shared stylesheet
   ========================================================== */

:root {
    --primary: #dc2626;
    --primary-dark: #b91c1c;
    --success: #16a34a;
    --success-dark: #15803d;
    --danger: #44403c;
    --danger-dark: #292524;
    --bg: #fdf7f4;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

/* ---------- Top bar ---------- */
header {
    background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 100%);
    color: #fff;
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(127, 29, 29, 0.25);
}
header strong { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; }
header span { font-size: 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
header a {
    color: #fee2e2;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
header a:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

/* ---------- Layout ---------- */
main {
    max-width: 1100px;
    margin: 28px auto;
    padding: 0 20px;
}

.box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.box h2 {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

/* Flex row for simple forms (add employee, add item, date filter) */
.inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* ---------- Messages ---------- */
.msg {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: 500;
}

/* ---------- Form controls ---------- */
.box form:not(.inline) > label + input[type="password"] {
    display: block;
    width: 100%;
    max-width: 360px;
    margin: 0 0 16px;
}
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"] {
    font: inherit;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 0;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.inline input[type="text"],
.inline input[type="password"],
.inline input[type="number"] { min-width: 170px; }

button,
.btn {
    font: inherit;
    font-weight: 600;
    padding: 10px 18px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.15s, transform 0.05s;
}
button:hover,
.btn:hover { background: var(--primary-dark); }
button:active,
.btn:active { transform: translateY(1px); }

button.small,
a.small {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    background: #e2e8f0;
    color: #334155;
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
}
button.small:hover,
a.small:hover { background: #cbd5e1; }

.btn.excel { background: var(--success); }
.btn.excel:hover { background: var(--success-dark); }
.btn.pdf { background: var(--danger); }
.btn.pdf:hover { background: var(--danger-dark); }

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}
th {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: #f8fafc;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
}
td {
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
tr:hover td { background: #fafbff; }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }

.right { text-align: right; }

input.qty {
    width: 90px;
    text-align: center;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}
.on { background: #16a34a; }
.off { background: #dc2626; }

/* ---------- Totals ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.grid input { width: 100%; }

.total,
.grand {
    font-size: 22px;
    font-weight: 700;
    text-align: right;
    margin-top: 18px;
    color: var(--text);
}
.total span,
.grand span { color: var(--primary); }

/* ---------- Login page ---------- */
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 60%, #f97316 100%);
    padding: 20px;
}
.card {
    background: #fff;
    width: 100%;
    max-width: 380px;
    padding: 40px 34px 34px;
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
}
.card h2 {
    text-align: center;
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}
.card::before {
    content: "Sign in to continue";
    display: block;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 26px;
}
.card form input[type="text"],
.card form input[type="password"] {
    display: block;
    width: 100%;
    margin-bottom: 18px;
}
.card button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: 4px;
}
.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    header { padding: 14px 16px; }
    main { padding: 0 12px; margin-top: 18px; }
    .box { padding: 16px; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
    .inline input[type="text"],
    .inline input[type="password"],
    .inline input[type="number"] { min-width: 0; width: 100%; }
}

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; }
.brand img { height: 42px; width: auto; border-radius: 10px; background: #fff; padding: 2px; }
.login-logo { display: block; height: 120px; width: auto; margin: 0 auto 10px; }

/* ---------- Left sidebar layout ---------- */
body:not(.login-page) { display: flex; min-height: 100vh; align-items: stretch; }
body:not(.login-page) > main { flex: 1; min-width: 0; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    background: linear-gradient(180deg, #7f1d1d 0%, #b91c1c 100%);
    color: #fff;
    box-shadow: 4px 0 18px rgba(127, 29, 29, 0.18);
}
.sidebar .brand { color: #fff; margin: 0 6px 4px; }
.sidebar .brand img { height: 46px; }
.sidebar .brand span { font-size: 17px; line-height: 1.2; }

.role-label {
    margin: 26px 12px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.7;
}

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
    color: #fde2e2;
    text-decoration: none;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.sidebar nav a.active { background: #fff; color: #b91c1c; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }

.sidebar-foot {
    margin-top: auto;
    padding: 16px 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 14px;
}
.sidebar-foot .who { font-weight: 700; }
.sidebar-foot small { opacity: 0.75; }
.sidebar-foot a {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}
.sidebar-foot a:hover { background: rgba(255, 255, 255, 0.25); }

@media (max-width: 900px) {
    body:not(.login-page) { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        padding: 14px 16px;
    }
    .role-label { display: none; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-foot { margin-top: 0; margin-left: auto; padding: 0; border: 0; display: flex; align-items: center; gap: 10px; }
    .sidebar-foot a { margin-top: 0; }
    .sidebar-foot small, .sidebar-foot br { display: none; }
}

/* ---------- Filters & selects ---------- */
select {
    font: inherit;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    min-width: 220px;
    outline: none;
}
select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15); }
.filters .field { display: flex; flex-direction: column; gap: 6px; }
.filters .field label { margin: 0; }
.filters { align-items: flex-end; }

/* ---------- Responsive refinements ---------- */
.box { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
    body:not(.login-page) > main {
        width: 100%;
        margin: 22px auto;
        padding: 0 18px;
    }
}

@media (max-width: 720px) {
    /* Tables scroll inside their box instead of squashing */
    table { display: table; white-space: normal; min-width: 600px; }
    th, td { padding: 9px 8px; }
    input.qty { width: 80px; }

    .box { padding: 16px; border-radius: 10px; }
    .box h2 { font-size: 16px; }

    /* Stack filter and form rows vertically */
    .inline { flex-direction: column; align-items: stretch; }
    .inline input,
    .inline select,
    .inline button,
    .inline .btn,
    .filters .field { width: 100%; }
    .inline input,
    .inline select { min-width: 0; }
    .filters .field { display: flex; }

    .grid { grid-template-columns: 1fr; gap: 12px; }
    .grand,
    .total { font-size: 18px; text-align: left; }

    .sidebar { padding: 12px 14px; }
    .sidebar .brand img { height: 36px; }
    .sidebar .brand span { font-size: 15px; }
    .sidebar nav a { padding: 8px 12px; font-size: 14px; }

    .card { padding: 28px 22px; }
    .login-logo { height: 96px; }
}

@media (max-width: 420px) {
    body { font-size: 14px; }
    .box { padding: 14px; }
    .sidebar nav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
    .sidebar nav a { text-align: center; }
    .sidebar-foot { width: 100%; justify-content: space-between; }
    .sidebar-foot a { margin-top: 0; }
}

/* ---------- Roles, permissions and expenses ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table.matrix th, table.matrix td { min-width: 110px; }
th.center, td.center { text-align: center; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.85; }
.muted { color: var(--muted); }
.hint { color: var(--muted); margin: 0 0 14px; }
.form-foot { margin-top: 14px; }
.box .table-scroll + .form-foot { margin-top: 14px; }
.right.form-foot { text-align: right; }
select { max-width: 100%; }

@media (max-width: 720px) {
    table.matrix th, table.matrix td { min-width: 90px; }
    .form-foot button { width: 100%; }
}
