/*
 * PackURL 2026 visual refresh
 * Presentation-only overrides: no application behavior is changed.
 */
:root {
    --pu-bg: #f5f7ff;
    --pu-surface: rgba(255, 255, 255, .88);
    --pu-surface-solid: #ffffff;
    --pu-surface-soft: #eef2ff;
    --pu-ink: #111827;
    --pu-muted: #64748b;
    --pu-line: rgba(148, 163, 184, .24);
    --pu-primary: #6366f1;
    --pu-primary-dark: #4338ca;
    --pu-secondary: #06b6d4;
    --pu-accent: #8b5cf6;
    --pu-success: #10b981;
    --pu-danger: #f43f5e;
    --pu-warning: #f59e0b;
    --pu-navy: #081226;
    --pu-navy-soft: #111c38;
    --pu-radius-sm: 12px;
    --pu-radius: 18px;
    --pu-radius-lg: 26px;
    --pu-shadow-sm: 0 8px 24px rgba(15, 23, 42, .06);
    --pu-shadow: 0 18px 50px rgba(42, 52, 120, .12);
    --pu-shadow-hover: 0 24px 65px rgba(79, 70, 229, .18);
}

html { scroll-behavior: smooth; }

body {
    color: var(--pu-ink);
    background:
        radial-gradient(circle at 8% -10%, rgba(99, 102, 241, .13), transparent 28rem),
        radial-gradient(circle at 96% 12%, rgba(6, 182, 212, .10), transparent 25rem),
        var(--pu-bg);
    font-family: Inter, "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

::selection { color: #fff; background: var(--pu-primary); }

/* Brand compatibility: remap legacy utility colors without changing markup. */
.text-teal, .hover\:text-teal:hover { color: var(--pu-primary) !important; }
.text-teal-dark, .hover\:text-teal-dark:hover { color: var(--pu-primary-dark) !important; }
.text-primary { color: var(--pu-primary) !important; }
.text-dark { color: var(--pu-navy) !important; }
.bg-teal { background-color: var(--pu-primary) !important; }
.bg-teal-dark { background-color: var(--pu-primary-dark) !important; }
.bg-primary { background-color: var(--pu-primary) !important; }
.bg-dark { background-color: var(--pu-navy) !important; }
.border-teal { border-color: var(--pu-primary) !important; }
.border-primary { border-color: var(--pu-primary) !important; }
.from-teal { --tw-gradient-from: var(--pu-primary) var(--tw-gradient-from-position) !important; }
.to-teal-dark { --tw-gradient-to: var(--pu-primary-dark) var(--tw-gradient-to-position) !important; }
.from-primary { --tw-gradient-from: var(--pu-accent) var(--tw-gradient-from-position) !important; }
.to-primary { --tw-gradient-to: var(--pu-primary) var(--tw-gradient-to-position) !important; }
.focus\:border-teal:focus { border-color: var(--pu-primary) !important; }
.focus\:ring-teal:focus { --tw-ring-color: rgba(99, 102, 241, .28) !important; }

/* Navigation */
nav, header {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
body > nav, body > header {
    border-bottom: 1px solid rgba(148, 163, 184, .16);
}
nav img, header img { filter: saturate(.92) contrast(1.06); }
nav a, header a { letter-spacing: -.01em; }

/* Shared surfaces */
.bg-white {
    background-color: var(--pu-surface-solid) !important;
}
.bg-gray-50, .bg-gray-100 {
    background-color: var(--pu-surface-soft) !important;
}
.border, .border-gray-100, .border-gray-200, .border-gray-300 {
    border-color: var(--pu-line) !important;
}
.shadow, .shadow-md, .shadow-lg, .shadow-xl, .shadow-2xl {
    box-shadow: var(--pu-shadow-sm) !important;
}
.rounded-lg { border-radius: var(--pu-radius-sm) !important; }
.rounded-xl, .rounded-2xl { border-radius: var(--pu-radius) !important; }
.rounded-3xl { border-radius: var(--pu-radius-lg) !important; }

main .bg-white,
section .bg-white,
.modal-content,
[class*="shadow"][class*="rounded"] {
    border: 1px solid var(--pu-line);
}

main .bg-white,
section .bg-white {
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

main .bg-white:hover,
section .bg-white:hover {
    border-color: rgba(99, 102, 241, .22);
}

/* Type */
h1, h2, h3, h4 {
    color: var(--pu-navy);
    letter-spacing: -.035em !important;
}
h1 { line-height: 1.03 !important; }
p { line-height: 1.7; }
.text-gray-400 { color: #94a3b8 !important; }
.text-gray-500 { color: #64748b !important; }
.text-gray-600 { color: #526077 !important; }
.text-gray-700 { color: #334155 !important; }
.text-gray-800, .text-gray-900 { color: var(--pu-ink) !important; }

/* Buttons and interactive controls */
button,
input[type="submit"],
[role="button"],
a[class*="px-"][class*="py-"][class*="rounded"] {
    transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease !important;
}
button:hover,
input[type="submit"]:hover,
[role="button"]:hover {
    transform: translateY(-1px);
}
button:active,
input[type="submit"]:active,
[role="button"]:active {
    transform: translateY(0) scale(.985);
}
.bg-gradient-to-r {
    background-image: linear-gradient(120deg, var(--pu-primary), var(--pu-secondary)) !important;
    box-shadow: 0 10px 25px rgba(79, 70, 229, .22);
}
.bg-gradient-to-r:hover { box-shadow: 0 15px 34px rgba(79, 70, 229, .30) !important; }

input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    min-height: 44px;
    color: var(--pu-ink);
    background: rgba(255, 255, 255, .9) !important;
    border-color: rgba(148, 163, 184, .35) !important;
    border-radius: var(--pu-radius-sm) !important;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, .025);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus,
select:focus {
    outline: none !important;
    background: #fff !important;
    border-color: var(--pu-primary) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .12) !important;
}
input::placeholder, textarea::placeholder { color: #94a3b8 !important; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--pu-primary); }

/* Dashboard shells */
.min-h-screen.flex > aside,
aside.bg-dark,
aside[class*="bg-gradient"] {
    background:
        radial-gradient(circle at 20% 0, rgba(99, 102, 241, .36), transparent 20rem),
        linear-gradient(165deg, var(--pu-navy-soft), var(--pu-navy) 65%) !important;
    border-right: 1px solid rgba(255, 255, 255, .07);
    box-shadow: 18px 0 55px rgba(8, 18, 38, .12);
}
aside a {
    border: 1px solid transparent;
    color: rgba(255, 255, 255, .72);
}
aside a:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, .08) !important;
    border-color: rgba(255, 255, 255, .08);
}
aside a.bg-white\/10,
aside a[class*="bg-white"] {
    color: #fff !important;
    background: linear-gradient(120deg, rgba(99, 102, 241, .34), rgba(6, 182, 212, .18)) !important;
    border-color: rgba(129, 140, 248, .28);
    box-shadow: inset 0 1px rgba(255, 255, 255, .08);
}

main { min-width: 0; }
main > header, main header.bg-white {
    background: rgba(255, 255, 255, .82) !important;
    border-bottom: 1px solid var(--pu-line);
    box-shadow: 0 6px 25px rgba(15, 23, 42, .03) !important;
}

/* Dashboard statistic cards */
.grid > .bg-white[class*="shadow"],
.grid > div[class*="rounded"][class*="shadow"] {
    position: relative;
    overflow: hidden;
}
.grid > .bg-white[class*="shadow"]::before,
.grid > div[class*="rounded"][class*="shadow"]::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--pu-primary), var(--pu-secondary));
    opacity: .8;
}
.grid > .bg-white[class*="shadow"]:hover,
.grid > div[class*="rounded"][class*="shadow"]:hover {
    transform: translateY(-3px);
    box-shadow: var(--pu-shadow-hover) !important;
}

/* Tables */
.overflow-x-auto {
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, .35) transparent;
}
table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}
thead {
    background: linear-gradient(180deg, #f8faff, #f1f5ff) !important;
}
th {
    color: #536078 !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: .075em !important;
    text-transform: uppercase;
}
td { color: #334155; }
tbody tr { transition: background .16s ease, transform .16s ease; }
tbody tr:hover { background: rgba(99, 102, 241, .045) !important; }
tbody tr:last-child td { border-bottom: 0; }

/* Badges */
[class*="bg-green-100"] { color: #047857 !important; background: #d1fae5 !important; }
[class*="bg-blue-100"] { color: #4338ca !important; background: #e0e7ff !important; }
[class*="bg-purple-100"] { color: #7c3aed !important; background: #ede9fe !important; }
[class*="bg-yellow-100"] { color: #b45309 !important; background: #fef3c7 !important; }
[class*="bg-red-100"] { color: #be123c !important; background: #ffe4e6 !important; }

/* Analytics */
canvas {
    max-width: 100%;
    filter: drop-shadow(0 8px 14px rgba(99, 102, 241, .05));
}
[id*="Chart"], [id*="chart"] {
    animation: puFadeUp .45s ease both;
}
.chart-container,
[class*="chart-container"] {
    padding: 8px;
    border-radius: var(--pu-radius);
}

/* Modals */
.fixed.inset-0[class*="bg-black"],
.fixed.inset-0[class*="bg-opacity"] {
    background: rgba(8, 18, 38, .66) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.fixed.inset-0 > .bg-white {
    border: 1px solid rgba(255, 255, 255, .5);
    box-shadow: 0 30px 100px rgba(2, 6, 23, .35) !important;
    animation: puModalIn .25s ease both;
}

/* Public marketing surfaces */
section { position: relative; }
section[class*="gradient"] {
    background-image:
        radial-gradient(circle at 10% 15%, rgba(99, 102, 241, .16), transparent 25rem),
        radial-gradient(circle at 88% 35%, rgba(6, 182, 212, .13), transparent 24rem),
        linear-gradient(180deg, #f8faff, #eef2ff) !important;
}
footer {
    background:
        radial-gradient(circle at 85% 0, rgba(99, 102, 241, .24), transparent 26rem),
        var(--pu-navy) !important;
}

/* Login and registration */
body > .min-h-screen[class*="flex"],
body > main.min-h-screen {
    background:
        radial-gradient(circle at 15% 10%, rgba(99, 102, 241, .18), transparent 25rem),
        radial-gradient(circle at 90% 90%, rgba(6, 182, 212, .13), transparent 25rem),
        var(--pu-bg);
}

pre, code {
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace !important;
}
pre {
    color: #dbeafe !important;
    background: #09152d !important;
    border: 1px solid rgba(129, 140, 248, .18);
    border-radius: var(--pu-radius-sm);
    box-shadow: inset 0 1px rgba(255, 255, 255, .05);
}

/* Accessible focus */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(99, 102, 241, .35) !important;
    outline-offset: 3px;
}

@keyframes puFadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes puModalIn {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1024px) {
    :root { --pu-radius: 16px; --pu-radius-lg: 22px; }
    main .p-8 { padding: 1.35rem !important; }
}

@media (max-width: 768px) {
    body { background-color: #f7f8ff; }
    h1 { letter-spacing: -.04em !important; }
    .p-8 { padding: 1.25rem !important; }
    .p-6 { padding: 1rem !important; }
    table { min-width: 680px; }
    .fixed.inset-0 > .bg-white {
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
        margin: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Page-level composition
   -------------------------------------------------------------------------- */

/* Public home */
body:has(#quickShortenForm) #mainNav {
    background: rgba(255, 255, 255, .78) !important;
    box-shadow: 0 1px 0 var(--pu-line), 0 10px 35px rgba(15, 23, 42, .035) !important;
}
body:has(#quickShortenForm) #mainNav > div {
    max-width: 1240px;
}
body:has(#quickShortenForm) #megaMenu {
    border: 1px solid rgba(99, 102, 241, .14);
    border-radius: 22px;
    box-shadow: 0 28px 80px rgba(15, 23, 42, .16);
    overflow: hidden;
}
body:has(#quickShortenForm) #mobileMenu {
    background: rgba(255, 255, 255, .96) !important;
    box-shadow: 0 20px 45px rgba(15, 23, 42, .12);
}
body:has(#quickShortenForm) #quickShortenForm,
body:has(#quickShortenForm) #qrGenerateForm {
    position: relative;
}
body:has(#quickShortenForm) #tabShorten,
body:has(#quickShortenForm) #tabQr {
    min-height: 60px;
}
body:has(#quickShortenForm) .tab-active {
    color: var(--pu-primary) !important;
    background: linear-gradient(180deg, rgba(99, 102, 241, .09), rgba(99, 102, 241, .02)) !important;
    box-shadow: inset 0 -3px var(--pu-primary);
}
body:has(#quickShortenForm) .tab-inactive {
    color: var(--pu-muted) !important;
    background: rgba(248, 250, 252, .72) !important;
}
body:has(#quickShortenForm) #contentShorten,
body:has(#quickShortenForm) #contentQr {
    background:
        radial-gradient(circle at 100% 0, rgba(99, 102, 241, .07), transparent 20rem),
        #fff;
}
body:has(#quickShortenForm) #quickResult,
body:has(#quickShortenForm) #qrResult {
    border: 1px solid rgba(16, 185, 129, .18);
    border-radius: var(--pu-radius);
    background: linear-gradient(145deg, rgba(236, 253, 245, .85), rgba(238, 242, 255, .82));
    padding: 1rem;
}
body:has(#quickShortenForm) #linkHistory {
    scrollbar-gutter: stable;
    padding-right: .35rem;
}
body:has(#quickShortenForm) #linkHistory > * {
    border: 1px solid var(--pu-line);
    border-radius: 14px;
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
body:has(#quickShortenForm) #linkHistory > *:hover {
    transform: translateX(3px);
    border-color: rgba(99, 102, 241, .32);
    box-shadow: var(--pu-shadow-sm);
}

/* Client dashboard */
body:has(#userSidebar) {
    background:
        radial-gradient(circle at 80% 0, rgba(99, 102, 241, .09), transparent 34rem),
        #f6f8ff;
}
#userSidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
#userSidebar > div { min-height: 100%; }
#userSidebar nav { display: grid; gap: .35rem; }
#userSidebar nav a,
#userSidebar nav button {
    min-height: 46px;
    padding: .75rem .9rem;
    border-radius: 13px !important;
}
body:has(#userSidebar) main > header {
    position: sticky;
    top: 0;
    z-index: 30;
}
body:has(#userSidebar) main > .container {
    max-width: 1480px !important;
}
#overview h2 {
    font-size: clamp(1.8rem, 3vw, 2.35rem);
}
#overviewCards {
    gap: 1rem !important;
}
#overviewCards > div {
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.35rem !important;
    isolation: isolate;
}
#overviewCards > div::after {
    content: "";
    position: absolute;
    width: 120px;
    height: 120px;
    right: -45px;
    bottom: -55px;
    z-index: -1;
    border-radius: 999px;
    background: rgba(255, 255, 255, .11);
}
#overviewCards > div p[id] {
    font-variant-numeric: tabular-nums;
    letter-spacing: -.055em;
}
#create, #api, #account, #urls {
    border: 1px solid rgba(148, 163, 184, .20);
    box-shadow: 0 14px 45px rgba(30, 41, 59, .065) !important;
}
#create > h2, #api h2, #account h2, #urls h2 {
    font-size: 1.35rem;
}
#rotCreateSection {
    padding: 1rem;
    border: 1px dashed rgba(99, 102, 241, .35);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(238, 242, 255, .72), rgba(236, 254, 255, .55));
}
#apiPanel > div,
#account > div:last-child > div {
    border: 1px solid var(--pu-line);
    background: linear-gradient(145deg, #fff, #f8faff) !important;
}
#apiExamples > div > div {
    border: 1px solid var(--pu-line);
    border-radius: 14px;
    overflow: hidden;
}
#urlsList > div {
    border: 1px solid var(--pu-line);
    border-radius: 16px;
    background: #fff;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
#urlsList > div:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, .30);
    box-shadow: var(--pu-shadow-sm);
}

/* Analytics panels in both dashboards */
#analyticsModal > div,
#adminAnalyticsModal > div {
    width: min(1120px, calc(100vw - 2rem)) !important;
    max-height: calc(100vh - 2rem) !important;
    overflow-y: auto;
    scrollbar-gutter: stable;
}
#analyticsModal canvas,
#adminAnalyticsModal canvas {
    min-height: 220px;
}
#analyticsModal .grid > div,
#adminAnalyticsModal .grid > div {
    border: 1px solid var(--pu-line);
    background: linear-gradient(145deg, #fff, #f8faff) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
#metricToday, #metricWeek, #metricMonth,
#adminMetricToday, #adminMetricWeek, #adminMetricMonth {
    color: var(--pu-primary) !important;
    font-variant-numeric: tabular-nums;
}
#referrersList > div,
#adminReferrersList > div {
    padding: .75rem .9rem;
    border: 1px solid var(--pu-line);
    border-radius: 12px;
    background: #fff;
}
#recentClicks, #adminRecentClicks {
    border: 1px solid var(--pu-line);
    border-radius: 14px;
}
#rotatorPerfSection, #adminRotatorPerfSection {
    border: 1px solid rgba(99, 102, 241, .16);
    background: linear-gradient(145deg, #f8faff, #eef2ff) !important;
}

