/* PWM_Operations_Hub/static/css/base.css */
:root {
    --pwm-blue: #004276;
    --pwm-blue-dark: #002f56;
    --pwm-blue-light: #1f78b8;

    --pwm-black: #111827;
    --pwm-grey: #6b7280;
    --pwm-grey-dark: #374151;
    --pwm-light-grey: #f3f4f6;
    --pwm-border: #d1d5db;
    --pwm-white: #ffffff;

    --page-bg: #f5f7fa;
    --card-bg: #ffffff;

    --header-height: 72px;
    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    color: var(--pwm-black);
    background: var(--page-bg);
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--pwm-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

/* Shared buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 18px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--pwm-blue), var(--pwm-blue-dark));
    color: var(--pwm-white);
    box-shadow: 0 8px 18px rgba(0, 66, 118, 0.24);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 66, 118, 0.34);
}

.btn-secondary {
    background: var(--pwm-white);
    color: var(--pwm-blue);
    border-color: var(--pwm-border);
}

/* Shared cards */

.card {
    background: var(--card-bg);
    border: 1px solid var(--pwm-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
}

/* Shared form elements */

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input,
.input-wrapper select,
.input-wrapper textarea {
    width: 100%;
    border: 1px solid var(--pwm-border);
    border-radius: 7px;
    padding: 0 14px;
    font-size: 16px;
    outline: none;
    background: var(--pwm-white);
    color: var(--pwm-black);
}

.input-wrapper input,
.input-wrapper select {
    height: 52px;
}

.input-wrapper textarea {
    min-height: 120px;
    padding-top: 14px;
    resize: vertical;
}

.input-wrapper input:focus,
.input-wrapper select:focus,
.input-wrapper textarea:focus {
    border-color: var(--pwm-blue);
    box-shadow: 0 0 0 3px rgba(0, 66, 118, 0.16);
}

.edit-input {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--pwm-border);
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 14px;
    color: var(--pwm-black);
    background: var(--pwm-white);
}

.edit-input:focus {
    outline: none;
    border-color: var(--pwm-blue);
    box-shadow: 0 0 0 3px rgba(0, 66, 118, 0.14);
}

.edit-textarea {
    min-height: 82px;
    resize: vertical;
}

/* Shared app layout for logged-in pages */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
}

.app-sidebar {
    position: sticky;
    top: 0;
    align-self: start;

    height: 100vh;
    overflow-y: auto;

    background: linear-gradient(180deg, #071827, #0c2235);
    color: var(--pwm-white);
    padding: 28px 20px;
}

.app-main {
    min-width: 0;
    background: var(--page-bg);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 100;

    height: var(--header-height);
    background: var(--pwm-white);
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08);

    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.app-content {
    padding: 28px;
}

.sidebar-logo {
    width: 200px;
    margin-bottom: 22px;
}

.sidebar-title {
    margin: 0 0 28px;
    font-size: 18px;
    font-weight: 800;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.86);
    padding: 13px 14px;
    border-radius: 8px;
    font-weight: 700;
    background: transparent;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pwm-white);
    text-decoration: none;
}

.sidebar-link.active {
    background: linear-gradient(135deg, var(--pwm-blue), var(--pwm-blue-dark));
    color: var(--pwm-white);
}

.sidebar-group-toggle {
    width: 100%;
    border: none;
    font-family: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}

.sidebar-link-text {
    flex: 1;
}

.sidebar-chevron {
    margin-left: auto;
    font-size: 16px;
    font-weight: 900;
    transition: transform 0.2s ease;
}

.sidebar-group:not(.sidebar-group-open) .sidebar-chevron {
    transform: rotate(-90deg);
}

.sidebar-group:not(.sidebar-group-open) .sidebar-subnav {
    display: none;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
}

.sidebar-subnav {
    margin: 4px 0 10px 36px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-sublink {
    color: rgba(255, 255, 255, 0.72);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.sidebar-sublink:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pwm-white);
    text-decoration: none;
}

.topbar-title {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-menu {
    color: var(--pwm-black);
    font-weight: 700;
}

.settings-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid var(--pwm-border);
    border-radius: 7px;
    background: var(--pwm-white);
    color: var(--pwm-blue);
    font-weight: 700;
    text-decoration: none;
}

.settings-link:hover {
    background: #e8f2fb;
    border-color: var(--pwm-blue-light);
    text-decoration: none;
}

/* Shared page/header layout */

.assets-page,
.repairs-page,
.roles-page,
.lookup-page {
    max-width: 1120px;
}

.lookup-page {
    max-width: 1180px;
}

.assets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.assets-header h2 {
    margin: 0 0 4px;
    font-size: 34px;
    line-height: 1.1;
}

.assets-header p {
    margin: 0;
    color: var(--pwm-grey);
    font-size: 16px;
}

/* Shared controls/search/tabs */

.asset-controls-row {
    display: flex;
    align-items: center;
    gap: 34px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.asset-search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    min-width: min(100%, 430px);
}

