/* ═══════════════════════════════════════════════════════════════
   shadcn/ui design system — adapted for Blazor + Bootstrap
   Tokens & component patterns from https://ui.shadcn.com/docs/installation
   (React/Tailwind originals mapped to CSS variables + Bootstrap overrides)
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* ── shadcn semantic tokens (HSL components) ── */
    --background: 30 25% 98%;
    --foreground: 20 14% 15%;
    --card: 0 0% 100%;
    --card-foreground: 20 14% 15%;
    --popover: 0 0% 100%;
    --popover-foreground: 20 14% 15%;
    --primary: 152 68% 19%;
    --primary-foreground: 0 0% 100%;
    --secondary: 56 20% 94%;
    --secondary-foreground: 60 10% 12%;
    --muted: 60 10% 96%;
    --muted-foreground: 60 5% 45%;
    --accent: 56 30% 92%;
    --accent-foreground: 60 10% 12%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 0 0% 98%;
    --success: 142 71% 45%;
    --success-foreground: 0 0% 100%;
    --warning: 38 92% 50%;
    --warning-foreground: 20 14% 15%;
    --border: 20 6% 90%;
    --input: 20 6% 88%;
    --ring: 57 42% 38%;
    --radius: 0.5rem;

    /* ── Bridge into existing temple tokens ── */
    --temple-page-bg: hsl(var(--background));
    --temple-surface: hsl(var(--card));
    --temple-parchment: hsl(var(--muted));
    --temple-text: hsl(var(--foreground));
    --temple-text-soft: hsl(var(--foreground) / 0.85);
    --temple-muted: hsl(var(--muted-foreground));
    --temple-border: hsl(var(--border));
    --temple-border-light: hsl(var(--border));
    --temple-border-input: hsl(var(--input));
    --temple-red: hsl(var(--primary));
    --temple-red-dark: var(--brand-800);
    --temple-maroon: hsl(var(--primary));
    --temple-radius-sm: var(--radius);
    --temple-radius: calc(var(--radius) + 2px);
    --temple-radius-lg: calc(var(--radius) + 4px);
    --temple-radius-xl: calc(var(--radius) + 8px);
    --temple-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --temple-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
    --temple-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
    --temple-focus-ring: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring) / 0.35);
    --temple-gradient-page: linear-gradient(180deg, hsl(var(--background)) 0%, hsl(30 20% 96%) 100%);

    /* Bootstrap 5 variable bridge */
    --bs-body-bg: hsl(var(--background));
    --bs-body-color: hsl(var(--foreground));
    --bs-border-color: hsl(var(--border));
    --bs-primary: #0F5132;
    --bs-primary-rgb: 15, 81, 50;
    --bs-secondary: hsl(var(--secondary));
    --bs-secondary-color: hsl(var(--muted-foreground));
    --bs-link-color: hsl(var(--primary));
    --bs-link-hover-color: var(--brand-800);
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: calc(var(--radius) - 2px);
    --bs-border-radius-lg: calc(var(--radius) + 2px);
    --bs-focus-ring-color: hsl(var(--ring) / 0.25);
}

/* ── Typography (shadcn: medium weight labels, tight tracking on headings) ── */
.theme-ayyappa {
    color: hsl(var(--foreground));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.theme-ayyappa h1,
.theme-ayyappa h2,
.theme-ayyappa h3,
.theme-ayyappa h4,
.theme-ayyappa h5,
.theme-ayyappa h6,
.theme-ayyappa .page-title {
    color: hsl(var(--foreground));
    font-weight: 600;
    letter-spacing: -0.025em;
}

.theme-ayyappa .text-muted,
.theme-ayyappa .form-text,
.theme-ayyappa small.text-muted {
    color: hsl(var(--muted-foreground)) !important;
}

/* ── Card (shadcn: rounded-lg border bg-card shadow-sm) ── */
.theme-ayyappa .card {
    background-color: hsl(var(--card)) !important;
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border)) !important;
    border-radius: calc(var(--radius) + 2px) !important;
    box-shadow: var(--temple-shadow-sm) !important;
    padding: 0 !important;
    margin-bottom: 1rem;
    transform: none !important;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.theme-ayyappa .card:hover {
    transform: none !important;
    box-shadow: var(--temple-shadow) !important;
}

