/* ==========================================================================
   Self-hosted utility CSS — replaces Tailwind CDN for China accessibility.
   Covers all utility classes used across the KeepYoga sniping web templates.
   ========================================================================== */

/* ---- Reset ---- */
*, ::before, ::after { box-sizing: border-box; border: 0 solid #e5e7eb; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; }
body { margin: 0; line-height: 1.5; }

/* Tailwind's preflight for form controls. Without this, any <button> that has
   no explicit bg-* class rendered with the UA's grey box (e.g. the ★ target
   toggle and the 编辑/删除 actions). */
button, input, optgroup, select, textarea {
    font-family: inherit; font-size: 100%; line-height: inherit;
    letter-spacing: inherit; color: inherit; margin: 0; padding: 0;
}
button, input[type='button'], input[type='reset'], input[type='submit'] {
    -webkit-appearance: button; appearance: button;
    background-color: transparent; background-image: none;
}
button { cursor: pointer; }
button:disabled { cursor: default; }

/* ---- Display ---- */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.flex { display: flex; }
.grid { display: grid; }
.table { display: table; }
@media (min-width: 768px) { .md\:flex { display: flex; } }

/* ---- Position ---- */
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.bottom-6 { bottom: 1.5rem; }
.right-6 { right: 1.5rem; }
.z-50 { z-index: 50; }

/* ---- Flexbox ---- */
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-x-4 { column-gap: 1rem; }
.gap-y-1 { row-gap: 0.25rem; }

/* ---- Grid ---- */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2 / span 2; }
@media (min-width: 1024px) {
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Width ---- */
.w-2\.5 { width: 0.625rem; }
.w-8 { width: 2rem; }
.w-32 { width: 8rem; }
.w-44 { width: 11rem; }
.w-56 { width: 14rem; }
.w-96 { width: 24rem; }
.w-\[700px\] { width: 700px; }
.w-full { width: 100%; }
.max-w-\[200px\] { max-width: 200px; }
.max-w-md { max-width: 28rem; }
.min-w-\[140px\] { min-width: 140px; }

/* ---- Height ---- */
.h-2\.5 { height: 0.625rem; }
.h-screen { height: 100vh; }
.min-h-screen { min-height: 100vh; }
.max-h-\[80vh\] { max-height: 80vh; }
.max-h-\[400px\] { max-height: 400px; }

/* ---- Overflow ---- */
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }

/* ---- Padding ---- */
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-2\.5 { padding-top: 0.625rem; padding-bottom: 0.625rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.pt-3 { padding-top: 0.75rem; }
.pr-4 { padding-right: 1rem; }

/* ---- Margin ---- */
.mt-0\.5 { margin-top: 0.125rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mr-2 { margin-right: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }

/* ---- Space Between (flexbox gap fallback via margin) ---- */
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }

/* ---- Typography ---- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace; }
.uppercase { text-transform: uppercase; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.underline { text-decoration: underline; }

/* ---- Colors: Text ---- */
.text-white { color: #ffffff; }
.text-gray-100 { color: #f3f4f6; }
.text-gray-300 { color: #d1d5db; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-red-400 { color: #f87171; }
.text-red-500 { color: #ef4444; }
.text-red-600 { color: #dc2626; }
.text-red-700 { color: #b91c1c; }
.text-yellow-400 { color: #facc15; }
.text-yellow-500 { color: #eab308; }
.text-yellow-600 { color: #ca8a04; }
.text-green-400 { color: #4ade80; }
.text-green-500 { color: #22c55e; }
.text-green-600 { color: #16a34a; }
.text-green-700 { color: #15803d; }
.text-green-800 { color: #166534; }
.text-blue-500 { color: #3b82f6; }
.text-blue-600 { color: #2563eb; }
.text-blue-800 { color: #1e40af; }

/* ---- Colors: Background ---- */
.bg-white { background-color: #ffffff; }
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-800 { background-color: #1f2937; }
.bg-gray-900 { background-color: #111827; }
.bg-red-50 { background-color: #fef2f2; }
.bg-red-100 { background-color: #fee2e2; }
.bg-red-400 { background-color: #f87171; }
.bg-yellow-50 { background-color: #fefce8; }
.bg-yellow-100 { background-color: #fef9c3; }
.bg-green-50 { background-color: #f0fdf4; }
.bg-green-100 { background-color: #dcfce7; }
.bg-green-400 { background-color: #4ade80; }
.bg-green-600 { background-color: #16a34a; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-blue-600 { background-color: #2563eb; }
.bg-black\/30 { background-color: rgba(0, 0, 0, 0.3); }

/* ---- Borders ---- */
.border { border-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-t { border-top-width: 1px; }
.border-r { border-right-width: 1px; }
.border-gray-100 { border-color: #f3f4f6; }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-300 { border-color: #d1d5db; }
.border-blue-200 { border-color: #bfdbfe; }

/* ---- Border Radius ---- */
.rounded { border-radius: 0.25rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-full { border-radius: 9999px; }

/* ---- Shadows ---- */
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); }

/* ---- Opacity ---- */
.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }
.disabled\:opacity-50:disabled { opacity: 0.5; }

/* ---- Hover ---- */
.hover\:bg-gray-50:hover { background-color: #f9fafb; }
.hover\:bg-red-50:hover { background-color: #fef2f2; }
.hover\:bg-blue-700:hover { background-color: #1d4ed8; }
.hover\:bg-green-700:hover { background-color: #15803d; }
.hover\:bg-red-200:hover { background-color: #fecaca; }
.hover\:text-red-600:hover { color: #dc2626; }
.hover\:text-blue-800:hover { color: #1e40af; }
.hover\:text-gray-600:hover { color: #4b5563; }
.hover\:underline:hover { text-decoration: underline; }
.hover\:text-red-700:hover { color: #b91c1c; }

/* ---- Focus ---- */
.focus\:ring-2:focus { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5); }
.focus\:ring-blue-500:focus { --tw-ring-color: #3b82f6; }
.focus\:border-blue-500:focus { border-color: #3b82f6; }
.outline-none { outline: none; }

/* ---- Tables ---- */
table { border-collapse: collapse; text-indent: 0; }
th { text-align: inherit; }

/* ---- Divide ---- */
.divide-y > * + * { border-top-width: 1px; }
.divide-gray-100 > * + * { border-color: #f3f4f6; }

/* ---- Sidebar ---- */
.sidebar-link {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem; border-radius: 0.5rem;
    font-size: 0.875rem; color: #374151;
    text-decoration: none; transition: all 0.15s ease;
}
.sidebar-link:hover { background-color: #f3f4f6; }
.sidebar-link.active { background-color: #dbeafe; color: #2563eb; font-weight: 600; }

/* ---- Cursor ---- */
.cursor-pointer { cursor: pointer; }

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

/* ---- Select ---- */
select { appearance: auto; }

/* ==========================================================================
   MISSING UTILITIES
   These classes are used by the templates (and by JS status badges) but were
   never defined in this hand-written subset. Missing ones silently collapsed
   layout (e.g. the sidebar status dot had no width, hover/focus states were
   dead, targets' action column had no styling).
   ========================================================================== */

/* ---- Display / position ---- */
.relative { position: relative; }
.absolute { position: absolute; }
.inline-flex { display: inline-flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.items-start { align-items: flex-start; }
.items-stretch { align-items: stretch; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-hidden { overflow-y: hidden; }

/* ---- Sizing ---- */
.w-3 { width: 0.75rem; }
.h-3 { height: 0.75rem; }
.h-full { height: 100%; }
.min-w-0 { min-width: 0; }
.min-w-\[80px\] { min-width: 80px; }
.max-w-\[700px\] { max-width: 700px; }

/* ---- Spacing ---- */
.pb-2 { padding-bottom: 0.5rem; }
.pb-4 { padding-bottom: 1rem; }
.pt-2 { padding-top: 0.5rem; }
.pb-20 { padding-bottom: 5rem; }
.bottom-20 { bottom: 5rem; }

/* ---- Layout helpers ---- */
.whitespace-nowrap { white-space: nowrap; }
.transition-all { transition: all 0.15s ease; }
.transition-colors { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); }

/* ---- Colors referenced from JS badge maps / template ternaries ---- */
.text-blue-100 { color: #dbeafe; }
.text-blue-200 { color: #bfdbfe; }
.text-gray-200 { color: #e5e7eb; }
.text-green-700 { color: #15803d; }
.text-red-800 { color: #991b1b; }
.text-yellow-800 { color: #854d0e; }
.bg-blue-50 { background-color: #eff6ff; }
.bg-blue-50\/50 { background-color: rgba(239, 246, 255, 0.5); }
.bg-red-200 { background-color: #fecaca; }
.border-red-200 { border-color: #fecaca; }
.border-blue-300 { border-color: #93c5fd; }

/* ---- Hover states referenced from templates ---- */
.hover\:bg-blue-50:hover { background-color: #eff6ff; }
.hover\:bg-blue-100:hover { background-color: #dbeafe; }
.hover\:border-blue-300:hover { border-color: #93c5fd; }
.hover\:text-yellow-400:hover { color: #facc15; }
.hover\:text-gray-800:hover { color: #1f2937; }

/* ---- md: variants (min-width: 768px) ---- */
@media (min-width: 768px) {
    .md\:hidden { display: none; }
    .md\:block { display: block; }
    .md\:table-cell { display: table-cell; }
    .md\:flex-row { flex-direction: row; }
    .md\:items-center { align-items: center; }
    .md\:justify-between { justify-content: space-between; }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:w-auto { width: auto; }
    .md\:bottom-6 { bottom: 1.5rem; }
}

/* ==========================================================================
   APP SHELL
   Desktop keeps the fixed sidebar + internally scrolling <main>. Mobile uses
   natural document scrolling with a fixed top bar and a fixed bottom tab bar,
   which avoids the iOS "100vh is taller than the visible viewport" trap that
   used to push the bottom of every page out of reach.
   ========================================================================== */

.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.app-main { flex: 1 1 0%; min-width: 0; }

/* Top bar + bottom tab bar are mobile-only. */
.app-topbar,
.app-tabbar { display: none; }

@media (max-width: 767.98px) {
    /* Leave room for the fixed bars so no content hides behind them. */
    .app-main { padding-top: 3.5rem; padding-bottom: 5rem; }

    .app-topbar {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 40;
        height: 3.5rem;
        padding: 0 0.75rem;
        background-color: #ffffff;
        border-bottom: 1px solid #e5e7eb;
    }

    .app-tabbar {
        display: flex;
        align-items: stretch;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        background-color: #ffffff;
        border-top: 1px solid #e5e7eb;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .app-tab {
        flex: 1 1 0%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 3.25rem;
        padding: 0.375rem 0 0.5rem;
        font-size: 0.6875rem;
        line-height: 1.1;
        color: #6b7280;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    .app-tab-icon { font-size: 1.125rem; line-height: 1; }
    .app-tab.active { color: #2563eb; font-weight: 600; background-color: #eff6ff; }

    .app-icon-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.25rem;
        height: 2.25rem;
        flex-shrink: 0;
        border-radius: 0.5rem;
        font-size: 1rem;
        text-decoration: none;
        color: #6b7280;
        background-color: #f3f4f6;
    }

    /* Comfortable touch targets for the small buttons in page headers. */
    .app-main button,
    .app-main select { min-height: 2.25rem; }

    /* iOS Safari zooms the whole page when focusing an input whose font-size is
       below 16px, which threw the layout off every time a field was tapped. */
    .app-main input,
    .app-main select,
    .app-main textarea { font-size: 16px; }

    /* Slightly tighter page padding — 1.5rem each side wastes a 390px screen. */
    .app-main .p-6 { padding: 1rem; }
}

@media (min-width: 768px) {
    .app-shell { height: 100vh; height: 100dvh; overflow: hidden; }
    .app-main { overflow-y: auto; }
}

/* ==========================================================================
   MOBILE DATA TABLES -> STACKED CARDS
   Every data table has 6-8 columns, which at 390px squeezed each cell into
   one character per line and clipped the trailing columns (the 操作 buttons
   on 目标管理 were literally unreachable). Below 768px each row becomes a
   card: the cell marked .card-title is the heading, every other <td> shows
   its data-label as a left-hand caption with the value right-aligned.
   ========================================================================== */

@media (max-width: 767.98px) {
    .table-cards { display: block; width: 100%; }
    .table-cards thead { display: none; }
    .table-cards tbody { display: block; width: 100%; }

    /* Column layout (not just block) so the .card-title cell can be moved to
       the top with `order` without touching the desktop column order. */
    .table-cards tr {
        display: flex;
        flex-direction: column;
        padding: 0.625rem 0;
        background-color: transparent;
    }

    .table-cards td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        width: auto;
        max-width: none;
        padding: 0.3125rem 1rem;
        text-align: right;
        white-space: normal;
    }

    .table-cards td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 0.75rem;
        font-weight: 500;
        color: #9ca3af;
        text-align: left;
    }

    /* Cells without a label (the primary field) render as the card heading. */
    .table-cards td.card-title {
        display: block;
        order: -1;
        padding-top: 0.25rem;
        padding-bottom: 0.375rem;
        text-align: left;
        font-size: 1rem;
        font-weight: 600;
        color: #1f2937;
    }
    .table-cards td.card-title::before { content: none; }
    .table-cards td[data-label=""]::before { content: none; }

    /* Columns that only carry meaning in the desktop table layout. Has to be
       more specific than `.table-cards td`, which forces display:flex. */
    .table-cards td.hide-mobile { display: none; }
}

/* ==========================================================================
   MOBILE TOASTS + MODALS
   ========================================================================== */

@media (max-width: 767.98px) {
    /* Keep toasts clear of the fixed bottom tab bar. */
    .app-toast { bottom: 5rem; left: 1rem; right: 1rem; text-align: center; }

    .modal-panel {
        width: 100%;
        max-width: 92vw;
        max-height: 88vh;
        overflow-y: auto;
    }
}

/* Horizontally scrollable date strip on phones; wraps normally on desktop. */
.date-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.date-strip > * { flex: 0 0 auto; }
@media (min-width: 768px) {
    .date-strip { flex-wrap: wrap; overflow-x: visible; padding-bottom: 0; }
}
