:root {
    --portal-bg: #17191c;
    --portal-bg-secondary: #1f2226;
    --portal-panel: #222529;
    --portal-panel-hover: #282c31;
    --portal-border: rgba(255,255,255,.08);

    --portal-text: #f5f5f5;
    --portal-muted: #9da2a8;

    --portal-accent: #e5a00d;
    --portal-accent-hover: #f3b51b;
    --portal-accent-soft: rgba(229,160,13,.13);

    --portal-navbar: rgba(18,20,22,.97);
}

html {
    min-height: 100%;
    color-scheme: dark;
}

body {
    min-height: 100vh;
    margin: 0;

    background:
        radial-gradient(
            circle at top right,
            rgba(229,160,13,.035),
            transparent 28rem
        ),
        var(--portal-bg);

    color: var(--portal-text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}

/* ================================================================
   Bootstrap dark-theme overrides
   ================================================================ */

[data-bs-theme="dark"] {
    --bs-body-bg: var(--portal-bg);
    --bs-body-color: var(--portal-text);

    --bs-secondary-bg: var(--portal-bg-secondary);
    --bs-tertiary-bg: var(--portal-panel);

    --bs-border-color: var(--portal-border);

    --bs-link-color: var(--portal-accent);
    --bs-link-hover-color: var(--portal-accent-hover);

    --bs-primary: var(--portal-accent);
    --bs-primary-rgb: 229,160,13;
}

/* ================================================================
   Navbar
   ================================================================ */

.portal-navbar {
    min-height: 64px;

    background: var(--portal-navbar) !important;

    border-bottom:
        1px solid var(--portal-border) !important;

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);

    box-shadow:
        0 3px 18px rgba(0,0,0,.28);

    z-index: 1030;
}

.portal-navbar-brand {
    color: #fff !important;

    font-weight: 600;
    letter-spacing: -.02em;

    display: flex;
    align-items: center;

    gap: .65rem;
}

.portal-brand-icon {
    color: var(--portal-accent);
    font-size: 1.3rem;
}

.portal-navbar .nav-link {
    color: #b7bbc0;

    border-radius: .4rem;

    padding-left: .8rem !important;
    padding-right: .8rem !important;

    transition:
        color .15s ease,
        background-color .15s ease;
}

.portal-navbar .nav-link:hover,
.portal-navbar .nav-link:focus {
    color: #fff;

    background:
        rgba(255,255,255,.055);
}

.portal-user-link {
    color: #ddd !important;
}

.portal-user-link i {
    color: var(--portal-accent);
}

/* ================================================================
   Buttons
   ================================================================ */

.btn-primary {
    --bs-btn-color: #171717;
    --bs-btn-bg: var(--portal-accent);
    --bs-btn-border-color: var(--portal-accent);

    --bs-btn-hover-color: #111;
    --bs-btn-hover-bg: var(--portal-accent-hover);
    --bs-btn-hover-border-color: var(--portal-accent-hover);

    --bs-btn-active-color: #111;
    --bs-btn-active-bg: var(--portal-accent-hover);
    --bs-btn-active-border-color: var(--portal-accent-hover);

    font-weight: 600;
}

.btn-warning {
    --bs-btn-color: #171717;
    --bs-btn-bg: var(--portal-accent);
    --bs-btn-border-color: var(--portal-accent);

    --bs-btn-hover-color: #111;
    --bs-btn-hover-bg: var(--portal-accent-hover);
    --bs-btn-hover-border-color: var(--portal-accent-hover);

    font-weight: 600;
}

.btn-outline-secondary {
    --bs-btn-color: #aeb3b8;
    --bs-btn-border-color: rgba(255,255,255,.16);

    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(255,255,255,.08);
    --bs-btn-hover-border-color: rgba(255,255,255,.25);
}

/* ================================================================
   Page shell
   ================================================================ */

.portal-main {
    max-width: 1680px;

    margin-left: auto;
    margin-right: auto;
}

.portal-page-header {
    padding-top: .45rem;
    padding-bottom: .75rem;
}

.portal-page-title {
    font-weight: 400;
    letter-spacing: -.025em;
}

.portal-page-subtitle {
    color: var(--portal-muted);
}

/* ================================================================
   Dashboard action cards
   ================================================================ */

