/* Modern Auth & Landing Page -- "deep space" theme shared by landing.php, login/register/
   forgot-password/reset-password screens, and the admin dashboard. Pure CSS, no build step. */

:root {
    --ma-bg: #05060f;
    --ma-surface: #12142b;
    --ma-surface-alt: #191c3a;
    --ma-text: #eef0ff;
    --ma-muted: #9aa3c7;
    --ma-primary: #8b5cf6;
    --ma-primary-dark: #7c3aed;
    --ma-accent: #22d3ee;
    --ma-pink: #f472b6;
    --ma-border: rgba(255, 255, 255, 0.1);
    --ma-radius: 14px;
    --ma-gradient: linear-gradient(135deg, #8b5cf6 0%, #ec4899 55%, #22d3ee 100%);
    --ma-glow: 0 0 24px rgba(139, 92, 246, 0.35);
}

/* Starfield + nebula backdrop, tileable, no images/JS */
.modern-space-bg {
    background-color: var(--ma-bg);
    background-image:
        radial-gradient(ellipse 120% 60% at 20% -10%, rgba(139, 92, 246, 0.35), transparent 60%),
        radial-gradient(ellipse 90% 55% at 90% 0%, rgba(34, 211, 238, 0.22), transparent 60%),
        radial-gradient(ellipse 80% 50% at 50% 100%, rgba(244, 114, 182, 0.15), transparent 60%),
        radial-gradient(1.5px 1.5px at 10% 20%, #fff, transparent),
        radial-gradient(1px 1px at 30% 70%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 50% 40%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 70% 80%, #fff, transparent),
        radial-gradient(1px 1px at 85% 25%, #fff, transparent),
        radial-gradient(1px 1px at 15% 85%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 60% 15%, #fff, transparent),
        radial-gradient(1px 1px at 95% 60%, #fff, transparent),
        radial-gradient(1px 1px at 40% 92%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 5% 55%, #fff, transparent);
    background-repeat: no-repeat, no-repeat, no-repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat;
    background-size: 100% 100%, 100% 100%, 100% 100%, 220px 220px, 260px 260px, 190px 190px, 300px 300px, 240px 240px, 210px 210px, 280px 280px, 230px 230px, 250px 250px, 200px 200px;
    background-attachment: fixed;
}

.modern-gradient-text {
    background: var(--ma-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Login / register / forgot / reset screens ---------- */

body.login, body.register, body.forgot-password, body.reset-password {
    color: var(--ma-text);
}

#login {
    max-width: 380px;
    margin: 3rem auto 0;
    padding: 2.5rem;
    background: var(--ma-surface);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius);
    box-shadow: var(--ma-glow), 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* Note: intentionally NOT "#login h1" -- core's global CSS has h1{float:right;margin:0} for
   the YOURLS logo heading, which any other h1 on the page inherits too. Use h2 instead. */
.modern-auth-title {
    font-size: 1.4rem;
    margin: 0 0 1.25rem;
    color: var(--ma-text);
    float: none;
}

#login label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ma-muted);
}

#login input.text,
#login input[type="email"],
#login input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.75rem;
    margin-top: 0.35rem;
    border: 1px solid var(--ma-border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--ma-text);
}

#login input.text:focus,
#login input[type="email"]:focus,
#login input[type="password"]:focus {
    outline: none;
    border-color: var(--ma-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

#login input.button,
#login input[type="submit"] {
    background: var(--ma-gradient);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.3rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

#login input.button:hover,
#login input[type="submit"]:hover {
    box-shadow: 0 6px 22px rgba(139, 92, 246, 0.6);
}

.modern-auth-register-link {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.9rem;
}

.modern-auth-register-link a {
    color: var(--ma-accent);
    text-decoration: none;
}

.modern-auth-success {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
}

#error-message.error {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
}

/* ---------- Public landing page ---------- */

body.modern-landing {
    margin: 0;
    color: var(--ma-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.landing-wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.landing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
}

.landing-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.landing-logo-mark {
    width: 130px !important;
    height: auto;
    flex-shrink: 0;
    filter: hue-rotate(60deg) saturate(2.2) brightness(1.15) drop-shadow(0 0 10px rgba(139, 92, 246, 0.6));
}

.landing-nav-link {
    color: var(--ma-text);
    text-decoration: none;
    margin-right: 1rem;
    font-weight: 500;
}

.landing-btn {
    display: inline-block;
    padding: 0.65rem 1.4rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}

.landing-btn-primary {
    background: var(--ma-gradient);
    color: #fff;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.45);
}

.landing-btn-primary:hover {
    box-shadow: 0 6px 28px rgba(139, 92, 246, 0.65);
}

.landing-btn-secondary {
    background: var(--ma-surface);
    color: var(--ma-text);
    border: 1px solid var(--ma-border);
}

.landing-btn-ghost {
    background: transparent;
    color: var(--ma-accent);
    border: 1px solid var(--ma-accent);
}

.landing-hero {
    text-align: center;
    padding: 6rem 0 4rem;
}

.landing-hero h1 {
    font-size: 3rem;
    line-height: 1.15;
    margin: 0 0 1.25rem;
    letter-spacing: -0.02em;
}

.landing-tagline {
    color: var(--ma-muted);
    font-size: 1.15rem;
    max-width: 560px;
    margin: 0 auto 2.25rem;
}

.landing-cta {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.landing-shorten-form {
    max-width: 640px;
    margin: 0 auto 1.5rem;
}

.landing-shorten-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.landing-shorten-row input[type="url"],
.landing-shorten-row input[type="text"] {
    flex: 1 1 200px;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--ma-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--ma-text);
    font-size: 0.95rem;
}

.landing-shorten-row input[type="url"]:focus,
.landing-shorten-row input[type="text"]:focus {
    outline: none;
    border-color: var(--ma-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.landing-shorten-row input[type="text"] {
    flex: 0 1 200px;
}

.landing-shorten-row .landing-btn {
    border: none;
    cursor: pointer;
    font: inherit;
}

.landing-shorten-message {
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
}

.landing-shorten-error {
    color: #fca5a5;
}

.landing-shorten-success {
    color: #6ee7b7;
}

.landing-shorten-success a {
    color: #6ee7b7;
    font-weight: 600;
}

@media (max-width: 640px) {
    .landing-shorten-row {
        flex-direction: column;
    }
    .landing-shorten-row input[type="text"] {
        flex: 1 1 auto;
    }
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    padding: 2rem 0 5rem;
}

.landing-feature {
    background: var(--ma-surface);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius);
    padding: 1.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.landing-feature:hover {
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: var(--ma-glow);
}

.landing-feature h3 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.landing-feature p {
    margin: 0;
    color: var(--ma-muted);
    font-size: 0.9rem;
}

.landing-footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--ma-muted);
    font-size: 0.85rem;
}

.landing-footer a {
    color: var(--ma-muted);
}

@media (max-width: 640px) {
    .landing-hero h1 {
        font-size: 2rem;
    }
    .landing-features {
        grid-template-columns: 1fr;
    }
    .landing-cta {
        flex-direction: column;
        align-items: center;
    }
}

/* ---------- Admin dashboard (link list + sidebar) ---------- */

/* Core's #wrap is a fixed max-width:950px + white card, sized for the original light theme.
   Restyle it as a dark glass panel for EVERY admin page (not just index/bookmark -- this used
   to be scoped to a hardcoded list of contexts and silently stayed white on any admin page not
   in that list, eg plugin admin pages like "Manage Users"). .modern-space-bg is added via the
   'bodyclass' filter to every page this plugin's yourls_html_head() runs on, so it covers all
   of them, present and future, without having to keep this list in sync. */
body.modern-space-bg {
    color: var(--ma-text);
}

body.modern-space-bg #wrap {
    max-width: 1400px;
    background: var(--ma-surface);
    border: 1px solid var(--ma-border);
    box-shadow: var(--ma-glow), 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* Login/register/forgot/reset: #login (not #wrap) is the visible card, so keep #wrap itself
   invisible and narrower there. */
body.login #wrap, body.register #wrap, body.forgot-password #wrap, body.reset-password #wrap {
    max-width: 950px;
    background: transparent;
    border: none;
    box-shadow: none;
}

body.modern-space-bg a {
    color: var(--ma-accent);
}

#overall_tracking, #wrap p {
    color: var(--ma-muted);
}

.modern-dash {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    align-items: start;
}

.modern-dash-main {
    min-width: 0; /* let the table scroll instead of overflowing the grid column */
    overflow-x: auto;
}

.modern-dash-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 1rem;
}

.modern-card {
    background: var(--ma-surface-alt);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius);
    padding: 1.25rem;
}

.modern-card h3 {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    color: var(--ma-text);
}

.modern-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.4rem;
}

.modern-stat-row .modern-stat-label {
    color: var(--ma-muted);
    font-size: 0.85rem;
}

.modern-stat-row .modern-stat-value {
    font-weight: 700;
    font-size: 1.1rem;
    background: var(--ma-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.modern-tip {
    display: flex;
    gap: 0.6rem;
    padding: 0.6rem 0;
    font-size: 0.85rem;
    color: var(--ma-muted);
    border-top: 1px solid var(--ma-border);
}

.modern-tip:first-of-type {
    border-top: none;
}

.modern-tip strong {
    color: var(--ma-text);
    display: block;
}

/* Override core's tablesorter.css (light theme, hardcoded colors) to fit the dark theme.
   Selector specificity matches or exceeds the originals; this stylesheet loads after
   tablesorter.css so it wins on ties too. */

table.tblSorter {
    background-color: transparent;
}

table.tblSorter thead tr th, table.tblSorter tfoot tr th, table.tblSorter th.header {
    background-color: var(--ma-surface-alt);
    color: var(--ma-text);
    border: 1px solid var(--ma-border);
}

table.tblSorter tfoot tr th {
    background-color: var(--ma-surface-alt);
}

table.tblSorter tbody td {
    color: var(--ma-text);
    background-color: var(--ma-surface);
    border-bottom: 1px solid var(--ma-border);
}

table.tblSorter tbody tr.normal-row td {
    background: var(--ma-surface);
}

table.tblSorter tbody tr.alt-row td {
    background: var(--ma-surface-alt);
}

table.tblSorter tbody tr.normal-row:hover td,
table.tblSorter tbody tr.alt-row:hover td {
    background-color: rgba(139, 92, 246, 0.12);
}

table.tblSorter thead tr .tablesorter-headerAsc,
table.tblSorter thead tr .tablesorter-headerDesc {
    background-color: rgba(139, 92, 246, 0.25);
}

table.tblSorter tfoot tr {
    background-color: var(--ma-surface-alt);
}

.navigation .nav_link a, .navigation .nav_current {
    border: 1px solid var(--ma-border);
    background: var(--ma-surface-alt);
    color: var(--ma-text);
}

.navigation .nav_link a:hover {
    border-color: var(--ma-primary);
    background: rgba(139, 92, 246, 0.25);
}

#new_url {
    background: var(--ma-surface) !important;
    border-color: var(--ma-border) !important;
}

#new_url div, #sharebox, #new_url_form {
    background: var(--ma-surface-alt) !important;
    color: var(--ma-text);
}

#add-url, #add-keyword {
    background: rgba(255, 255, 255, 0.06);
    color: var(--ma-text);
    border: 1px solid var(--ma-border);
}

