/* ============================================================
   euContract – Global Stylesheet
   ============================================================ */

:root {
    --brand:        #1a3a5c;
    --brand-light:  #2255a4;
    --brand-hover:  rgba(255,255,255,.1);
    --surface:      #f0f2f5;
    --card-border:  #dde3ec;
    --text-primary: #1a2b4a;
    --text-muted:   #6b7a99;
}

/* ── Base ───────────────────────────────────────────────── */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--surface);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: #2d3748;
}

main.content {
    flex: 1;
}

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
    background-color: var(--brand);
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    padding-top: .6rem;
    padding-bottom: .6rem;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff !important;
    letter-spacing: .02em;
    display: flex;
    align-items: center;
    gap: .45rem;
}

.navbar-brand img {
    max-height: 40px;
    width: auto;
}

.navbar .nav-link {
    color: rgba(255,255,255,.82) !important;
    font-size: .875rem;
    padding: .4rem .8rem !important;
    border-radius: 5px;
    transition: background .15s, color .15s;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus,
.navbar .nav-link.active {
    color: #fff !important;
    background-color: var(--brand-hover);
}

.navbar .dropdown-menu {
    border: 1px solid var(--card-border);
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
    border-radius: 8px;
    min-width: 190px;
    font-size: .875rem;
    padding: .35rem;
}

.navbar .dropdown-item {
    border-radius: 5px;
    padding: .45rem .85rem;
    transition: background .12s;
}

.navbar .dropdown-item:hover {
    background-color: #eef2ff;
}

/* ── Nested dropdown (submenu) ──────────────────────────── */
.navbar .dropdown-submenu {
    position: relative;
}

.navbar .dropdown-submenu > a::after {
    content: "";
    display: inline-block;
    margin-left: .5em;
    vertical-align: middle;
    border-top: .3em solid transparent;
    border-bottom: .3em solid transparent;
    border-left: .3em solid;
}

.navbar .dropdown-submenu > .dropdown-menu {
    display: none;
}

.navbar .dropdown-submenu.show > .dropdown-menu {
    display: block;
}

@media (min-width: 992px) {
    .navbar .dropdown-submenu > .dropdown-menu {
        top: 0;
        left: 100%;
        margin-top: -.35rem;
    }

    /* Parent menu is right-aligned (dropdown-menu-end) — flyout to the left instead,
       otherwise the submenu renders off the right edge of the viewport. */
    .navbar .dropdown-menu-end .dropdown-submenu > .dropdown-menu {
        left: auto;
        right: 100%;
    }

    .navbar .dropdown-submenu:hover > .dropdown-menu {
        display: block;
    }
}

@media (max-width: 991.98px) {
    .navbar .dropdown-submenu > .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        margin-left: .75rem;
        padding-left: .5rem;
        border-left: 2px solid var(--card-border);
    }
}

.navbar-toggler {
    border-color: rgba(255,255,255,.3);
}
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ── Page Header ────────────────────────────────────────── */
.page-header {
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 0;
    margin-bottom: 0;
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-header .breadcrumb {
    margin-bottom: .25rem;
}

.page-header .breadcrumb-item,
.page-header .breadcrumb-item a {
    font-size: .8rem;
    color: var(--text-muted);
    text-decoration: none;
}

.page-header .breadcrumb-item a:hover {
    color: var(--brand-light);
}

.page-header .breadcrumb-item.active {
    color: var(--text-primary);
}

.page-header .breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-muted);
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    background: #fff;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    font-weight: 600;
    color: var(--text-primary);
    font-size: .9rem;
    padding: .85rem 1.25rem;
    border-radius: 10px 10px 0 0 !important;
}

/* Stat / icon cards on Dashboard */
.stat-card {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: #fff;
    padding: 1.5rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    transition: box-shadow .18s, transform .18s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    transform: translateY(-2px);
    color: inherit;
}

.stat-card .icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.stat-card h6 {
    font-weight: 700;
    font-size: .9rem;
    color: var(--text-primary);
    margin-bottom: .25rem;
}

