/* Self-hosted admin utilities — 不依赖 CDN，兼容微信内置浏览器 */

*, *::before, *::after { box-sizing: border-box; }

.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.grid { display: grid; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.inset-0 { inset: 0; }
.top-0 { top: 0; }
.top-4 { top: 1rem; }
.right-4 { right: 1rem; }
.z-50 { z-index: 50; }

.flex-1 { flex: 1 1 0%; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.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; }

.w-full { width: 100%; }
.w-11 { width: 2.75rem; }
.w-6 { width: 1.5rem; }
.h-6 { height: 1.5rem; }
.h-5 { height: 1.25rem; }
.w-5 { width: 1.25rem; }
.h-14 { height: 3.5rem; }
.min-h-screen { min-height: 100vh; min-height: -webkit-fill-available; }
.max-w-xs { max-width: 20rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-3xl { max-width: 48rem; }
.max-w-5xl { max-width: 64rem; }
.max-w-6xl { max-width: 72rem; }
.max-w-7xl { max-width: 80rem; }
.max-h-96 { max-height: 24rem; }
.max-w-\[70vw\] { max-width: 70vw; }

.mx-auto { margin-left: auto; margin-right: auto; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.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-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-2\.5 { padding-top: 0.625rem; padding-bottom: 0.625rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }

.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.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-center { text-align: center; }
.text-left { text-align: left; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-mono { font-family: ui-monospace, monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.whitespace-pre-wrap { white-space: pre-wrap; }
.antialiased { -webkit-font-smoothing: antialiased; }

.bg-white { background-color: #fff; }
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-300 { background-color: #d1d5db; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-blue-600 { background-color: #2563eb; }
.bg-black\/40 { background-color: rgba(0, 0, 0, 0.4); }

.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-blue-600 { color: #2563eb; }
.text-blue-700 { color: #1d4ed8; }
.text-red-500 { color: #ef4444; }
.text-green-600 { color: #16a34a; }

.border { border-width: 1px; border-style: solid; border-color: #e5e7eb; }
.border-b { border-bottom-width: 1px; border-bottom-style: solid; border-color: #e5e7eb; }
.border-t { border-top-width: 1px; border-top-style: solid; border-color: #e5e7eb; }
.rounded { border-radius: 0.25rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-full { border-radius: 9999px; }

.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); }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); }

.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.overflow-x-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.divide-y > :not([hidden]) ~ :not([hidden]) { border-top: 1px solid #e5e7eb; }

.outline-none { outline: none; }
.cursor-pointer { cursor: pointer; }
.transition { transition-property: color, background-color, border-color; transition-duration: 150ms; }
.space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }
.space-y-3 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.75rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
.space-y-5 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.25rem; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

input, select, textarea, button {
    font: inherit;
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}

button.bg-blue-600, .bg-blue-600.text-white {
    color: #fff;
    border: none;
    cursor: pointer;
}

.hover\:bg-blue-700:hover { background-color: #1d4ed8; }
.hover\:bg-gray-100:hover { background-color: #f3f4f6; }
.hover\:bg-gray-50:hover { background-color: #f9fafb; }
.hover\:bg-red-50:hover { background-color: #fef2f2; }
.hover\:underline:hover { text-decoration: underline; }

.focus\:ring-2:focus { box-shadow: 0 0 0 2px #93c5fd; }
.focus\:ring-blue-500:focus { box-shadow: 0 0 0 2px #3b82f6; }

.max-h-\[600px\] { max-height: 600px; }
.max-h-\[90vh\] { max-height: 90vh; }
.max-h-\[70vh\] { max-height: 70vh; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; }

a { color: inherit; text-decoration: none; }

.mb-8 { margin-bottom: 2rem; }

@media (min-width: 640px) {
    .page-main {
        padding: 1.5rem 1rem 2.5rem;
    }
    .sm\:px-4 { padding-left: 1rem; padding-right: 1rem; }
    .sm\:py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
    .sm\:p-8 { padding: 2rem; }
    .sm\:text-2xl { font-size: 1.5rem; line-height: 2rem; }
    .sm\:text-lg { font-size: 1.125rem; line-height: 1.75rem; }
    .sm\:flex-row { flex-direction: row; }
    .sm\:items-center { align-items: center; }
    .sm\:justify-between { justify-content: space-between; }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sm\:col-span-1 { grid-column: span 1 / span 1; }
    .sm\:gap-2 { gap: 0.5rem; }
}

@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .md\:col-span-2 { grid-column: span 2 / span 2; }
    .md\:flex { display: flex; }
    .md\:hidden { display: none !important; }
}

@media (min-width: 1024px) {
    .lg\:flex { display: flex !important; }
    .lg\:hidden { display: none !important; }
}

@media (max-width: 1023px) {
    .nav-desktop { display: none !important; }
}

/* nav-desktop shown via style.css at 1024px+ */

/* Toggle switch */
.relative { position: relative; }
.inline-flex { display: inline-flex; }
.peer {
    position: absolute; opacity: 0; width: 0; height: 0;
}
.peer:checked + .toggle-track { background-color: #2563eb; }
.peer:checked + .toggle-track::after { transform: translateX(1.25rem); }
.toggle-track {
    position: relative; width: 2.75rem; height: 1.5rem; background: #d1d5db;
    border-radius: 9999px; transition: background 0.2s;
}
.toggle-track::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 1.25rem; height: 1.25rem;
    background: #fff; border-radius: 9999px; transition: transform 0.2s;
}

/* WeChat WebView fixes */
.is-wechat body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.is-wechat .admin-topbar {
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.is-wechat .theme-toggle,
.is-wechat .topbar-menu-btn,
.is-wechat button,
.is-wechat a.px-3 {
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.is-wechat .table-wrap {
    width: 100%;
    max-width: 100vw;
}

.is-wechat .admin-sidebar.is-open {
    display: flex !important;
}
