/* Paygital design system */

:root {
    /* Primitive brand colors */
    --brand-navy: #020d3b;
    --brand-blue: #185efc;
    --brand-violet: #5b24f5;
    --brand-mist: #f6f8fc;
    --brand-white: #ffffff;
    --brand-navy-rgb: 2 13 59;
    --brand-blue-rgb: 24 94 252;
    --brand-violet-rgb: 91 36 245;
    --brand-mist-rgb: 246 248 252;
    --brand-white-rgb: 255 255 255;

    /* Primitive supporting colors */
    --neutral-soft-rgb: 238 242 248;
    --neutral-border-rgb: 221 227 238;
    --neutral-muted-rgb: 89 98 122;
    --nav-hover-rgb: 17 30 76;
    --nav-border-rgb: 31 45 91;
    --nav-muted-rgb: 175 192 218;
    --primary-hover-rgb: 18 76 210;
    --primary-active-rgb: 14 58 165;
    --primary-soft-rgb: 232 239 255;
    --primary-border-rgb: 184 202 255;
    --accent-soft-rgb: 239 233 255;
    --accent-hover-rgb: 72 22 212;

    /* Primitive typography, shape, shadow, and motion */
    --font-family-heading: Nunito, "DM Sans", Arial, sans-serif;
    --font-family-subtitle: Nunito, "DM Sans", Arial, sans-serif;
    --font-family-body: "DM Sans", Arial, sans-serif;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px rgb(2 13 59 / 0.06);
    --shadow-md: 0 16px 38px -24px rgb(2 13 59 / 0.42);
    --shadow-lg: 0 28px 70px -32px rgb(2 13 59 / 0.55);
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;

    /* Semantic colors */
    --color-background-rgb: var(--brand-mist-rgb);
    --color-surface-rgb: var(--brand-white-rgb);
    --color-foreground-rgb: var(--brand-navy-rgb);
    --color-muted-rgb: var(--neutral-soft-rgb);
    --color-muted-foreground-rgb: var(--neutral-muted-rgb);
    --color-border-rgb: var(--neutral-border-rgb);
    --color-input-rgb: var(--neutral-border-rgb);
    --color-primary-rgb: var(--brand-blue-rgb);
    --color-primary-hover-rgb: var(--primary-hover-rgb);
    --color-primary-active-rgb: var(--primary-active-rgb);
    --color-primary-soft-rgb: var(--primary-soft-rgb);
    --color-primary-border-rgb: var(--primary-border-rgb);
    --color-primary-foreground-rgb: var(--brand-white-rgb);
    --color-accent-rgb: var(--brand-violet-rgb);
    --color-accent-hover-rgb: var(--accent-hover-rgb);
    --color-accent-soft-rgb: var(--accent-soft-rgb);
    --color-accent-foreground-rgb: var(--brand-white-rgb);
    --color-ring-rgb: var(--brand-blue-rgb);
    --color-nav-rgb: var(--brand-navy-rgb);
    --color-nav-hover-rgb: var(--nav-hover-rgb);
    --color-nav-border-rgb: var(--nav-border-rgb);
    --color-nav-foreground-rgb: var(--brand-white-rgb);
    --color-nav-muted-rgb: var(--nav-muted-rgb);
    --color-success-bg: #ecfdf3;
    --color-success-border: #a7f3d0;
    --color-success-text: #166534;
    --color-danger-bg: #fff1f2;
    --color-danger-border: #fecdd3;
    --color-danger-text: #9f1239;
    --color-warning-bg: #fffbeb;
    --color-warning-border: #fde68a;
    --color-warning-text: #92400e;
    --color-info-bg: var(--brand-mist);
    --color-info-border: rgb(var(--primary-border-rgb));
    --color-info-text: var(--brand-navy);

    /* Component tokens */
    --button-bg: var(--brand-blue);
    --button-bg-hover: #124cd2;
    --button-bg-active: #0e3aa5;
    --button-fg: var(--brand-white);
    --button-radius: 0.65rem;
    --input-bg: var(--brand-white);
    --input-border: rgb(var(--color-input-rgb));
    --input-focus: var(--brand-blue);
    --card-bg: var(--brand-white);
    --card-border: rgb(var(--color-border-rgb));
    --card-radius: var(--radius-lg);
    --card-shadow: var(--shadow-sm);
    --topbar-control-size: 2.75rem;
    --topbar-menu-width: 18rem;
}

[x-cloak] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
    background: rgb(var(--color-background-rgb));
}

body {
    margin: 0;
    background: rgb(var(--color-background-rgb));
    color: rgb(var(--color-foreground-rgb));
    font-family: var(--font-family-body);
}

