/* ==========================================================================
   HRD Service Portal — base theme
   Cobalt + cool neutrals, Plus Jakarta Sans (loaded in partials/header.php).
   Page-specific styles stay in each page; this file sets the shared base.
   ========================================================================== */

:root {
    --ink: #141a2e;
    --ink-2: #2b3247;
    --muted: #5d6479;
    --faint: #a0a6b8;
    --line: #e3e6ee;
    --line-strong: #d3d7e2;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --header: #100ea0;
    --brand: #2422b8;
    --brand-dark: #17159a;
    --brand-soft: #ececfd;
    --brand-tint: #f6f6fe;
    --ok: #127a4a;
    --ok-soft: #e6f6ee;
    --danger: #b4232c;
    --danger-soft: #fdecec;
    --warn: #8a4b00;
    --warn-soft: #fff4dc;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(20, 26, 46, .04), 0 4px 16px rgba(20, 26, 46, .05);
    --focus: 0 0 0 3px rgba(36, 34, 184, .22);
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--ink); letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16.5px; font-weight: 700; }
h4 { font-size: 14px; font-weight: 700; }
a { color: var(--brand); text-underline-offset: 2px; }
code { font-size: .92em; background: var(--brand-tint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
::selection { background: rgba(36, 34, 184, .16); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Top bar — brand blue, matches the SP Manufacturing logo
   -------------------------------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; justify-content: space-between; align-items: center; gap: 20px;
    min-height: 68px; padding: 10px 28px;
    background: var(--header);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 4px 18px rgba(16, 14, 160, .18);
}
.topbar__brand { display: flex; align-items: center; white-space: nowrap; }
.topbar__home {
    display: flex; align-items: center; gap: 14px;
    color: #fff; text-decoration: none;
}
.topbar__logo { display: block; height: 42px; width: auto; }
.topbar__title {
    padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .28);
    font-weight: 700; font-size: 15px; letter-spacing: -.005em; color: #fff;
}
.topbar__nav {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end;
    font-size: 14px;
}
.topbar__nav > a,
.navdrop__toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px; border-radius: 999px;
    color: rgba(255, 255, 255, .82); font-weight: 600; text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}
