@layer components {
    .btn {
        @apply inline-flex min-h-11 items-center justify-center gap-1.5 rounded-md px-4 py-2 text-sm font-medium sm:min-h-0 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:ring-offset-1;
    }
    .btn-sm {
        @apply px-3 py-2 sm:py-1.5;
    }
    .btn-xs {
        @apply min-h-10 px-3 py-1.5 text-sm sm:min-h-0 sm:px-2.5 sm:py-1 sm:text-xs;
    }
    .btn-primary {
        @apply bg-slate-900 text-white shadow-sm hover:bg-slate-700;
    }
    .btn-secondary {
        @apply border border-slate-300 bg-white text-slate-700 shadow-sm hover:bg-slate-100;
    }
    .btn-danger {
        @apply border border-red-300 bg-white text-red-700 hover:bg-red-50;
    }

    .input {
        @apply min-h-11 rounded-md border border-slate-300 bg-white px-3 py-2 text-base text-slate-800 sm:min-h-0 sm:text-sm shadow-sm focus:border-slate-500 focus:outline-none focus:ring-1 focus:ring-slate-400;
    }
    .input-sm {
        @apply px-2.5 py-2 sm:py-1.5;
    }

    .card {
        @apply rounded-lg border border-slate-200 bg-white shadow-sm;
    }

    .page-title {
        @apply text-2xl font-semibold tracking-tight text-slate-900;
    }

    .table-card {
        @apply overflow-x-auto rounded-lg border border-slate-200 bg-white shadow-sm;
    }
    .data-table {
        @apply min-w-full divide-y divide-slate-200 text-sm;
    }
    .data-table thead {
        @apply bg-slate-50 text-left text-xs font-medium uppercase tracking-wide text-slate-500;
    }
    .data-table tbody tr {
        @apply transition-colors hover:bg-slate-50;
    }

    .badge {
        @apply inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset;
    }
    .badge-success {
        @apply bg-emerald-50 text-emerald-800 ring-emerald-200;
    }
    .badge-warning {
        @apply bg-amber-50 text-amber-800 ring-amber-200;
    }
    .badge-muted {
        @apply bg-slate-100 text-slate-600 ring-slate-200;
    }
    .badge-info {
        @apply bg-sky-50 text-sky-800 ring-sky-200;
    }

    .alert {
        @apply rounded-md border px-4 py-2 text-sm;
    }
    .alert-success {
        @apply border-emerald-200 bg-emerald-50 text-emerald-800;
    }
    .alert-warning {
        @apply border-amber-300 bg-amber-50 text-amber-900;
    }
    .alert-error {
        @apply border-red-200 bg-red-50 text-red-700;
    }
}

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

input[type='checkbox'],
input[type='radio'] {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    accent-color: #0f172a;
}

.filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}
.filters > div,
.filters > div > .input {
    min-width: 0;
    width: 100%;
}
.filters > .btn,
.filters > .filters-wide {
    width: 100%;
}
.filters-wide {
    grid-column: 1 / -1;
}
@media (min-width: 640px) {
    .filters {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
    }
    .filters > div,
    .filters > div > .input,
    .filters > .btn {
        width: auto;
    }
}

@media (max-width: 767px) {
    table[data-stack] thead {
        display: none;
    }
    table[data-stack],
    table[data-stack] tbody {
        display: block;
        width: 100%;
    }
    table[data-stack] tbody tr {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
        padding: 0.75rem 1rem;
    }
    table[data-stack] tbody tr + tr {
        border-top: 1px solid #e2e8f0;
    }
    table[data-stack] td {
        display: flex;
        align-items: baseline;
        gap: 0.375rem;
        min-width: 0;
        padding: 0;
        overflow-wrap: anywhere;
        text-align: left;
        white-space: normal;
    }
    table[data-stack] td:empty {
        display: none;
    }
    table[data-stack] td[data-label]:not([data-label=''])::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 0.6875rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #64748b;
    }
    table[data-stack] td[data-cell='comment'],
    table[data-stack] td[data-cell='case_number'] {
        flex-basis: 100%;
    }
    table[data-stack] td.cell-actions {
        display: block;
        flex-basis: 100%;
        margin-top: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px dashed #e2e8f0;
        text-align: left;
    }
    table[data-stack] td.cell-actions > div {
        justify-content: flex-start;
    }
    table[data-stack] td a:not(.btn) {
        display: inline-block;
        padding: 0.75rem 0;
    }
    table[data-stack] td[colspan] {
        display: block;
        flex-basis: 100%;
        padding: 0.5rem 0;
        text-align: center;
    }
}

@media (pointer: coarse) {
    .btn {
        min-height: 2.75rem;
    }
    .btn-xs {
        min-height: 2.5rem;
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    .input {
        min-height: 2.75rem;
        font-size: 1rem;
    }
}
