/*
 * app.css — Weldmation authenticated shell
 *
 * Loaded after bootstrap.min.css, app.min.css, icons.min.css so the
 * declarations below win. The --wm-* palette + component classes mirror
 * the public landing (public/assets/css/landing.css) so the two surfaces
 * read as one product.
 */

:root {
    /* Palette — copied verbatim from landing.css lines 12-26 */
    --wm-navy: #071827;
    --wm-navy-soft: #10283a;
    --wm-graphite: #1b2d3c;
    --wm-ink: #122433;
    --wm-copy: #405363;
    --wm-muted: #647583;
    --wm-line: #dce3e8;
    --wm-mist: #f3f6f8;
    --wm-paper: #ffffff;
    --wm-accent: #c4451a;
    --wm-accent-dark: #9f3511;
    --wm-accent-bright: #ff7a3d;
    --wm-accent-soft: #fff0e8;
    --wm-shadow: 0 24px 70px rgba(7, 24, 39, 0.12);
    --wm-radius: 18px;
}

:root {
    color-scheme: light;
}

/* Bootstrap variable overrides — affect every .btn, .text-*, .table, .form-* the modules already use. */
:root,
[data-bs-theme="light"] {
    --bs-primary: var(--wm-accent);
    --bs-primary-rgb: 196, 69, 26;
    --bs-primary-bg-subtle: var(--wm-accent-soft);
    --bs-primary-border-subtle: var(--wm-accent-soft);
    --bs-body-color: var(--wm-ink);
    --bs-body-color-rgb: 18, 36, 51;
    --bs-body-bg: var(--wm-paper);
    --bs-secondary-color: var(--wm-muted);
    --bs-tertiary-color: var(--wm-muted);
    --bs-border-color: var(--wm-line);
    --bs-link-color: var(--wm-navy);
    --bs-link-color-rgb: 7, 24, 39;
    --bs-link-hover-color: var(--wm-accent);
    --bs-link-hover-color-rgb: 196, 69, 26;
    --bs-heading-color: var(--wm-navy);
}

html {
    overflow-x: clip;
    scroll-behavior: smooth;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    color: var(--wm-ink);
    background: var(--wm-mist);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

::selection {
    background: var(--wm-accent);
    color: var(--wm-paper);
}

:focus-visible {
    border-radius: 5px;
    outline: 3px solid var(--wm-accent);
    outline-offset: 3px;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    text-underline-offset: 0.22em;
}

/* Skip link (a11y) */
.wm-skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2000;
    min-height: 44px;
    padding: 10px 18px;
    transform: translateY(-140%);
    border-radius: 6px;
    background: var(--wm-paper);
    box-shadow: var(--wm-shadow);
    color: var(--wm-navy);
    font-weight: 700;
    text-decoration: none;
    transition: transform 180ms ease-out;
}

.wm-skip-link:focus {
    transform: translateY(0);
}

/* ===== Topbar ===== */
.wm-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: 72px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(7, 24, 39, 0.08);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.wm-header__brand img {
    display: block;
    width: 132px;
    height: auto;
}

.wm-header__spacer {
    flex: 1 1 auto;
}

.wm-header__user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border: 1px solid var(--wm-line);
    border-radius: 999px;
    background: var(--wm-paper);
    color: var(--wm-ink);
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 180ms ease-out, color 180ms ease-out;
}

.wm-header__user:hover,
.wm-header__user:focus-visible {
    border-color: var(--wm-accent);
    color: var(--wm-accent);
}

.wm-header__user .name {
    color: var(--wm-navy);
    font-weight: 800;
}

.wm-header__user .profile {
    display: block;
    color: var(--wm-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.wm-header__user-avatar {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wm-navy);
    color: var(--wm-paper);
    font-weight: 800;
    font-size: 0.85rem;
}

.wm-header__user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

@media (max-width: 575.98px) {
    .wm-header { padding: 0 14px; min-height: 64px; }
    .wm-header__brand img { width: 108px; }
    .wm-header__user .name,
    .wm-header__user .profile { display: none; }
}

/* ===== Sidebar ===== */
.wm-sidebar {
    width: 264px;
    flex: 0 0 264px;
    min-height: calc(100vh - 0px);
    background: var(--wm-paper);
    border-right: 1px solid var(--wm-line);
    padding: 20px 0;
}

.wm-sidebar__brand {
    display: block;
    padding: 6px 24px 26px;
}

.wm-sidebar__brand img {
    display: block;
    width: 132px;
    height: auto;
}

.wm-sidebar__nav {
    list-style: none;
    margin: 0;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wm-sidebar__title {
    margin: 18px 16px 8px;
    color: var(--wm-muted);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.wm-sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--wm-ink);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background-color 180ms ease-out, color 180ms ease-out;
}

.wm-sidebar__link i {
    color: var(--wm-muted);
    font-size: 1.15rem;
    transition: color 180ms ease-out;
}

.wm-sidebar__link:hover,
.wm-sidebar__link:focus-visible {
    background: var(--wm-mist);
    color: var(--wm-navy);
}

.wm-sidebar__link:hover i,
.wm-sidebar__link:focus-visible i {
    color: var(--wm-accent);
}

.wm-sidebar__link.is-active {
    background: var(--wm-navy);
    color: var(--wm-paper);
}

.wm-sidebar__link.is-active i {
    color: var(--wm-accent-bright);
}

@media (max-width: 991.98px) {
    .wm-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform 220ms ease-out;
        overflow-y: auto;
    }
    .wm-sidebar.is-open { transform: translateX(0); }
}