.asset-search-label {
    color: var(--pwm-grey-dark);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.asset-search-input {
    flex: 1;
    min-width: 210px;
    min-height: 40px;
    border: 1px solid var(--pwm-border);
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 14px;
    color: var(--pwm-black);
    background: var(--pwm-white);
}

.asset-search-input:focus {
    outline: none;
    border-color: var(--pwm-blue);
    box-shadow: 0 0 0 3px rgba(0, 66, 118, 0.14);
}

.asset-no-results,
.role-no-results {
    margin-top: 16px;
}

.asset-tabs {
    display: inline-flex;
    background: var(--pwm-white);
    border: 1px solid var(--pwm-border);
    border-radius: 10px;
    overflow: hidden;
}

.asset-tab {
    border: none;
    background: var(--pwm-white);
    color: var(--pwm-grey-dark);
    padding: 12px 22px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border-right: 1px solid var(--pwm-border);
}

.asset-tab:last-child {
    border-right: none;
}

.asset-tab:hover {
    background: #f3f7fb;
}

.asset-tab.active {
    background: var(--pwm-blue);
    color: var(--pwm-white);
}

.active-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--pwm-grey-dark);
    font-size: 14px;
    font-weight: 600;
    user-select: none;
}

.active-toggle input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 58px;
    height: 30px;
    border-radius: 999px;
    background: var(--pwm-blue);
    cursor: pointer;
    transition: background 0.2s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--pwm-white);
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.25);
    transition: transform 0.2s ease;
}

.active-toggle input:checked + .toggle-slider {
    background: var(--pwm-grey-dark);
}

.active-toggle input:checked + .toggle-slider::before {
    transform: translateX(28px);
}

/* Shared card/detail patterns */

.asset-card-list {
    display: grid;
    gap: 16px;
}

.asset-card,
.role-card {
    padding: 20px 22px 22px;
}

.asset-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.asset-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex-wrap: wrap;
}

.asset-title-group h3 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
}

.asset-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #f3f4f6;
    color: var(--pwm-grey-dark);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.asset-status.active {
    background: #dcfce7;
    color: #166534;
}

.asset-status.location-name-status {
    background: #e8f2fb;
    color: var(--pwm-blue);
}

.asset-status.location-name-status.location-active {
    background: #dcfce7;
    color: #166534;
}

.asset-status.location-name-status.location-grey {
    background: #f3f4f6;
    color: var(--pwm-grey-dark);
}

.asset-edit-button {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 1px solid var(--pwm-border);
    border-radius: 8px;
    background: var(--pwm-white);
    color: var(--pwm-blue);
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-decoration: none;
}

.asset-edit-button:hover {
    background: #e8f2fb;
    border-color: var(--pwm-blue-light);
    text-decoration: none;
}

.asset-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 42px;
    row-gap: 10px;
}

.asset-detail-item {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.asset-detail-label {
    color: var(--pwm-grey);
    font-weight: 600;
    white-space: nowrap;
}

.asset-detail-value {
    color: var(--pwm-black);
    font-weight: 400;
    overflow-wrap: anywhere;
}

.empty-assets {
    padding: 28px;
}

.empty-assets h3 {
    margin: 0 0 8px;
}

.empty-assets p {
    margin: 0;
    color: var(--pwm-grey);
}

/* Shared modals/actions */

.asset-modal {
    width: min(640px, calc(100vw - 32px));
    border: none;
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 24px 70px rgba(17, 24, 39, 0.32);
}

.asset-modal::backdrop {
    background: rgba(17, 24, 39, 0.58);
}

.asset-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 26px;
    border-bottom: 1px solid #e5e7eb;
}

.asset-modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.asset-modal-footer {
    padding: 18px 26px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #e5e7eb;
}

.modal-form {
    margin: 0;
}

.modal-close-button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #f3f4f6;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.modal-close-button:hover {
    background: #e5e7eb;
}

.back-link {
    display: inline-flex;
    margin-bottom: 10px;
    color: var(--pwm-blue);
    font-weight: 800;
}