/* Excludes the per-row action icons (button_stats/share/edit/delete): those use
   background-image sprites in core's style.css designed for a light backing, not a solid
   fill -- the "background" shorthand here would reset background-image to none and erase
   the icon, so they're styled separately below instead of just being excluded from this. */
.button:not(.button_stats):not(.button_share):not(.button_edit):not(.button_delete),
input.button {
    background: var(--ma-gradient) !important;
    color: #fff !important;
    border: none !important;
}

td.actions .button {
    background-color: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid var(--ma-border) !important;
}

/* Click/badge cells in the main links table */

#main_table .clicks,
#main_table .unique {
    text-align: center;
}

.modern-badge {
    display: inline-block;
    min-width: 2.2em;
    padding: 0.15em 0.5em;
    border-radius: 999px;
    background: rgba(139, 92, 246, 0.18);
    border: 1px solid rgba(139, 92, 246, 0.4);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ma-text);
}

/* QR code thumbnail cell */

.modern-qr-code {
    width: 40px;
    height: 40px;
    cursor: pointer;
    background: #fff;
    border-radius: 4px;
    padding: 2px;
}

.modern-qr-code svg {
    width: 100%;
    height: 100%;
    display: block;
}

.modern-qr-popup {
    position: fixed;
    z-index: 9999;
    background: var(--ma-surface);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius);
    box-shadow: var(--ma-glow), 0 20px 50px rgba(0, 0, 0, 0.5);
    padding: 1rem;
    text-align: center;
}