/* Admin suite */
body:has(a[href="users.php"]) aside,
body:has(a[href="urls.php"]) aside {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
body:has(a[href="users.php"]) main,
body:has(a[href="urls.php"]) main {
    background:
        radial-gradient(circle at 100% 0, rgba(139, 92, 246, .08), transparent 32rem),
        #f6f8ff;
}
body:has(a[href="users.php"]) main > div,
body:has(a[href="urls.php"]) main > div {
    max-width: 1500px;
    margin-inline: auto;
}
body:has(a[href="users.php"]) main table,
body:has(a[href="urls.php"]) main table {
    background: #fff;
}
body:has(a[href="users.php"]) main .overflow-x-auto,
body:has(a[href="urls.php"]) main .overflow-x-auto {
    border-radius: 0 0 var(--pu-radius) var(--pu-radius);
}
#adminUserSearch {
    padding-left: 2.65rem !important;
    background-image: linear-gradient(45deg, transparent 48%, #64748b 49%, #64748b 54%, transparent 55%) !important;
    background-repeat: no-repeat !important;
    background-size: 8px 8px !important;
    background-position: 1.15rem 1.05rem !important;
}
#adminUserLinks {
    overflow: hidden;
    border-color: rgba(99, 102, 241, .20);
}
#adminUserLinksContainer > * {
    border: 1px solid var(--pu-line);
    border-radius: 13px;
}

