﻿/* ===== BASE VARIABLES ===== */
:root {
    --header-h: 58px;
    --footer-h: 42px;
    --footer-right-gap: 84px;

    --pms-bg: #fff8eb;
    --pms-header-bg: #faf2e3;
    --pms-card-bg: #ffffff;
    --pms-primary: #1f99be;
    --pms-primary-dark: #176d8a;
    --pms-text: #07364a;
    --pms-muted: #60717b;
    --pms-border: rgba(31, 153, 190, 0.18);
    --pms-hover: #e6f6fa;
    --pms-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
}

/* ===== BASE STYLES ===== */
body {
    font-family: Calibri, Arial, Helvetica, sans-serif;
    background-color: var(--pms-bg);
    margin: 0;
    padding: 20px;
    color: rgb(26, 109, 134);
    padding-bottom: 45px;
    overflow-x: hidden;
}

/* ===== FULL BLEED PAGES ===== */
body.fullbleed {
    padding-top: 0 !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
    padding-bottom: var(--footer-h) !important;
}

body.fullbleed .content-wrap {
    margin: 0;
    padding: 0;
    width: 100%;
    height: calc(100vh - var(--footer-h));
    display: flex;
}

body.fullbleed .card {
    flex: 1 1 auto;
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    margin-right: var(--footer-right-gap);
}

body.fullbleed .table-wrap {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    width: calc(100% - var(--footer-right-gap));
}

@media (max-width: 900px) {
    :root {
        --footer-right-gap: 72px;
    }
}

@media (max-width: 700px) {
    :root {
        --footer-right-gap: 60px;
    }
}

@media (max-width: 480px) {
    :root {
        --footer-right-gap: 52px;
    }
}

/* ===== HEADER ===== */
.header-bar.mega-header {
    min-height: var(--header-h);
    width: calc(100% + 40px);
    margin: -20px -20px 12px -20px;
    padding: 5px 18px;
    box-sizing: border-box;

    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;

    background: var(--pms-header-bg);
    border-bottom: 1px solid var(--pms-border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);

    position: sticky;
    top: 0;
    z-index: 6000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.main-logo {
    height: 42px;
    width: auto;
    object-fit: contain;
    display: block;
}

/* ===== NAVIGATION ===== */
.nav-titles.mega-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
    flex: 0 1 auto;
    min-width: 0;
    overflow: visible;
    position: relative;
}

.nav-item {
    height: 34px;
    padding: 0 8px;
    border-radius: 10px;
    border: 0;
    outline: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;

    background: transparent;
    color: var(--pms-text);
    font-family: Calibri, Arial, Helvetica, sans-serif;
    font-size: 0.92em;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;

    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.nav-item:hover,
.nav-item:focus,
.mega-dropdown:hover > .nav-item,
.mega-dropdown:focus-within > .nav-item {
    background: var(--pms-hover);
    color: var(--pms-primary-dark);
}

.nav-icon {
    font-size: 18px;
    color: var(--pms-primary-dark);
    line-height: 1;
}

.chevron {
    font-size: 15px;
    color: var(--pms-primary-dark);
    margin-left: 2px;
}

/* ===== MEGA MENU ===== */
.mega-dropdown {
    position: static;
    display: inline-flex;
}

.mega-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);

    width: min(1120px, calc(100vw - 70px));
    max-height: calc(100vh - 140px);
    overflow-y: auto;

    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--pms-border);
    border-radius: 16px;
    box-shadow: 0 18px 42px rgba(6, 61, 83, 0.18);
    padding: 24px 28px;

    opacity: 0;
    visibility: hidden;

    transition: opacity 0.18s ease 0.3s, transform 0.18s ease 0.3s, visibility 0.18s ease 0.3s;
    z-index: 9999;

    scrollbar-width: thin;
    scrollbar-color: var(--pms-primary) rgba(31, 153, 190, 0.10);
}

.mega-menu::-webkit-scrollbar {
    width: 8px;
}