.modern-qr-popup svg {
    width: 200px;
    height: 200px;
    background: #fff;
    border-radius: 8px;
    padding: 8px;
}

.modern-qr-popup a {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--ma-accent);
}

@media (max-width: 1300px) {
    .modern-dash {
        grid-template-columns: 1fr;
    }
    .modern-dash-sidebar {
        position: static;
    }
}

/* Footer "Powered by YOURLS": core wraps it in a big white pill with a border -- drop that
   and just leave a small, quiet line of text. */
body.modern-space-bg #footer p {
    background: transparent;
    border: none;
    box-shadow: none;
    max-width: none;
    color: var(--ma-muted);
    font-size: 0.8rem;
    padding: 0.5rem;
}

body.modern-space-bg #footer p a {
    background: none;
    padding-left: 0;
    color: var(--ma-accent);
}

/* ---------- Branding header/logo ---------- */

/* Core's default header (300px logo image + "YOURLS: Your Own URL Shortener" text) is fully
   replaced by .modern-brand-logo (injected via the 'html_logo' action, see plugin.php) --
   hide the original outright instead of fighting its layout. */
body.modern-space-bg header[role="banner"] {
    display: none;
}

.modern-brand-logo {
    display: block;
    width: fit-content;
    float: right;
}

.modern-brand-logo-mark {
    display: block;
    width: 150px;
    height: auto;
    filter: hue-rotate(60deg) saturate(2.2) brightness(1.15) drop-shadow(0 0 14px rgba(139, 92, 246, 0.6));
}

/* Login/register/forgot/reset: center the logo as a lockup above the card instead of
   floating it in a disconnected top-right corner. */
body.login .modern-brand-logo,
body.register .modern-brand-logo,
body.forgot-password .modern-brand-logo,
body.reset-password .modern-brand-logo {
    float: none;
    margin: 6vh auto 0;
}