.font-heading,
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-family-heading);
}

.font-subtitle {
    font-family: var(--font-family-subtitle);
}

.app-shell {
    position: relative;
    min-width: 100%;
}

.app-sidebar {
    background:
        radial-gradient(circle at 18% 4%, rgb(var(--brand-blue-rgb) / 0.2), transparent 24rem),
        rgb(var(--color-nav-rgb));
}

.app-sidebar .nav-icon {
    display: inline-flex;
    width: 1.25rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-size: 1.125rem;
}

.app-sidebar .nav-submenu-icon {
    width: 1rem;
    margin-right: 0.5rem;
    font-size: 0.875rem;
}

.app-topbar {
    box-shadow: var(--shadow-sm);
}

.topbar-control {
    display: inline-flex;
    min-width: var(--topbar-control-size);
    height: var(--topbar-control-size);
    align-items: center;
    justify-content: center;
    border: 1px solid rgb(var(--color-border-rgb));
    border-radius: var(--radius-md);
    background: rgb(var(--color-surface-rgb));
    color: rgb(var(--color-muted-foreground-rgb));
    cursor: pointer;
    transition: background-color var(--duration-fast) ease-in-out, border-color var(--duration-fast) ease-in-out, color var(--duration-fast) ease-in-out;
}

.topbar-control:hover,
.topbar-control[aria-expanded="true"] {
    border-color: rgb(var(--color-primary-border-rgb));
    background: rgb(var(--color-primary-soft-rgb) / 0.55);
    color: rgb(var(--color-foreground-rgb));
}

.topbar-control-icon {
    width: var(--topbar-control-size);
}

.topbar-brand-link {
    display: inline-flex;
    width: var(--topbar-control-size);
    height: var(--topbar-control-size);
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    padding: 0.25rem;
    text-decoration: none;
    transition: background-color var(--duration-fast) ease-in-out;
}

.topbar-brand-link:hover {
    background: rgb(var(--color-primary-soft-rgb) / 0.55);
}

.topbar-brand-icon {
    display: block;
    width: auto;
    height: 2.25rem;
    object-fit: contain;
}

.topbar-user-control {
    border-color: rgb(var(--color-primary-border-rgb));
    border-radius: var(--radius-full);
    background: rgb(var(--color-primary-soft-rgb));
    color: rgb(var(--color-primary-rgb));
}

.topbar-menu-panel {
    max-width: calc(100vw - 2rem);
    transform-origin: top right;
}

.topbar-menu-panel.w-72 {
    width: var(--topbar-menu-width);
}

.topbar-menu-item {
    display: flex;
    width: 100%;
    min-height: 2.75rem;
    align-items: center;
    gap: 0.75rem;
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color var(--duration-fast) ease-in-out, color var(--duration-fast) ease-in-out;
}

.topbar-menu-item:hover {
    background: rgb(var(--color-muted-rgb));
}

.topbar-menu-item > i {
    width: 1.125rem;
    flex-shrink: 0;
    text-align: center;
    font-size: 1rem;
}

.brand-logo-link {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-sm);
}