.theme-ayyappa .card-header {
    background-color: hsl(var(--muted) / 0.5) !important;
    border-bottom: 1px solid hsl(var(--border)) !important;
    padding: 1rem 1.25rem !important;
    font-weight: 600;
    font-size: 0.9375rem;
}

.theme-ayyappa .card-body {
    padding: 1.25rem;
}

.theme-ayyappa .card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0;
    letter-spacing: -0.01em;
}

/* ── Buttons (shadcn: h-9/h-10, font-medium, rounded-md) ── */
.theme-ayyappa .btn {
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.25rem;
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    min-height: 2.25rem;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: none;
}

.theme-ayyappa .btn-sm {
    font-size: 0.8125rem;
    min-height: 2rem;
    padding: 0.375rem 0.75rem;
}

.theme-ayyappa .btn-lg {
    min-height: 2.75rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
}

.theme-ayyappa .btn-primary {
    background-color: hsl(var(--primary)) !important;
    background-image: none !important;
    border: 1px solid hsl(var(--primary)) !important;
    color: hsl(var(--primary-foreground)) !important;
    border-radius: var(--radius) !important;
    min-height: 2.5rem;
    font-weight: 500;
    box-shadow: none !important;
    transform: none !important;
}

.theme-ayyappa .btn-primary:hover,
.theme-ayyappa .btn-primary:focus {
    background-color: var(--brand-800) !important;
    background-image: none !important;
    border-color: var(--brand-800) !important;
    color: hsl(var(--primary-foreground)) !important;
    transform: none !important;
    box-shadow: var(--temple-shadow-sm) !important;
}

.theme-ayyappa .btn-primary:active,
.theme-ayyappa .btn-primary.active {
    background-color: hsl(57 42% 30%) !important;
    border-color: hsl(57 42% 30%) !important;
    transform: scale(0.98) !important;
}

.theme-ayyappa .btn-secondary {
    background-color: hsl(var(--secondary));
    border-color: hsl(var(--border));
    color: hsl(var(--secondary-foreground));
}

.theme-ayyappa .btn-secondary:hover {
    background-color: hsl(30 12% 91%);
    border-color: hsl(var(--border));
    color: hsl(var(--secondary-foreground));
}

.theme-ayyappa .btn-outline-primary {
    color: hsl(var(--primary)) !important;
    border: 1px solid hsl(var(--border)) !important;
    background-color: transparent !important;
    border-radius: var(--radius) !important;
    font-weight: 500;
}

.theme-ayyappa .btn-outline-primary:hover {
    background-color: hsl(var(--accent)) !important;
    border-color: hsl(var(--primary) / 0.4) !important;
    color: hsl(var(--primary)) !important;
}

.theme-ayyappa .btn-outline-secondary {
    color: hsl(var(--foreground));
    border-color: hsl(var(--border));
    background-color: hsl(var(--background));
}

.theme-ayyappa .btn-outline-secondary:hover {
    background-color: hsl(var(--accent));
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
}

.theme-ayyappa .btn-outline-danger {
    color: hsl(var(--destructive));
    border-color: hsl(var(--border));
}

.theme-ayyappa .btn-outline-danger:hover {
    background-color: hsl(var(--destructive) / 0.08);
    border-color: hsl(var(--destructive) / 0.35);
    color: hsl(var(--destructive));
}

.theme-ayyappa .btn-warning {
    background-color: hsl(var(--warning));
    border-color: hsl(var(--warning));
    color: hsl(var(--warning-foreground));
}

.theme-ayyappa .btn-success {
    background-color: hsl(var(--success));
    border-color: hsl(var(--success));
    color: hsl(var(--success-foreground));
}

.theme-ayyappa .btn-danger {
    background-color: hsl(var(--destructive));
    border-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.theme-ayyappa .btn:focus-visible,
.theme-ayyappa .btn:focus {
    box-shadow: var(--temple-focus-ring);
    outline: none;
}

/* ── Form inputs (shadcn Input: border-input, ring on focus) ── */
.theme-ayyappa .form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 0.375rem;
}