.side-action-button,
.mini-action-button {
    border: 1px solid var(--pwm-border);
    background: var(--pwm-white);
    color: var(--pwm-blue);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.side-action-button {
    min-height: 40px;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
}

.mini-action-button {
    min-height: 30px;
    padding: 6px 9px;
    font-size: 12px;
    white-space: nowrap;
}

.side-action-button:hover,
.mini-action-button:hover {
    border-color: var(--pwm-blue-light);
    background: #e8f2fb;
    text-decoration: none;
}

.warning-action-button {
    border-color: #dc2626;
    background: #fee2e2;
    color: #991b1b;
}

.warning-action-button:hover {
    border-color: #b91c1c;
    background: #fecaca;
    color: #7f1d1d;
}

/* Shared messages */

.messages {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.message {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--pwm-border);
    background: var(--pwm-white);
}

.message-success {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.message-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.message-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.message-info {
    background: #e8f2fb;
    color: var(--pwm-blue);
    border-color: #bfdbfe;
}

/* Mobile navigation controls are hidden on desktop. */

.mobile-nav-toggle,
.mobile-nav-close,
.mobile-nav-backdrop,
.mobile-sidebar-account {
    display: none;
}

/* Responsive shared app layout */

@media (max-width: 900px) {
    .app-shell {
        display: block;
        min-height: 100vh;
    }

    .app-sidebar {
        display: block;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 300;

        width: min(86vw, 320px);
        height: 100vh;
        height: 100dvh;

        padding: 24px 18px;
        overflow-y: auto;
        overscroll-behavior: contain;

        box-shadow: 14px 0 36px rgba(15, 23, 42, 0.34);

        visibility: hidden;
        transform: translateX(-105%);
        transition:
            transform 0.22s ease,
            visibility 0.22s ease;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    body.mobile-nav-open .app-sidebar {
        visibility: visible;
        transform: translateX(0);
    }

    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 250;

        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;

        border: none;
        background: rgba(15, 23, 42, 0.58);
        cursor: pointer;

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        transition:
            opacity 0.22s ease,
            visibility 0.22s ease;
    }

    body.mobile-nav-open .mobile-nav-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .mobile-nav-toggle {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;

        width: 42px;
        height: 42px;
        padding: 0;

        border: 1px solid var(--pwm-border);
        border-radius: 8px;
        background: var(--pwm-white);
        color: var(--pwm-blue-dark);

        font-family: inherit;
        font-size: 24px;
        font-weight: 900;
        line-height: 1;
        cursor: pointer;
    }

    .mobile-nav-toggle:hover {
        border-color: var(--pwm-blue-light);
        background: #e8f2fb;
    }

    .mobile-nav-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 16px;
        right: 14px;

        width: 40px;
        height: 40px;
        padding: 0;

        border: 1px solid rgba(255, 255, 255, 0.24);
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.08);
        color: var(--pwm-white);

        font-family: inherit;
        font-size: 28px;
        line-height: 1;
        cursor: pointer;
    }

    .mobile-nav-close:hover {
        background: rgba(255, 255, 255, 0.16);
    }

    .app-sidebar .sidebar-logo {
        width: 180px;
        max-width: calc(100% - 50px);
    }

    .mobile-sidebar-account {
        display: grid;
        gap: 10px;

        margin-top: 24px;
        padding-top: 20px;

        border-top: 1px solid rgba(255, 255, 255, 0.18);
    }

    .mobile-sidebar-user {
        display: block;
        margin-bottom: 4px;
        color: rgba(255, 255, 255, 0.88);
        font-size: 14px;
        font-weight: 700;
        overflow-wrap: anywhere;
    }

    .mobile-sidebar-account .settings-link {
        width: 100%;
        justify-content: flex-start;

        border-color: rgba(255, 255, 255, 0.22);
        background: rgba(255, 255, 255, 0.08);
        color: var(--pwm-white);
    }

    .mobile-sidebar-account .settings-link:hover {
        border-color: rgba(255, 255, 255, 0.38);
        background: rgba(255, 255, 255, 0.16);
    }

    .mobile-sidebar-logout {
        width: 100%;
        margin: 0;
    }

    .mobile-sidebar-logout .btn {
        width: 100%;
    }

    .app-topbar {
        gap: 12px;
        padding: 0 18px;
    }

    .topbar-title {
        flex: 1;
        min-width: 0;

        font-size: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-actions {
        display: none;
    }

    .app-content {
        padding: 18px;
    }

    .asset-search {
        width: 100%;
        margin-left: 0;
    }
}

@media (max-width: 700px) {
    .assets-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .asset-controls-row {
        gap: 16px;
    }

    .asset-tabs {
        display: flex;
        width: 100%;
    }

    .asset-tab {
        flex: 1;
        padding-left: 10px;
        padding-right: 10px;
    }

    .active-toggle {
        width: 100%;
        justify-content: flex-start;
    }

    .asset-details-grid {
        grid-template-columns: 1fr;
    }

    .asset-detail-item {
        grid-template-columns: 120px minmax(0, 1fr);
    }
}

@media (max-width: 560px) {
    .asset-search {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .asset-search-input {
        min-width: 0;
    }

    .asset-search .mini-action-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .asset-detail-item {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

/* Flatpickr inside modal dialogs */
dialog .flatpickr-wrapper {
    width: 100%;
}

dialog .flatpickr-wrapper .edit-input,
dialog .flatpickr-wrapper .lookup-table-input {
    width: 100%;
}

dialog .flatpickr-calendar {
    z-index: 2147483647 !important;
}

@media (max-width: 480px) {
    .app-topbar {
        padding-right: 12px;
        padding-left: 12px;
    }

    .topbar-title {
        font-size: 18px;
    }

    .app-content {
        padding: 12px;
    }
}