.mega-menu::-webkit-scrollbar-track {
    background: rgba(31, 153, 190, 0.08);
    border-radius: 8px;
}

.mega-menu::-webkit-scrollbar-thumb {
    background: var(--pms-primary);
    border-radius: 8px;
}

.mega-menu::-webkit-scrollbar-thumb:hover {
    background: var(--pms-primary-dark);
}

.mega-dropdown:hover .mega-menu,
.mega-dropdown:focus-within .mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0s;
}

/* Force an immediate close (no lingering delay) when another mega-menu is opened */
.mega-dropdown.force-closed .mega-menu {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateX(-50%) translateY(8px) !important;
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s ease !important;
}

.mega-dropdown.force-closed .production-menu {
    transform: translateY(8px) !important;
}

/* Invisible hover bridge covering the gap between the nav item and the panel,
   so moving the mouse slowly from the title to the menu doesn't close it */
.mega-menu::after {
    content: "";
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
}

.production-menu {
    width: min(1180px, calc(100vw - 40px));
    left: 0;
    transform: translateY(8px);
}

.mega-dropdown:hover .production-menu,
.mega-dropdown:focus-within .production-menu {
    transform: translateY(0);
}

.small-mega {
    width: min(680px, calc(100vw - 70px));
}

.admin-mega {
    width: min(780px, calc(100vw - 70px));
}

/* ===== MEGA MENU HEADER ===== */
.mega-menu-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;

    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(7, 54, 74, 0.12);
}

.mega-menu-header h3 {
    margin: 0 0 5px 0;
    color: var(--pms-primary-dark);
    font-size: 22px;
    font-weight: 800;
}

.mega-menu-header p {
    margin: 0;
    color: var(--pms-muted);
    font-size: 13.5px;
}

/* ===== MEGA GRID ===== */
.mega-grid {
    display: grid;
    gap: 20px;
}

.mega-grid-1 {
    grid-template-columns: 1fr;
}

.mega-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mega-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mega-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ===== MEGA COLUMNS ===== */
.mega-column {
    min-width: 0;
    padding-right: 18px;
    border-right: 1px solid rgba(7, 54, 74, 0.10);
}

.mega-column:last-child {
    padding-right: 0;
    border-right: none;
}

.mega-column h4 {
    margin: 0 0 12px 0;
    color: var(--pms-primary-dark);
    font-size: 15px;
    font-weight: 800;
}