.theme-ayyappa .form-control {
    display: flex;
    height: 2.5rem;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-ayyappa .form-select {
    display: block;
    width: 100%;
    height: 2.5rem;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748B' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px 10px;
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    padding: 0.5rem 2.25rem 0.5rem 0.75rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-ayyappa textarea.form-control {
    height: auto;
    min-height: 5rem;
}

.theme-ayyappa .form-control::placeholder {
    color: hsl(var(--muted-foreground));
}

.theme-ayyappa .form-control:focus,
.theme-ayyappa .form-select:focus {
    border-color: hsl(var(--ring));
    box-shadow: var(--temple-focus-ring);
    outline: none;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
}

.theme-ayyappa .form-control.is-invalid,
.theme-ayyappa .form-select.is-invalid {
    border-color: hsl(var(--destructive));
}

.theme-ayyappa .form-select-sm,
.theme-ayyappa .form-control-sm {
    height: 2.25rem;
    font-size: 0.8125rem;
    padding: 0.375rem 0.625rem;
}

/* ── Tables (shadcn Table: muted header, subtle row borders) ── */
.theme-ayyappa .table {
    --bs-table-bg: transparent;
    --bs-table-color: hsl(var(--foreground));
    --bs-table-border-color: hsl(var(--border));
    font-size: 0.875rem;
}

.theme-ayyappa .table thead th {
    background-color: hsl(var(--muted) / 0.6);
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    font-size: 0.8125rem;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid hsl(var(--border));
    padding: 0.75rem 1rem;
}

.theme-ayyappa .table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: hsl(var(--border));
}

.theme-ayyappa .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: hsl(var(--muted) / 0.35);
}

.theme-ayyappa .table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: hsl(var(--accent));
}

/* ── Modals / Dialog (shadcn Dialog) ── */
.theme-ayyappa .modal-content {
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--temple-shadow-lg);
}

.theme-ayyappa .modal-header {
    background-color: transparent;
    border-bottom: 1px solid hsl(var(--border));
    padding: 1.25rem 1.5rem 1rem;
}

.theme-ayyappa .modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.theme-ayyappa .modal-body {
    padding: 1.25rem 1.5rem;
}

.theme-ayyappa .modal-footer {
    border-top: 1px solid hsl(var(--border));
    padding: 1rem 1.5rem 1.25rem;
    gap: 0.5rem;
}

/* ── Alerts ── */
.theme-ayyappa .alert {
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    font-size: 0.875rem;
    padding: 0.875rem 1rem;
}

.theme-ayyappa .alert-info {
    background-color: hsl(214 95% 97%);
    border-color: hsl(214 90% 88%);
    color: hsl(214 50% 30%);
}

.theme-ayyappa .alert-success {
    background-color: hsl(142 76% 96%);
    border-color: hsl(142 60% 85%);
    color: hsl(142 50% 28%);
}

.theme-ayyappa .alert-warning {
    background-color: hsl(38 92% 96%);
    border-color: hsl(38 80% 85%);
    color: hsl(38 70% 28%);
}

.theme-ayyappa .alert-danger {
    background-color: hsl(0 86% 97%);
    border-color: hsl(0 80% 88%);
    color: hsl(0 60% 35%);
}

.theme-ayyappa .alert-light {
    background-color: hsl(var(--muted) / 0.5);
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
}

/* ── Badges (shadcn Badge: subtle secondary variant) ── */
.theme-ayyappa .badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: calc(var(--radius) - 2px);
}

.theme-ayyappa .badge.bg-success {
    background-color: hsl(var(--success) / 0.12) !important;
    color: hsl(142 50% 30%) !important;
    border: 1px solid hsl(var(--success) / 0.25);
}

.theme-ayyappa .badge.bg-danger {
    background-color: hsl(var(--destructive) / 0.12) !important;
    color: hsl(0 60% 40%) !important;
    border: 1px solid hsl(var(--destructive) / 0.25);
}

