/* Avalara Automator Web UI - Custom styles
   Tailwind utilities handle most styling; this file covers custom overrides. */

/* ── CSS custom properties (design tokens) ───────────────── */
/* Maps Tailwind gray palette + brand colors to CSS variables.
   Since Tailwind CDN doesn't auto-generate variables, we define
   them here so app.css rules can reference the design system. */
:root {
    --tw-gray-50:  #f9fafb;
    --tw-gray-100: #f3f4f6;
    --tw-gray-200: #e5e7eb;
    --tw-gray-300: #d1d5db;
    --tw-gray-400: #9ca3af;
    --tw-gray-500: #6b7280;
    --tw-gray-600: #4b5563;
    --tw-gray-700: #374151;
    --tw-gray-800: #1f2937;
    --tw-primary:      #007ACC;
    --tw-primary-dark: #3794ff;
}

.dark {
    /* Dark-mode overrides — currently identity (same palette),
       but having the block lets us diverge later if needed. */
    --tw-primary:      #007ACC;
    --tw-primary-dark: #3794ff;
}

/* Scrollbar styling for dark mode */
.dark ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.dark ::-webkit-scrollbar-track {
    background: var(--tw-gray-800);
}

.dark ::-webkit-scrollbar-thumb {
    background: var(--tw-gray-600);
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: var(--tw-gray-500);
}

/* Prevent FOUC for Alpine.js x-cloak */
[x-cloak] {
    display: none !important;
}

/* File input styling */
input[type="file"]::file-selector-button {
    padding: 0.375rem 0.75rem;
    margin-right: 0.75rem;
    border: 1px solid var(--tw-gray-300);
    border-radius: 0.375rem;
    background-color: var(--tw-gray-50);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

input[type="file"]::file-selector-button:hover {
    background-color: var(--tw-gray-200);
}

.dark input[type="file"]::file-selector-button {
    background-color: var(--tw-gray-700);
    border-color: var(--tw-gray-600);
    color: var(--tw-gray-300);
}

.dark input[type="file"]::file-selector-button:hover {
    background-color: var(--tw-gray-600);
}

/* ── Responsive table wrapper ────────────────────────────── */
/* Wraps tables so they scroll horizontally on narrow viewports */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ensure all tables inside <main> get horizontal scroll when needed */
main table.data-table {
    min-width: 600px;
}

/* ── Responsive form layout helpers ──────────────────────── */
/* Stack form rows vertically on mobile, side-by-side on sm+ */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
@media (min-width: 640px) {
    .form-row {
        flex-direction: row;
        align-items: flex-end;
    }
    .form-row > * {
        flex: 1;
    }
}

/* Buttons full-width on mobile, auto-width on sm+ */
.btn-responsive {
    width: 100%;
}
@media (min-width: 640px) {
    .btn-responsive {
        width: auto;
    }
}

/* ── Mobile header utilities ─────────────────────────────── */
/* Hide non-essential header items below sm breakpoint */
.header-hide-mobile {
    display: none;
}
@media (min-width: 640px) {
    .header-hide-mobile {
        display: block;
    }
}

/* ── HTMX loading indicator ─────────────────────────────── */
/* Global spinner shown during HTMX requests */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
}

/* ── Skeleton loading placeholders ──────────────────────── */
/* Animated gray bar placeholder for text content */
.skeleton-line {
    height: 0.875rem;
    border-radius: 0.25rem;
    background: linear-gradient(90deg, var(--tw-gray-200) 25%, var(--tw-gray-100) 50%, var(--tw-gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.dark .skeleton-line {
    background: linear-gradient(90deg, var(--tw-gray-700) 25%, var(--tw-gray-600) 50%, var(--tw-gray-700) 75%);
    background-size: 200% 100%;
}

/* Card-shaped placeholder */
.skeleton-card {
    border-radius: 0.5rem;
    background: linear-gradient(90deg, var(--tw-gray-200) 25%, var(--tw-gray-100) 50%, var(--tw-gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    min-height: 6rem;
}

.dark .skeleton-card {
    background: linear-gradient(90deg, var(--tw-gray-700) 25%, var(--tw-gray-600) 50%, var(--tw-gray-700) 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-pulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Focus-visible outlines for accessibility ────────────── */
/* Visible focus ring on interactive elements for keyboard users */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--tw-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.dark a:focus-visible,
.dark button:focus-visible,
.dark input:focus-visible,
.dark select:focus-visible,
.dark textarea:focus-visible,
.dark [tabindex]:focus-visible {
    outline-color: var(--tw-primary-dark);
}