/* Auth pages */
body:has(#password):not(:has(#userSidebar)) > div.min-h-screen,
body:has(#confirmPassword):not(:has(#userSidebar)) > div.min-h-screen {
    position: relative;
    overflow: hidden;
}
body:has(#password):not(:has(#userSidebar)) > div.min-h-screen::before,
body:has(#confirmPassword):not(:has(#userSidebar)) > div.min-h-screen::before {
    content: "";
    position: fixed;
    width: 460px;
    height: 460px;
    border-radius: 999px;
    top: -180px;
    right: -120px;
    background: linear-gradient(145deg, rgba(99, 102, 241, .20), rgba(6, 182, 212, .12));
    filter: blur(2px);
    pointer-events: none;
}
body:has(#password):not(:has(#userSidebar)) form,
body:has(#confirmPassword):not(:has(#userSidebar)) form {
    position: relative;
}

/* Better mobile dashboard behavior */
@media (max-width: 767px) {
    #userSidebar.fixed {
        width: min(86vw, 320px) !important;
        right: auto !important;
        box-shadow: 30px 0 80px rgba(2, 6, 23, .42);
        animation: puSidebarIn .22s ease both;
    }
    #sidebarToggleBtn {
        min-width: 44px;
        min-height: 42px;
        font-size: 0;
    }
    #sidebarToggleBtn::after {
        content: "☰";
        font-size: 1.25rem;
    }
    body:has(#userSidebar) main > header > div {
        padding-inline: 1rem !important;
    }
    body:has(#userSidebar) main > header h1 {
        font-size: 1.15rem !important;
    }
    #overviewCards { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    #overviewCards > div { min-height: 135px; }
    #overviewCards .text-4xl { font-size: 1.85rem !important; }
    #analyticsModal > div,
    #adminAnalyticsModal > div {
        width: calc(100vw - 1rem) !important;
        max-height: calc(100vh - 1rem) !important;
    }
}

@media (max-width: 440px) {
    #overviewCards { grid-template-columns: 1fr !important; }
    #overviewCards > div { min-height: 120px; }
    #apiPanel { grid-template-columns: 1fr !important; }
}

@keyframes puSidebarIn {
    from { opacity: 0; transform: translateX(-18px); }
    to { opacity: 1; transform: translateX(0); }
}