/* ===== Layout shell — wires header, sidebar and page-content together ===== */
.wm-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - 72px);
}

.wm-shell__main {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--wm-mist);
}

/* ===== Page title bar ===== */
.wm-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 24px 28px;
    background: var(--wm-paper);
    border-bottom: 1px solid var(--wm-line);
}

.wm-page-header__eyebrow {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 0;
    color: var(--wm-accent);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.wm-page-header__eyebrow > span {
    width: 30px;
    height: 2px;
    flex: 0 0 30px;
    background: currentColor;
}

.wm-page-header__title {
    margin: 6px 0 0;
    color: var(--wm-navy);
    font-size: clamp(1.4rem, 2.4vw, 1.85rem);
    font-weight: 780;
    letter-spacing: -0.025em;
    line-height: 1.1;
}

.wm-page-header__actions {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

/* ===== Card + content area ===== */
.wm-card {
    background: var(--wm-paper);
    border: 1px solid var(--wm-line);
    border-radius: var(--wm-radius);
    box-shadow: 0 1px 2px rgba(7, 24, 39, 0.04);
}

.wm-page-content {
    padding: 28px;
}

@media (max-width: 575.98px) {
    .wm-page-header,
    .wm-page-content { padding-left: 18px; padding-right: 18px; }
}

/* ===== Buttons (used inline where we want a guaranteed CTA) ===== */
.wm-button {
    display: inline-flex;
    min-width: 44px;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 21px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.91rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    transition: transform 180ms ease-out, box-shadow 180ms ease-out, background-color 180ms ease-out, border-color 180ms ease-out, color 180ms ease-out;
}

@media (hover: hover) {
    .wm-button:hover { transform: translateY(-2px); box-shadow: 0 15px 32px rgba(7, 24, 39, 0.18); }
    .wm-button--primary:hover { background: var(--wm-accent-dark); }
    .wm-button--ghost:hover {
        border-color: var(--wm-navy);
        background: var(--wm-navy);
        color: var(--wm-paper);
    }
    .wm-button--dark:hover { background: var(--wm-graphite); }
}

.wm-button--primary {
    background: var(--wm-accent);
    color: var(--wm-paper);
    box-shadow: 0 14px 30px rgba(196, 69, 26, 0.22);
}

.wm-button--ghost {
    background: transparent;
    border-color: rgba(7, 24, 39, 0.2);
    color: var(--wm-navy);
}

.wm-button--dark {
    background: var(--wm-navy);
    color: var(--wm-paper);
}

.wm-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== Bootstrap button skin for existing module views =====
   `.btn-primary` shows in the new accent color via the variable override
   above; this keeps `.btn-success` (used by login) and a couple of
   decorative knobs coherent with the palette. */
.btn-success {
    --bs-btn-bg: var(--wm-navy);
    --bs-btn-border-color: var(--wm-navy);
    --bs-btn-hover-bg: var(--wm-graphite);
    --bs-btn-hover-border-color: var(--wm-graphite);
    --bs-btn-active-bg: var(--wm-graphite);
    --bs-btn-active-border-color: var(--wm-graphite);
    --bs-btn-color: var(--wm-paper);
    --bs-btn-hover-color: var(--wm-paper);
    --bs-btn-active-color: var(--wm-paper);
    --bs-btn-disabled-bg: var(--wm-navy);
    --bs-btn-disabled-border-color: var(--wm-navy);
    --bs-btn-disabled-color: var(--wm-paper);
}

.btn-secondary {
    --bs-btn-bg: var(--wm-paper);
    --bs-btn-border-color: var(--wm-line);
    --bs-btn-color: var(--wm-ink);
    --bs-btn-hover-bg: var(--wm-mist);
    --bs-btn-hover-border-color: var(--wm-line);
    --bs-btn-hover-color: var(--wm-navy);
}

/* ===== Form controls (used inside login.php) ===== */
.wm-input {
    display: block;
    width: 100%;
    min-height: 50px;
    padding: 12px 16px;
    border: 1px solid var(--wm-line);
    border-radius: 8px;
    background: var(--wm-paper);
    color: var(--wm-ink);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 180ms ease-out, box-shadow 180ms ease-out;
}

.wm-input:focus {
    border-color: var(--wm-accent);
    outline: none;
    box-shadow: 0 0 0 4px rgba(196, 69, 26, 0.16);
}

.wm-label {
    display: block;
    margin-bottom: 6px;
    color: var(--wm-ink);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ===== Tables (used in CRUD views via DataTables) =====
   Subtle: header row navy, hover mist, hairline borders. */
.table {
    --bs-table-color: var(--wm-ink);
    --bs-table-bg: var(--wm-paper);
    --bs-table-border-color: var(--wm-line);
    --bs-table-hover-bg: var(--wm-mist);
    --bs-table-hover-color: var(--wm-navy);
    --bs-table-striped-bg: var(--wm-paper);
}

.table thead th {
    background: var(--wm-navy);
    color: var(--wm-paper);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: none;
}

/* Pagination + DataTables controls also benefit from the token override */

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
.chosen-container-single .chosen-single {
    border: 1px solid var(--wm-line) !important;
    border-radius: 8px !important;
    color: var(--wm-ink);
}

/* ===== Velzon layout class recoloring =====
   These classes are still emitted by module views (e.g. #layout-wrapper,
   #page-topbar). We don't change the markup; we just rewrite the visible
   chrome to the landing palette so existing pages read coherent. */
#page-topbar {
    display: none; /* replaced by .wm-header */
}

#layout-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    min-height: 100vh;
    background: var(--wm-mist);
}

/* Header takes its own row, full width, sits above the body row. */
#layout-wrapper > .wm-header {
    flex: 0 0 100%;
    width: 100%;
}