.theme-ayyappa .badge.bg-primary {
    background-color: hsl(var(--primary) / 0.12) !important;
    color: hsl(var(--primary)) !important;
    border: 1px solid hsl(var(--primary) / 0.25);
}

/* ── Validation ── */
.theme-ayyappa .validation-message {
    color: hsl(var(--destructive));
    font-size: 0.8125rem;
    font-weight: 500;
}

.theme-ayyappa .invalid {
    border-color: hsl(var(--destructive)) !important;
}

/* ── Page shells (history, users, admin) ── */
.theme-ayyappa .history-page .card,
.theme-ayyappa .users-page .card,
.theme-ayyappa .users-filter-bar {
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--temple-shadow-sm);
    background: hsl(var(--card));
}

.theme-ayyappa .users-page .table thead th,
.theme-ayyappa .history-page .table thead th {
    background-color: hsl(var(--muted) / 0.6);
}

/* ── Temple rich form alignment ── */
.theme-ayyappa .temple-form-card {
    border: 1px solid hsl(var(--border)) !important;
    border-radius: calc(var(--radius) + 4px) !important;
    box-shadow: var(--temple-shadow-sm) !important;
}

.theme-ayyappa .temple-field .form-control {
    border: 1px solid hsl(var(--input)) !important;
    border-radius: var(--radius) !important;
    background-color: hsl(var(--background)) !important;
    min-height: 2.5rem;
    font-size: 0.875rem;
}

.theme-ayyappa .temple-field .form-select {
    border: 1px solid hsl(var(--input)) !important;
    border-radius: var(--radius) !important;
    background-color: hsl(var(--background)) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748B'%3e%3cpath d='M4.5 6l3.5 3.5L11.5 6' stroke='%2364748B' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 1rem 1rem !important;
    min-height: 2.5rem;
    padding-right: 2.5rem !important;
    font-size: 0.875rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.theme-ayyappa .temple-field .form-control:focus,
.theme-ayyappa .temple-field .form-select:focus {
    border-color: hsl(var(--ring)) !important;
    box-shadow: var(--temple-focus-ring) !important;
}

.theme-ayyappa .temple-form-section-title {
    color: hsl(var(--foreground));
    font-weight: 600;
}

/* ── Offering / puja cards ── */
.theme-ayyappa .temple-offering-card {
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--temple-shadow-sm);
    background: hsl(var(--card));
}

.theme-ayyappa .temple-offering-card:hover {
    box-shadow: var(--temple-shadow);
    border-color: hsl(var(--primary) / 0.2);
}

.theme-ayyappa .temple-btn-select {
    background: hsl(var(--primary)) !important;
    background-image: none !important;
    border: 1px solid hsl(var(--primary)) !important;
    border-radius: var(--radius) !important;
    box-shadow: none !important;
    font-weight: 500;
    font-size: 0.875rem;
    min-height: 2.5rem;
}

.theme-ayyappa .temple-btn-select:hover {
    background: var(--brand-800) !important;
    background-image: none !important;
    box-shadow: var(--temple-shadow-sm) !important;
    transform: none !important;
}

/* ── Admin KPI cards — cleaner shadcn surface ── */
.theme-ayyappa .admin-kpi-card {
    border: 1px solid hsl(var(--border)) !important;
    border-radius: calc(var(--radius) + 4px) !important;
    box-shadow: var(--temple-shadow-sm) !important;
}

.theme-ayyappa .admin-grid-panel {
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    background: hsl(var(--card));
    box-shadow: var(--temple-shadow-sm);
}

.theme-ayyappa .admin-grid-filters .form-control,
.theme-ayyappa .admin-grid-filters .form-select {
    background: hsl(var(--background));
}

/* ── Scrollbar (subtle, desktop) ── */
@media (min-width: 768px) {
    .theme-ayyappa ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    .theme-ayyappa ::-webkit-scrollbar-thumb {
        background: hsl(var(--border));
        border-radius: 999px;
    }

    .theme-ayyappa ::-webkit-scrollbar-thumb:hover {
        background: hsl(var(--muted-foreground) / 0.4);
    }
}