.stat-card p {
    font-size: .8rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

/* ── Tables ─────────────────────────────────────────────── */
.table {
    font-size: .875rem;
    color: #2d3748;
}

.table thead th {
    background-color: #f7f9fc;
    color: var(--text-primary);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 2px solid var(--card-border);
    white-space: nowrap;
    padding: .75rem 1rem;
}

.table tbody td {
    padding: .7rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f2f5;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover td {
    background-color: #f7f9fc;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    font-size: .875rem;
    border-radius: 6px;
    font-weight: 500;
}

.btn-primary {
    background-color: var(--brand-light);
    border-color: var(--brand-light);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #1a4a8a;
    border-color: #1a4a8a;
}

.btn-sm {
    font-size: .8rem;
    padding: .3rem .7rem;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-control,
.form-select {
    border-color: #cbd5e0;
    border-radius: 6px;
    font-size: .875rem;
    color: #2d3748;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-light);
    box-shadow: 0 0 0 .2rem rgba(34,85,164,.15);
}

.form-label {
    color: var(--text-primary);
}

.form-check-input:checked {
    background-color: var(--brand-light);
    border-color: var(--brand-light);
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    border-radius: 8px;
    font-size: .875rem;
    border: none;
}

.alert-success { background-color: #ecfdf5; color: #065f46; }
.alert-danger   { background-color: #fef2f2; color: #991b1b; }
.alert-warning  { background-color: #fffbeb; color: #92400e; }
.alert-info     { background-color: #eff6ff; color: #1e40af; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    font-weight: 500;
    letter-spacing: .02em;
}

/* ── Footer ──────────────────────────────────────────────── */
footer.site-footer {
    background-color: var(--brand);
    color: rgba(255,255,255,.55);
    padding: .85rem 0;
    font-size: .78rem;
    text-align: center;
    margin-top: auto;
}

/* ── Permission matrix (Create/Edit User) ────────────────── */
.perm-group {
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: .85rem 1rem;
    background: #fafbfd;
}

.perm-group-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: .6rem;
    display: block;
}

/* ── Prevent horizontal page overflow on mobile ─────────── */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* ── Contract content (user HTML) ───────────────────────── */
.contract-content {
    overflow-x: auto;
}
.contract-content img {
    max-width: 100%;
    height: auto;
}
.contract-content table {
    width: 100%;
    max-width: 100%;
    word-break: break-word;
}

/* ── Brand colour utilities (portal pages) ──────────────── */
.bg-brand {
    background-color: var(--brand-color, var(--brand)) !important;
    color: #fff !important;
}
.text-brand { color: var(--brand-color, var(--brand)) !important; }
.border-brand { border-color: var(--brand-color, var(--brand)) !important; }

.btn-brand {
    background-color: var(--brand-color, var(--brand));
    border-color: var(--brand-color, var(--brand));
    color: #fff;
}
.btn-brand:hover,
.btn-brand:focus {
    background-color: color-mix(in srgb, var(--brand-color, var(--brand)) 85%, black);
    border-color: color-mix(in srgb, var(--brand-color, var(--brand)) 85%, black);
    color: #fff;
}
.btn-outline-brand {
    background-color: transparent;
    border-color: var(--brand-color, var(--brand));
    color: var(--brand-color, var(--brand));
}
.btn-outline-brand:hover,
.btn-outline-brand:focus {
    background-color: var(--brand-color, var(--brand));
    border-color: var(--brand-color, var(--brand));
    color: #fff;
}

.card-link-hover {
    transition: box-shadow .15s, transform .12s;
    cursor: pointer;
}
.card-link-hover:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.12) !important;
    transform: translateY(-2px);
}

.dropzone {
    border: 2px dashed #ccc;
    border-radius: .375rem;
    padding: .75rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.dropzone-active {
    border-color: var(--brand-color, var(--brand));
    background-color: rgba(0,0,0,.03);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .page-header h1 { font-size: 1.1rem; }
    .stat-card      { padding: 1.1rem 1rem; }

    /* Page header: let h1 + badge wrap on small screens */
    .page-header .badge-heading {
        flex-wrap: wrap;
        gap: .4rem !important;
    }

    /* Navbar brand: hide text label on small screens if logo present */
    .navbar-brand .brand-text { display: none; }

    /* Action button bars: stack vertically */
    .action-bar {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .action-bar > .btn,
    .action-bar > form {
        width: 100%;
    }
    .action-bar > form > .btn {
        width: 100%;
    }
    .action-bar > .btn.ms-auto,
    .action-bar > a.ms-auto {
        margin-left: 0 !important;
    }

    /* Card headers with flex: allow wrapping */
    .card-header.d-flex {
        flex-wrap: wrap;
        gap: .35rem;
    }

    /* Contract/compliance content padding */
    .contract-content {
        padding: .75rem !important;
    }

    /* Signature modal canvas */
    #signatureCanvas {
        height: 150px !important;
    }
}

@media (max-width: 576px) {
    body   { font-size: .875rem; }
    .table { font-size: .8rem; }

    /* Definition list rows: labels and values stack on phones */
    dl.row > dt { margin-bottom: 0; }
    dl.row > dd { margin-bottom: .6rem; }

    /* Modal sizing */
    .modal-body    { padding: .85rem; }
    .modal-footer  { padding: .65rem .85rem; }

    /* Reduce card body padding */
    .card-body { padding: .85rem; }
    .card-body.p-4 { padding: .85rem !important; }
}

/* ── Collapsible card headers ──────────────────────────────
   Used on Employees/Details and Employees/Edit so long pages default to
   collapsed sections. Bootstrap's collapse.js toggles the .collapsed class
   on the trigger element itself — the chevron just reacts to it. */
.card-header.collapsible-header {
    cursor: pointer;
}

.card-header.collapsible-header .collapse-chevron {
    transition: transform .2s ease;
    margin-left: auto;
}

.card-header.collapsible-header.collapsed .collapse-chevron {
    transform: rotate(-90deg);
}

/* ── Filled stat tiles ──────────────────────────────────────
   Solid-fill summary cards with white text, for report headline figures
   (Position View, Expiry Hit List, etc). Fixed, non-cycled role colors —
   pick by meaning, not by position in the row. */
.stat-tile {
    border: none;
    border-radius: .5rem;
    color: #fff;
}
.stat-tile .stat-tile-label {
    color: rgba(255,255,255,.85);
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.stat-tile .stat-tile-value {
    color: #fff;
    font-weight: 700;
}
.stat-tile .stat-tile-sub {
    color: rgba(255,255,255,.75);
    font-size: .8rem;
}
.stat-tile-blue   { background-color: #2a78d6; }
.stat-tile-teal   { background-color: #1baf7a; }
.stat-tile-green  { background-color: #0ca30c; }
.stat-tile-orange { background-color: #eb6834; }
.stat-tile-red    { background-color: #d03b3b; }

/* ── Position View matrix: wrap requirement column headers ────
   Table auto-layout otherwise sizes each column to fit its label on one
   line, making the matrix very wide with many requirement columns. */
.table thead th.pv-req-th {
    max-width: 100px;
    white-space: normal;
    word-break: break-word;
    vertical-align: bottom;
}