.topbar__nav > a:hover,
.navdrop:hover .navdrop__toggle { background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; }
.topbar__nav > a.is-active,
.navdrop__toggle.is-active { background: #fff; color: var(--header); }
.navdrop:hover .navdrop__toggle.is-active { background: #fff; color: var(--header); }
.topbar__nav > a[href$="/logout.php"] {
    margin-left: 4px; border: 1px solid rgba(255, 255, 255, .35); color: #fff;
}
.topbar__nav > a[href$="/logout.php"]:hover { background: #fff; color: var(--header); border-color: #fff; }
.topbar__user {
    margin-left: 10px; padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .25);
    color: rgba(255, 255, 255, .75); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.topbar :focus-visible { outline-color: #fff; }

/* Dropdown nav items */
.navdrop { position: relative; }
.navdrop__toggle { cursor: pointer; user-select: none; }
.navdrop__caret {
    width: 0; height: 0; display: inline-block;
    border-left: 4px solid transparent; border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform .15s ease;
}
.navdrop__menu {
    display: none;
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 200;
    min-width: 210px; padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(20, 26, 46, .12);
}
/* invisible bridge so the menu doesn't close while moving the mouse into it */
.navdrop::after { content: ""; position: absolute; top: 100%; left: 0; width: 100%; height: 12px; }
.navdrop__menu a {
    display: block; padding: 8px 12px; border-radius: var(--radius-sm);
    color: var(--ink-2) !important; font-size: 14px; font-weight: 500;
    text-decoration: none; white-space: nowrap;
}
.navdrop__menu a:hover { background: var(--bg); text-decoration: none !important; }
.navdrop__menu a.is-active { background: var(--brand-soft); color: var(--brand) !important; font-weight: 600; }
.navdrop:hover .navdrop__menu,
.navdrop:focus-within .navdrop__menu { display: block; }
.navdrop:hover .navdrop__caret { transform: rotate(180deg); }

/* --------------------------------------------------------------------------
   Layout + surfaces
   -------------------------------------------------------------------------- */
.container { max-width: 1600px; margin: 28px auto; padding: 0 32px 56px; }
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
a.card { transition: border-color .15s ease, box-shadow .15s ease; }
a.card:hover { border-color: #d7d6f8; box-shadow: 0 8px 24px rgba(36, 34, 184, .10); }

/* Alerts */
.alert {
    position: relative;
    padding: 12px 16px 12px 40px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    margin-bottom: 16px; font-size: 14px; font-weight: 500;
}
.alert::before {
    content: ""; position: absolute; left: 16px; top: 17px;
    width: 10px; height: 10px; border-radius: 50%;
    background: currentColor;
}
.alert--error { background: var(--danger-soft); color: var(--danger); border-color: #f6cdcd; }
.alert--success { background: var(--ok-soft); color: var(--ok); border-color: #bfe6d0; }
.alert--warning { background: var(--warn-soft); color: var(--warn); border-color: #f5dea6; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
input[type=text], input[type=password], input[type=date], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit; font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input[type=number], input[type=search], input[type=email], input[type=time] {
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: var(--focus);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--brand); color: #fff;
    border: none; border-radius: 10px;
    padding: 10px 18px;
    font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, box-shadow .15s ease;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn--ghost {
    background: var(--surface); color: var(--brand);
    border: 1px solid var(--line-strong);
}
.btn--ghost:hover { background: var(--brand-soft); border-color: #d7d6f8; color: var(--brand); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
th {
    background: var(--brand-tint);
    color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .01em;
    border-bottom-color: var(--line-strong);
}

/* Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.5;
}
.badge--baru { background: var(--ok-soft); color: var(--ok); }
.badge--lama { background: var(--brand-soft); color: var(--brand); }
.badge--pending { background: var(--warn-soft); color: var(--warn); }
.badge--approved { background: var(--ok-soft); color: var(--ok); }
.badge--rejected { background: var(--danger-soft); color: var(--danger); }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
.auth {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    gap: 56px; align-items: center;
    max-width: 980px; margin: 6vh auto 0;
}
.auth__intro h1 { font-size: 40px; line-height: 1.08; margin: 18px 0 12px; letter-spacing: -.03em; }
.auth__intro p { color: var(--muted); font-size: 16px; max-width: 36ch; margin: 0; }
.auth__logo { display: block; height: 76px; width: auto; }
.auth__card { padding: 30px; margin: 0; }
.auth__card h2 { margin: 0 0 4px; font-size: 22px; }
.auth__sub { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.auth__check {
    display: flex; align-items: center; gap: 8px;
    margin-top: 12px; font-weight: 500; font-size: 13.5px; color: var(--muted); cursor: pointer;
}
.auth__check input { width: auto; margin: 0; }
.auth__submit { width: 100%; margin-top: 22px; padding: 12px 18px; font-size: 15px; }
.auth__forms { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.auth__forms p { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.auth__links { display: flex; gap: 10px; flex-wrap: wrap; }
.auth__links .btn { flex: 1; min-width: 150px; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.app-footer {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    display: flex; justify-content: flex-end; align-items: center;
    padding: 8px 28px;
    background: rgba(255, 255, 255, .9);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    color: var(--faint); font-size: 11px; letter-spacing: .01em;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .topbar { position: static; flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; }
    .topbar__logo { height: 36px; }
    .topbar__nav { justify-content: flex-start; }
    .topbar__user { margin-left: 0; padding-left: 0; border-left: none; width: 100%; order: -1; }
    .container { padding: 0 16px 56px; margin-top: 18px; }
    .card { padding: 18px; }
    .auth { grid-template-columns: 1fr; gap: 24px; margin-top: 2vh; }
    .auth__intro h1 { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
    .topbar { box-shadow: none; }
    .app-footer { display: none !important; }
    body { background: #fff !important; }
}