.mega-column a {
    min-height: 32px;
    padding: 6px 9px;
    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    color: #0d2b3a;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.25;

    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.mega-column a:hover,
.mega-column a:focus {
    background: var(--pms-hover);
    color: var(--pms-primary-dark);
    transform: translateX(2px);
}

.mega-section-title {
    margin: 14px 0 5px;
    color: var(--pms-primary-dark);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.35px;
}

/* ===== PLAN BADGE ===== */
.plan-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 2px 7px;
    border-radius: 6px;

    background: #e3f6e6;
    color: #1f7a32;

    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

/* ===== PLANNED (NON-CLICKABLE) MENU ITEM ===== */
.planned-menu-item {
    min-height: 32px;
    padding: 6px 9px;
    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    color: #0d2b3a;
    opacity: 0.7;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.25;
    cursor: default;
    user-select: none;
}

/* ===== USER SECTION ===== */
.user-section {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.95em;
    margin-left: auto;
}

.fullscreen-btn {
    width: 38px;
    height: 38px;

    border: 1px solid rgba(23, 109, 138, 0.35);
    border-radius: 9px;
    background: #ffffff;
    color: var(--pms-primary-dark);

    display: inline-flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    font-size: 18px;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.fullscreen-btn:hover {
    background: var(--pms-hover);
    color: var(--pms-primary);
}

.welcome-user {
    color: var(--pms-primary-dark);
    font-weight: 500;
}

.user-name {
    font-weight: 700;
    font-style: italic;
    color: var(--pms-primary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: bottom;
}

a.profile-link {
    text-decoration: none;
    color: var(--pms-primary);
    cursor: pointer;
}

a.profile-link:hover {
    color: var(--pms-primary-dark);
    text-decoration: underline;
}

.logout-form {
    display: inline;
}

.logout-btn {
    height: 38px;
    padding: 0 15px;
    border-radius: 8px;

    border: 1px solid var(--pms-primary-dark);
    background: var(--pms-primary);
    color: #ffffff;

    font-family: Calibri, Arial, Helvetica, sans-serif;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;

    box-shadow: 0 3px 8px rgba(31, 153, 190, 0.25);
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.logout-btn:hover {
    background: var(--pms-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.16);
}

/* ===== HAMBURGER BUTTON ===== */
.hamburger-btn {
    display: none;
    width: 42px;
    height: 38px;

    border: 1px solid rgba(23, 109, 138, 0.35);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;

    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;

    transition: background 0.18s ease;
}

.hamburger-btn:hover {
    background: var(--pms-hover);
}

.hamburger-line {
    display: block;
    width: 21px;
    height: 2px;
    background: var(--pms-primary-dark);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.hamburger-btn.open .hamburger-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger-btn.open .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.open .hamburger-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ===== MAINTENANCE TOGGLE ===== */
.maintenance-toggle-item {
    padding: 10px 9px;
    border-top: 1px solid rgba(7, 54, 74, 0.10);
    margin-top: 8px;
}

.maintenance-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13.5px;
    color: #0d2b3a;
}

.maint-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
    flex-shrink: 0;
}

.maint-switch input {
    display: none;
}

.maint-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #ccc;
    border-radius: 20px;
    transition: background-color 0.3s;
}

.maint-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

.maint-switch.active .maint-slider {
    background-color: #e74c3c;
}

.maint-switch.active .maint-slider::before {
    transform: translateX(18px);
}

.maint-badge {
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.maint-badge-off {
    background: #d4edda;
    color: #155724;
}

.maint-badge-on {
    background: #f8d7da;
    color: #721c24;
}

.maint-duration-row {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(7, 54, 74, 0.18);
}

.maint-duration-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: #555;
    white-space: nowrap;
}

.maint-duration-label input {
    width: 58px;
    padding: 4px 5px;
    border: 1px solid #bbb;
    border-radius: 5px;
    font-size: 0.95em;
    color: var(--pms-primary-dark);
    text-align: center;
}

/* ===== FOOTER ===== */
.footer {
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #faf2e3;
    padding: 7px 15px;
    border-top: 1.5px solid #1f99be;
    font-size: 0.9em;
    color: #176d8a;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    min-height: 42px;
}

.footer-left {
    flex: 1;
    text-align: left;
    padding-left: 15px;
}

.footer-center {
    flex: 2;
    text-align: center;
    font-size: 0.86em;
    line-height: 1.25;
}

.footer-right {
    flex: 1;
    text-align: right;
    padding-right: 15px;
}

.footer-logo {
    height: 50px;
    width: auto;
    border-radius: 6px;
    border: 1.5px solid #1f99be;
    position: absolute;
    right: 15px;
    bottom: 7px;
    z-index: 1002;
    background-color: #faf2e3;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

.contact-link {
    color: #1f99be;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.2s;
    padding: 2px 0;
    display: inline-block;
    border-bottom: 1px solid transparent;
}

.contact-link:hover {
    color: #1f99be;
    text-decoration: none;
    border-bottom: 1px solid #1f99be;
}

.footer-separator {
    color: #1f99be;
    margin: 0 8px;
    font-weight: 400;
    opacity: 0.6;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1250px) {
    .nav-item {
        padding: 0 9px;
        font-size: 0.94em;
    }

    .main-logo {
        height: 38px;
    }

    .user-name {
        max-width: 150px;
    }
}

@media (max-width: 1100px) {
    .header-bar.mega-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
    }

    .hamburger-btn {
        display: flex;
    }

    .nav-titles.mega-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding-top: 8px;
        border-top: 1px solid rgba(31, 153, 190, 0.18);
    }

    .nav-titles.mega-nav.nav-open {
        display: flex;
        max-height: calc(100vh - var(--header-h) - 20px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-item {
        width: 100%;
        min-height: 44px;
        justify-content: flex-start;
        padding: 0 12px;
    }

    .mega-dropdown {
        width: 100%;
        display: block;
    }

    .mega-menu,
    .production-menu,
    .small-mega,
    .admin-mega {
        position: static;
        width: 100%;
        max-height: none;
        overflow: visible;

        transform: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;

        display: none;

        margin-top: 6px;
        padding: 16px;
        border-radius: 12px;
        box-shadow: none;
    }

    .mega-menu::before,
    .mega-menu::after {
        display: none;
    }

    .mega-dropdown.active .mega-menu {
        display: block;
    }

    .mega-grid,
    .mega-grid-1,
    .mega-grid-2,
    .mega-grid-3,
    .mega-grid-4 {
        grid-template-columns: 1fr;
    }

    .mega-column {
        border-right: none;
        border-bottom: 1px solid rgba(7, 54, 74, 0.10);
        padding-right: 0;
        padding-bottom: 12px;
    }

    .mega-column:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .mega-column a,
    .planned-menu-item {
        min-height: 44px;
    }

    .user-section {
        width: 100%;
        justify-content: flex-end;
        border-top: 1px solid rgba(31, 153, 190, 0.18);
        padding-top: 8px;
    }
}

@media (max-width: 900px) and (min-width: 701px) {
    .mega-grid-2,
    .mega-grid-3,
    .mega-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    body {
        padding-top: 56px;
        padding-bottom: 40px;
    }

    .header-bar.mega-header {
        width: calc(100% + 40px);
        margin: -20px -20px 12px -20px;
        padding: 8px 10px;
    }

    .main-logo {
        height: 34px;
    }

    .mega-menu-header h3 {
        font-size: 19px;
    }

    .mega-menu-header p {
        font-size: 12.5px;
    }

    .mega-column a {
        font-size: 13px;
    }

    .mega-menu,
    .production-menu,
    .small-mega,
    .admin-mega {
        padding: 12px;
    }

    .mega-grid {
        gap: 12px;
    }

    .maintenance-label {
        white-space: normal;
    }

    .maint-duration-row {
        flex-wrap: wrap;
    }

    .user-section {
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 6px;
        font-size: 0.88em;
    }

    .user-name {
        max-width: 120px;
    }

    .logout-btn {
        height: 34px;
        padding: 0 10px;
        font-size: 0.88em;
    }

    .fullscreen-btn {
        width: 34px;
        height: 34px;
    }

    .footer {
        min-height: 38px;
    }

    .footer-logo {
        height: 40px;
        bottom: 5px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 6px;
        padding-top: 52px;
        padding-bottom: 38px;
        overflow-x: hidden;
    }

    .header-bar.mega-header {
        width: calc(100% + 12px);
        margin: -6px -6px 10px -6px;
    }

    .user-section {
        font-size: 0.86em;
    }

    .footer-logo {
        height: 35px;
    }
}

@media (max-width: 480px) {
    .user-name {
        max-width: 80px;
    }

    .welcome-user {
        font-size: 0.86em;
    }

    .logout-btn {
        padding: 0 8px;
        font-size: 0.84em;
    }

    .footer {
        min-height: 36px;
        padding: 5px 10px;
    }

    .footer-logo {
        height: 32px;
        bottom: 4px;
        right: 10px;
    }
}

@media (max-width: 380px) {
    .user-name {
        max-width: 60px;
    }

    .logout-btn {
        padding: 0 6px;
        font-size: 0.8em;
    }

    .footer {
        min-height: 34px;
    }
}