.portal-action-card {
    height: 100%;

    position: relative;

    overflow: hidden;

    border:
        1px solid var(--portal-border) !important;

    border-radius: .7rem;

    background:
        linear-gradient(
            145deg,
            rgba(255,255,255,.018),
            transparent 45%
        ),
        var(--portal-panel);

    box-shadow:
        0 7px 22px rgba(0,0,0,.18);

    transition:
        transform .18s ease,
        border-color .18s ease,
        background-color .18s ease,
        box-shadow .18s ease;
}

.portal-action-card:hover {
    transform: translateY(-3px);

    border-color:
        rgba(229,160,13,.34) !important;

    background-color:
        var(--portal-panel-hover);

    box-shadow:
        0 12px 32px rgba(0,0,0,.3);
}

.portal-action-card::after {
    content: "";

    position: absolute;

    width: 130px;
    height: 130px;

    right: -55px;
    top: -55px;

    border-radius: 50%;

    background:
        radial-gradient(
            circle,
            var(--portal-accent-soft),
            transparent 68%
        );

    pointer-events: none;
}

.portal-card-icon {
    width: 48px;
    height: 48px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: .65rem;

    color: var(--portal-accent);

    background:
        rgba(229,160,13,.09);

    font-size: 1.65rem;
}

.portal-card-title {
    font-size: 1.06rem;
    font-weight: 500;
}

.portal-card-description {
    min-height: 3rem;

    color: var(--portal-muted);

    font-size: .9rem;
    line-height: 1.5;
}

/* ================================================================
   Account / generic cards
   ================================================================ */

.card {
    --bs-card-bg: var(--portal-panel);
    --bs-card-border-color: var(--portal-border);
}

.list-group {
    --bs-list-group-bg: transparent;
    --bs-list-group-border-color: var(--portal-border);
}

/* ================================================================
   Login
   ================================================================ */

.login-shell {
    min-height: 100vh;

    display: flex;
    align-items: center;

    background:
        radial-gradient(
            circle at center,
            rgba(229,160,13,.045),
            transparent 30rem
        );
}

.login-shell .card {
    border:
        1px solid var(--portal-border) !important;

    background:
        rgba(31,34,38,.96);

    box-shadow:
        0 24px 70px rgba(0,0,0,.42) !important;
}

/* ================================================================
   Modal
   ================================================================ */

.modal-content {
    background: var(--portal-bg-secondary);

    border:
        1px solid var(--portal-border);
}

.modal-header {
    background: #191b1e;

    border-bottom:
        1px solid var(--portal-border);
}

/* ================================================================
   Alerts
   ================================================================ */

.alert-danger {
    color: #ff9494;

    background:
        rgba(145,23,23,.24);

    border-color:
        rgba(255,74,74,.34);
}

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 991.98px) {

    .portal-navbar {
        min-height: 58px;
    }

    .portal-navbar .navbar-collapse {
        padding-top: .75rem;
        padding-bottom: .55rem;
    }

    .portal-navbar .nav-link {
        padding:
            .68rem .8rem !important;
    }

    .portal-navbar .btn {
        width: 100%;

        margin-top: .45rem;
        margin-bottom: .25rem;
    }
}

@media (max-width: 575.98px) {

    .portal-page-title {
        font-size: 1.55rem;
    }

    .portal-main {
        padding-left: .85rem !important;
        padding-right: .85rem !important;
    }

    .portal-action-card .card-body {
        padding: 1.15rem;
    }

    .portal-card-description {
        min-height: auto;
    }
}

/* ================================================================
   Plex account avatar
   ================================================================ */

.portal-avatar {
    width: 30px;
    height: 30px;

    flex: 0 0 30px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    object-fit: cover;

    vertical-align: middle;

    background: #34373b;

    box-shadow:
        0 0 0 1px rgba(255,255,255,.10);
}

.portal-avatar-initials {
    color: #151515;

    background:
        var(--portal-accent);

    font-size: .68rem;
    font-weight: 700;

    letter-spacing: .015em;
}

.portal-user-link {
    display: flex !important;
    align-items: center;
}


/* ================================================================
   Browse Media
   ================================================================ */

.portal-media-table th {
    color: var(--portal-muted);
    font-size: .78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .045em;
}

.portal-media-name {
    display: flex;
    align-items: center;
    gap: .85rem;

    color: var(--portal-text);
}

.portal-media-name:hover {
    color: #fff;
}

.portal-media-icon {
    width: 38px;
    height: 38px;

    flex: 0 0 38px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: .45rem;

    background:
        rgba(255,255,255,.055);

    color:
        var(--portal-accent);

    font-size: 1.25rem;
}