/* Desktop layout: sidebar is a fixed-width flex column to the left of main. */
@media (min-width: 992px) {
    #layout-wrapper > .wm-sidebar {
        flex: 0 0 264px;
        width: 264px;
        align-self: stretch;
    }
    #layout-wrapper > .main-content {
        flex: 1 1 0;
        min-width: 0;
        align-self: stretch;
    }
}

/* On narrow viewports the sidebar is off-canvas (see @media max-width:991
   above). Zero its flex space so main-content fills the row instead of
   being pushed off-screen. */
@media (max-width: 991.98px) {
    #layout-wrapper > .wm-sidebar { flex: 0 0 0; width: 0; min-width: 0; }
    #layout-wrapper > .main-content { flex: 1 1 100%; width: 100%; }
}

.app-menu.navbar-menu {
    /* Hide the legacy sidebar markup — replaced by .wm-sidebar.
       We render both so a partial-rebuild doesn't strand the user. */
    display: none;
}

.vertical-overlay {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(7, 24, 39, 0.4);
    display: none;
}

.vertical-overlay.is-open { display: block; }

.page-content {
    padding: 0;
    background: transparent;
}

.main-content {
    margin-left: 0;
}

.footer {
    padding: 22px 28px;
    background: var(--wm-paper);
    border-top: 1px solid var(--wm-line);
    color: var(--wm-muted);
    font-size: 0.85rem;
}

#sidebar-menu,
#two-column-menu {
    display: none !important;
}

.sidebar-background {
    display: none;
}

/* ===== Login (body.wm-auth) ===== */
body.wm-auth {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background:
        radial-gradient(ellipse at top right, rgba(196, 69, 26, 0.18), transparent 60%),
        linear-gradient(140deg, var(--wm-navy) 0%, var(--wm-navy-soft) 60%, var(--wm-graphite) 100%);
    color: var(--wm-paper);
}

body.wm-auth .wm-auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px 36px;
    background: var(--wm-paper);
    border-radius: var(--wm-radius);
    box-shadow: var(--wm-shadow);
    color: var(--wm-ink);
}

body.wm-auth .wm-auth-brand {
    display: block;
    width: 132px;
    margin: 0 auto 24px;
}

body.wm-auth .wm-auth-title {
    margin: 0 0 6px;
    color: var(--wm-navy);
    font-size: 1.6rem;
    font-weight: 780;
    letter-spacing: -0.025em;
    text-align: center;
}

body.wm-auth .wm-auth-sub {
    margin: 0 0 28px;
    color: var(--wm-muted);
    font-size: 0.92rem;
    text-align: center;
}

body.wm-auth .wm-form-field { margin-bottom: 16px; }

body.wm-auth .wm-auth-foot {
    margin-top: 18px;
    color: var(--wm-muted);
    font-size: 0.86rem;
    text-align: center;
}

body.wm-auth .wm-auth-foot a {
    color: var(--wm-navy);
    font-weight: 700;
    text-decoration: none;
}

body.wm-auth .wm-auth-foot a:hover { color: var(--wm-accent); }

body.wm-auth .wm-auth-copyright {
    margin-top: 28px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.78rem;
    text-align: center;
}

body.wm-auth .wm-auth-error {
    margin-bottom: 18px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #fdecea;
    color: #7a1f12;
    border: 1px solid #f6c1b8;
    font-size: 0.88rem;
}

body.wm-auth .wm-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: var(--wm-paper);
    border-radius: 50%;
    animation: wm-spin 0.8s linear infinite;
    vertical-align: -2px;
}

@keyframes wm-spin {
    to { transform: rotate(360deg); }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