.sidebar-brand-header {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo {
    display: block;
    height: auto;
    object-fit: contain;
}

.brand-logo-sidebar {
    width: 10rem;
}

.brand-logo-auth {
    width: 11rem;
    max-width: 100%;
}

.auth-page {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: var(--brand-navy);
}

.auth-page::before,
.auth-page::after {
    position: fixed;
    z-index: -1;
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.auth-page::before {
    top: -14rem;
    right: -10rem;
    width: 34rem;
    height: 34rem;
    border: 5.5rem solid rgb(var(--brand-blue-rgb) / 0.18);
}

.auth-page::after {
    bottom: -16rem;
    left: -10rem;
    width: 30rem;
    height: 30rem;
    border: 4.5rem solid rgb(var(--brand-violet-rgb) / 0.16);
}

.auth-panel {
    border: 1px solid rgb(var(--brand-white-rgb) / 0.32);
    background: rgb(var(--brand-white-rgb) / 0.98);
    box-shadow: var(--shadow-lg);
}

.dashboard-page {
    position: relative;
}

.dashboard-page::before {
    position: absolute;
    top: -0.4rem;
    right: 0;
    width: 6rem;
    height: 2.5rem;
    background-image: radial-gradient(circle, rgb(var(--brand-blue-rgb) / 0.2) 1.5px, transparent 1.5px);
    background-size: 0.75rem 0.75rem;
    content: "";
    pointer-events: none;
}

.card {
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid rgb(var(--color-border-rgb));
    padding: 1rem 1.25rem;
}

.dashboard-page .card {
    box-shadow: 0 4px 18px -14px rgb(2 13 59 / 0.3);
}

.dashboard-metric {
    display: block;
    text-decoration: none;
    transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease, transform var(--duration-normal) ease;
}

.dashboard-metric:hover {
    border-color: rgb(var(--color-primary-border-rgb));
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dashboard-action {
    display: flex;
    min-height: 7rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    border: 1px solid rgb(var(--color-border-rgb));
    border-radius: var(--radius-md);
    background: rgb(var(--color-surface-rgb));
    padding: 1rem;
    color: rgb(var(--color-foreground-rgb));
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--duration-normal) ease, background-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease, transform var(--duration-normal) ease;
}

.dashboard-action > span {
    display: flex;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    border-radius: 0.65rem;
    font-size: 1.25rem;
}

.dashboard-action > strong {
    display: block;
    max-width: 8rem;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
}

.dashboard-action:hover {
    border-color: rgb(var(--color-primary-border-rgb));
    background: rgb(var(--color-primary-soft-rgb) / 0.45);
    box-shadow: var(--shadow-sm);
    color: var(--brand-blue);
    transform: translateY(-2px);
}

.dashboard-action:active {
    box-shadow: none;
    transform: translateY(0);
}

.section-title {
    color: rgb(var(--color-foreground-rgb));
    font-family: var(--font-family-heading);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.page-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header-copy {
    min-width: 0;
}

.page-title {
    color: rgb(var(--color-foreground-rgb));
    font-family: var(--font-family-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.25;
}

.page-subtitle {
    margin-top: 0.25rem;
    color: rgb(var(--color-muted-foreground-rgb));
    font-size: 0.875rem;
    line-height: 1.5;
}

.page-header-actions {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.page-header-back,
.page-header-eyebrow {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.page-header-back {
    color: rgb(var(--color-muted-foreground-rgb));
    transition: color var(--duration-fast) ease-in-out;
}

.page-header-back:hover {
    color: rgb(var(--color-foreground-rgb));
}

.page-header-eyebrow {
    color: rgb(var(--color-primary-rgb));
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--button-radius);
    padding: 0.55rem 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--duration-fast) ease-in-out, border-color var(--duration-fast) ease-in-out, color var(--duration-fast) ease-in-out;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--button-bg);
    color: var(--button-fg);
}

.btn-primary:hover {
    background: var(--button-bg-hover);
}

.btn-primary:active {
    background: var(--button-bg-active);
}

.btn-secondary {
    border-color: rgb(var(--color-border-rgb));
    background: rgb(var(--color-surface-rgb));
    color: rgb(var(--color-foreground-rgb));
}

.btn-secondary:hover {
    border-color: rgb(var(--color-primary-border-rgb));
    background: rgb(var(--color-primary-soft-rgb) / 0.55);
}

.btn-success {
    border-color: var(--color-success-border);
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.btn-success:hover {
    filter: brightness(0.98);
}

.btn-outline-primary {
    border-color: var(--brand-blue);
    background: rgb(var(--color-surface-rgb));
    color: var(--brand-blue);
}

.btn-outline-primary:hover {
    background: rgb(var(--color-primary-soft-rgb));
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-full);
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
}

.badge-info {
    background: rgb(var(--color-primary-soft-rgb));
    color: var(--brand-navy);
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.focus-ring:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgb(var(--color-surface-rgb)), 0 0 0 4px rgb(var(--color-ring-rgb));
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
    background-color: var(--input-bg);
    color: rgb(var(--color-foreground-rgb));
}

input::placeholder,
textarea::placeholder {
    color: rgb(var(--color-muted-foreground-rgb));
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgb(var(--color-muted-rgb));
}

::-webkit-scrollbar-thumb {
    border-radius: var(--radius-full);
    background: rgb(var(--color-muted-foreground-rgb) / 0.65);
}

::-webkit-scrollbar-thumb:hover {
    background: rgb(var(--color-muted-foreground-rgb));
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-indicator {
    display: none;
}

@media (max-width: 640px) {
    .auth-page::before {
        top: -18rem;
        right: -18rem;
    }

    .auth-page::after {
        bottom: -20rem;
        left: -18rem;
    }

    .dashboard-page::before {
        display: none;
    }
}

@media (min-width: 640px) {
    .page-header {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }

    .page-title {
        font-size: 1.875rem;
    }

    .page-header-actions {
        width: auto;
        justify-content: flex-end;
        margin-left: auto;
    }
}

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

@media print {
    aside,
    nav,
    button,
    .dashboard-page::before {
        display: none !important;
    }

    body,
    main {
        background: white !important;
    }

    main {
        margin: 0 !important;
        padding: 0 !important;
    }
}