.portal-media-thumb {
    width: 48px;
    height: 48px;

    flex: 0 0 48px;

    object-fit: cover;

    border-radius: .4rem;

    background:
        rgba(255,255,255,.05);

    box-shadow:
        0 0 0 1px
        rgba(255,255,255,.06);
}

.nav-pills {
    --bs-nav-pills-link-active-bg:
        var(--portal-accent);

    --bs-nav-pills-link-active-color:
        #161616;
}

@media (max-width: 575.98px) {

    .portal-media-thumb {
        width: 42px;
        height: 42px;

        flex-basis: 42px;
    }

    .portal-media-icon {
        width: 34px;
        height: 34px;

        flex-basis: 34px;
    }

    .portal-media-table td,
    .portal-media-table th {
        padding-top: .8rem;
        padding-bottom: .8rem;
    }
}


/* ================================================================
   Browse Media desktop column behavior
   ================================================================ */

@media (min-width: 992px) {

    .portal-media-table th,
    .portal-media-table td {
        white-space: nowrap;
    }

    .portal-media-table td:first-child,
    .portal-media-table th:first-child {
        white-space: normal;
    }

    .portal-media-table td:first-child {
        min-width: 0;
    }

    .portal-media-table .portal-media-name {
        min-width: 0;
    }

    .portal-media-table .portal-media-name > span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}


/* ================================================================
   Media preview lightbox
   ================================================================ */

.portal-media-modal-body {
    min-height: 420px;

    background:
        #101214;

    overflow: hidden;
}

.portal-lightbox-image {
    display: block;

    max-width: 100%;
    max-height: calc(90vh - 150px);

    width: auto;
    height: auto;

    object-fit: contain;

    margin: auto;
}

.portal-lightbox-video {
    display: block;

    max-width: 100%;
    max-height: calc(90vh - 150px);

    width: 100%;

    background: #000;

    margin: auto;
}

@media (max-width: 767.98px) {

    .portal-media-modal-body {
        min-height: 0;
        height: calc(100vh - 58px);
        padding: 0;
    }

    .portal-lightbox-image,
    .portal-lightbox-video {
        max-width: 100%;
        max-height: 100%;
    }

}


/* ================================================================
   Browse Media fixed detail columns
   ================================================================ */

.portal-media-table {
    width: 100%;
    table-layout: fixed;
}

/*
 * The Name column consumes all remaining width.
 * The detail columns stay predictable and aligned.
 */

.portal-media-table .portal-col-name {
    width: auto;
}

.portal-media-table .portal-col-type {
    width: 90px;
}

.portal-media-table .portal-col-size {
    width: 105px;
}

.portal-media-table .portal-col-modified {
    width: 190px;
}

.portal-media-table .portal-col-actions {
    width: 125px;
}


/* Name column is the only flexible column. */

.portal-media-table .portal-cell-name,
.portal-media-table td:first-child {
    min-width: 0;
    overflow: hidden;
}

.portal-media-table .portal-media-name {
    width: 100%;
    min-width: 0;
}

.portal-media-table .portal-media-name > span:last-child {
    display: block;

    min-width: 0;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/*
 * Detail columns never wrap and sit neatly on the right.
 */

.portal-media-table .portal-cell-type,
.portal-media-table .portal-cell-size,
.portal-media-table .portal-cell-modified,
.portal-media-table .portal-cell-actions {
    white-space: nowrap;
}

.portal-media-table .portal-cell-type,
.portal-media-table .portal-cell-size,
.portal-media-table .portal-cell-modified {
    text-align: right;
}

.portal-media-table .portal-cell-actions {
    text-align: right;
}


/*
 * Keep action buttons together.
 */

.portal-media-table td:last-child {
    white-space: nowrap;
}


/* ================================================================
   Responsive adjustments
   ================================================================ */

@media (max-width: 1199.98px) {

    .portal-media-table .portal-col-modified {
        width: 170px;
    }

    .portal-media-table .portal-col-actions {
        width: 115px;
    }
}

@media (max-width: 991.98px) {

    /*
     * Size/Modified are already hidden by Bootstrap at this width,
     * so let Name take the space back naturally.
     */

    .portal-media-table {
        table-layout: auto;
    }

    .portal-media-table .portal-col-name,
    .portal-media-table .portal-col-type,
    .portal-media-table .portal-col-size,
    .portal-media-table .portal-col-modified,
    .portal-media-table .portal-col-actions {
        width: auto;
    }

}

