/* ── Ordynx Design System ─────────────────────────────────────────── */

/* Reset / Layout */
[x-cloak] {
    display: none !important;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: var(--line-height-body);
    color: var(--color-body);
    background-color: #f8fafc;
}

main {
    flex: 1;
}

/* Prevent horizontal overflow on all main containers */
.page-shell {
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
}

/* ── Typography ─────────────────────────────────────────────────── */
h1,
h2,
h3,
h4,
.heading-tight {
    font-family: var(--font-heading);
    letter-spacing: -0.01em;
    color: #111827;
}

p,
ul,
ol,
dl {
    color: var(--color-body);
}

/* ── Links ──────────────────────────────────────────────────────── */
a:not(.btn):not(.btn-link):not([class*="block"]):not([class*="flex"]):not([class*="group"]):not([class*="rounded"]):not([class*="inline-flex"]):not(nav a) {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease, text-decoration 0.15s ease;
}

a:not(.btn):not(.btn-link):not([class*="block"]):not([class*="flex"]):not([class*="group"]):not([class*="rounded"]):not([class*="inline-flex"]):not(nav a):hover {
    text-decoration: underline;
    text-underline-offset: 2px;
    filter: brightness(0.85);
}

.link-accent {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s ease;
}

.link-accent:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
    filter: brightness(0.85);
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.75rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    border: 1px solid transparent;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid rgba(79, 70, 229, 0.45);
    outline-offset: 3px;
}

.btn[disabled],
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--primary-contrast);
}

.btn-primary:hover {
    filter: brightness(0.92);
}

.btn-primary:active {
    filter: brightness(0.84);
}

.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.8125rem;
    border-radius: 0.65rem;
    gap: 0.4rem;
}

.btn-secondary {
    background-color: #ffffff;
    color: #1f2937;
    border-color: #c7d2fe;
}

.btn-secondary:hover {
    background-color: #f8fafc;
    color: #1f2937;
}

.btn-secondary:active {
    background-color: #e2e8f0;
}

.btn-ghost {
    background-color: transparent;
    color: var(--primary-color);
    border-color: transparent;
    box-shadow: none;
}

.btn-ghost:hover {
    background-color: rgba(0,0,0,0.04);
}

.btn-danger {
    background-color: #dc2626;
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-warning {
    background-color: #f59e0b;
    color: #1f2937;
}

.btn-warning:hover {
    background-color: #d97706;
}

.btn-light {
    background-color: #e0e7ff;
    color: #4338ca;
}

.btn-light:hover {
    background-color: #c7d2ff;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

/* ── Stat Cards ─────────────────────────────────────────────────── */
.stat-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.stat-card-text {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
}

.stat-value {
    display: block;
    margin-top: 0.5rem;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
    font-size: clamp(1.35rem, 0.95rem + 1vw, 2.1rem);
    line-height: 1.1;
}

.stat-value-sm {
    font-size: clamp(1.15rem, 0.9rem + 0.7vw, 1.7rem);
}

.stat-value-xs {
    font-size: clamp(1rem, 0.85rem + 0.6vw, 1.45rem);
}

@media (max-width: 1280px) {
    .stat-card {
        gap: 0.75rem;
    }
}

/* ── Layout ─────────────────────────────────────────────────────── */

.section-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
}

@media (max-width: 768px) {
    body {
        font-size: 14.5px;
    }

    .section-stack {
        gap: 2rem;
    }

    /* Prevent horizontal overflow on mobile */
    main {
        max-width: 100%;
    }

    /* Better touch targets on mobile */
    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
    }
}

/* ── Organisation accent overrides ──────────────────────────────── */
#logo-header-placeholder,
.w-8.h-8.bg-indigo-600,
.h-10.w-10.bg-indigo-600 {
    background-color: var(--primary-color) !important;
    color: var(--primary-contrast) !important;
}

.text-indigo-800 {
    color: var(--primary-color) !important;
}

.border-indigo-200 {
    border-color: rgba(0,0,0,0.06) !important;
}

.bg-indigo-600 {
    background-color: var(--primary-color) !important;
}

.hover\:bg-indigo-700:hover {
    background-color: var(--primary-color) !important;
    filter: brightness(0.92);
}

.text-indigo-600 {
    color: var(--primary-color) !important;
}

.from-indigo-50 {
    --tw-gradient-from: color-mix(in srgb, var(--primary-color) 8%, transparent);
}

.from-indigo-600 {
    --tw-gradient-from: var(--primary-color) !important;
}

.to-purple-600 {
    --tw-gradient-to: var(--primary-color) !important;
}

.text-indigo-100 {
    color: color-mix(in srgb, var(--primary-color) 12%, #ffffff) !important;
}

.bg-indigo-50 {
    background-color: color-mix(in srgb, var(--primary-color) 8%, #ffffff) !important;
}

.hover\:bg-indigo-50:hover {
    background-color: color-mix(in srgb, var(--primary-color) 8%, #ffffff) !important;
}

/* ── Mobile bottom navigation safe area ─────────────────────────── */
.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 767px) {
    /* Ensure legal tables don't cause overflow */
    .legal-body table {
        font-size: 0.8rem;
    }
    .legal-body table th,
    .legal-body table td {
        padding: 0.375rem 0.5rem;
    }
}
