/* CY ScrExt Hub - 统一样式文件 */

/* 通知样式 */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.notification {
    background-color: white;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    border-left: 4px solid #e2e8f0;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.hide {
    transform: translateX(100%);
    opacity: 0;
}

.notification-success {
    border-left-color: #10b981;
}

.notification-error {
    border-left-color: #ef4444;
}

.notification-warning {
    border-left-color: #f59e0b;
}

.notification-info {
    border-left-color: #3b82f6;
}

.notification-icon {
    font-size: 20px;
}

.notification-success .notification-icon {
    color: #10b981;
}

.notification-error .notification-icon {
    color: #ef4444;
}

.notification-warning .notification-icon {
    color: #f59e0b;
}

.notification-info .notification-icon {
    color: #3b82f6;
}

.notification-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* 加载状态样式 */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #4F62C9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误状态样式 */
.error {
    border-color: #ef4444 !important;
}

.error-message {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
}

/* 骨架屏样式 */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

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

/* 焦点样式 */
.focus-visible {
    outline: 2px solid #4F62C9;
    outline-offset: 2px;
}

/* 响应式图片 */
.responsive-img {
    max-width: 100%;
    height: auto;
}

/* 渐变背景 */
.bg-gradient-primary {
    background: #4F62C9;
}

.bg-gradient-secondary {
    background: #10b981;
}

/* 卡片样式 */
.card-hover {
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #4F62C9;
    color: white;
}

.btn-primary:not(:disabled):hover {
    opacity: 0.9;
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

.btn-secondary:not(:disabled):hover {
    opacity: 0.85;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:not(:disabled):hover {
    opacity: 0.9;
}

/* 按钮点击效果（按压反馈） */
.btn:active:not(:disabled),
.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled),
.btn-danger:active:not(:disabled) {
    transform: scale(0.97);
    transition: transform 0.08s ease;
}

/* 通用按钮点击波纹效果 */
button:not(:disabled),
[role="button"]:not(:disabled),
a.btn,
.btn {
    -webkit-tap-highlight-color: transparent;
}

button:not(:disabled):active,
[role="button"]:not(:disabled):active {
    transform: scale(0.98);
    transition: transform 0.08s ease;
}

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: #374151;
}

.form-input {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #4F62C9;
    box-shadow: 0 0 0 3px rgba(79, 98, 201, 0.1);
}

.form-input.error {
    border-color: #ef4444;
}

/* 工具提示 */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* 响应式工具类 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 640px) {
    .container {
        padding: 0 24px;
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 0 32px;
    }
}

/* 滚动条样式 */
.scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

.scrollbar-thin::-webkit-scrollbar {
    width: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

/* 动画类 */
.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.slide-up {
    animation: slideUp 0.3s ease forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 网格布局 */
.grid {
    display: grid;
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

/* 弹性布局 */
.flex { display: flex; }
.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; }

/* 文本工具类 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-sm { font-size: 14px; }
.text-base { font-size: 16px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* 间距工具类 */
.m-0 { margin: 0; }
.m-1 { margin: 4px; }
.m-2 { margin: 8px; }
.m-3 { margin: 12px; }
.m-4 { margin: 16px; }
.m-6 { margin: 24px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }

/* 颜色工具类 */
.text-primary { color: #4F62C9; }
.text-secondary { color: #6b7280; }
.text-success { color: #10b981; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }

.bg-primary { background-color: #4F62C9; }
.bg-secondary { background-color: #f3f4f6; }
.bg-success { background-color: #10b981; }
.bg-danger { background-color: #ef4444; }
.bg-warning { background-color: #f59e0b; }

/* 边框工具类 */
.border { border: 1px solid #d1d5db; }
.border-t { border-top: 1px solid #d1d5db; }
.border-b { border-bottom: 1px solid #d1d5db; }
.border-l { border-left: 1px solid #d1d5db; }
.border-r { border-right: 1px solid #d1d5db; }

.rounded { border-radius: 6px; }
.rounded-md { border-radius: 8px; }
.rounded-lg { border-radius: 12px; }
.rounded-full { border-radius: 9999px; }

/* 阴影工具类 */
.shadow { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }

/* 显示工具类 */
.hidden { display: none; }
.block { display: block; }
.inline { display: inline; }

/* ============================================================
 * 公共导航栏组件（统一所有页面）
 * ============================================================ */

/* 普通导航链接 */
.nav-link {
    color: #4b5563;
    font-weight: 500;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}
.nav-link:hover { color: #4F62C9; }

/* 主按钮（注册） */
.nav-btn-primary {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 1rem;
    background: #4F62C9;
    color: white;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s ease;
}
.nav-btn-primary:hover { background: #3D4FA8; }

/* 描边按钮（提交扩展） */
.nav-btn-outline {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 1rem;
    border: 1px solid #4F62C9;
    color: #4F62C9;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.nav-btn-outline:hover {
    background: #4F62C9;
    color: white;
}

/* 强调按钮（管理） */
.nav-btn-accent {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 1rem;
    background: #8B5CF6;
    color: white;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s ease;
}
.nav-btn-accent:hover { background: #7c3aed; }

/* 头像+用户名链接 */
.nav-user-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #1f2937;
    transition: opacity 0.2s ease;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
}
.nav-user-link:hover {
    background: #f3f4f6;
}

.nav-avatar-img,
.nav-avatar-text {
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    background: #4F62C9;
    object-fit: cover;
    overflow: hidden;
}

.nav-username {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1f2937;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 图标链接（收件箱） */
.nav-icon-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9999px;
    color: #4b5563;
    font-size: 1.05rem;
    transition: all 0.2s ease;
}
.nav-icon-link:hover {
    background: #eef2ff;
    color: #4F62C9;
}

/* 未读徽章 */
.nav-unread-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    background: #ef4444;
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px white;
}
.nav-unread-badge.hidden { display: none; }
.inline-block { display: inline-block; }

/* 位置工具类 */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-50 { z-index: 50; }

/* 溢出工具类 */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }

.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-hidden { overflow-y: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* 文本截断 */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 宽高工具类 */
.w-full { width: 100%; }
.h-full { height: 100%; }
.w-auto { width: auto; }
.h-auto { height: auto; }

/* 响应式显示类 */
@media (max-width: 639px) {
    .sm\:hidden { display: none; }
}

@media (min-width: 640px) {
    .sm\:block { display: block; }
    .sm\:flex { display: flex; }
    .sm\:grid { display: grid; }
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
    .md\:block { display: block; }
    .md\:flex { display: flex; }
    .md\:grid { display: grid; }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .lg\:block { display: block; }
    .lg\:flex { display: flex; }
    .lg\:grid { display: grid; }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .lg\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ============================================================
 * 移动端体验深度优化（全局生效，所有页面受益）
 * ============================================================ */

/* 防止移动端横向溢出 + 禁止 iOS 自动缩放字号 */
/* html 与 body 同时限制 max-width: 100vw + overflow-x: hidden，
   双重保险阻止任何子元素撑出视口导致整页横向滚动条。
   （单独给 body 设 overflow-x:hidden 在部分浏览器中仍会从 html 冒泡出滚动条） */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}
body {
    overflow-x: hidden;
    max-width: 100vw;
    /* 长文本/长 URL 自动换行，避免撑宽容器 */
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* 图片自适应，避免任何元素导致横向溢出 */
img { max-width: 100%; }

/* 页面加载遮罩：仅作视觉提示，永远不拦截指针事件，
   避免其（即便因异常未隐藏）挡住导航栏菜单按钮等交互。
   遮罩的隐藏由各页面 JS 与 nav.js 的兜底定时器负责。 */
#page-loading { pointer-events: none; }

/* 表格、代码块等宽内容在窄屏自动横向滚动（容器内滚动，不撑出页面） */
table { max-width: 100%; }
pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 移除移动端点击高亮闪烁，统一用 :active 反馈 */
* { -webkit-tap-highlight-color: transparent; }

/* 触摸设备：移除 hover 悬停变换/阴影，避免粘滞高亮与卡顿（桌面 hover 效果保留） */
@media (hover: none) {
    .extension-card:hover,
    .nav-link:hover,
    .popular-category-btn:hover,
    .filter-option:hover,
    .nav-btn-primary:hover,
    .nav-btn-outline:hover,
    .nav-btn-accent:hover,
    .nav-icon-link:hover,
    .reset-filters-btn:hover,
    .ext-btn:hover {
        transform: none !important;
        box-shadow: none !important;
        filter: none !important;
    }
    .extension-card:hover .extension-card-img { filter: none; }
    /* 触摸时显式按下反馈，替代 hover */
    .extension-card:active { transform: scale(0.98); }
}

/* iOS 输入框聚焦缩放问题：移动端字号不小于 16px */
@media (max-width: 768px) {
    input, textarea, select,
    .form-input, .comment-textarea,
    #search-input, #comment-input {
        font-size: 16px !important;
    }

    /* 增大触摸目标，便于手指点击（按钮/链接最小可点击高度） */
    .nav-link,
    .nav-btn-primary,
    .nav-btn-outline,
    .nav-btn-accent {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }
    .nav-icon-link { width: 40px; height: 40px; }

    /* 超小屏减少容器横向内边距，给内容更多空间 */
    .container { padding-left: 12px; padding-right: 12px; }

    /* 移动端弹窗/抽屉占满宽度并贴底，利用动态视口高度（规避 iOS 地址栏 100vh 问题） */
    .detail-modal {
        align-items: flex-end;
    }
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 92dvh;
        border-radius: 16px 16px 0 0;
    }

    /* 评论区表单在手机上稍微增大输入框，便于打字 */
    .comment-textarea { min-height: 64px; }

    /* 网格在手机上单列更友好（覆盖部分页面默认双列） */
    #popular-extensions-container,
    #extensions-container,
    #extensions-grid,
    .extensions-grid {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }

    .grid > *,
    .flex > *,
    .extension-card,
    .tool-card,
    .extension-item:not(#extensions-row .extension-item) {
        min-width: 0 !important;
    }
}

/* 利用动态视口高度，避免移动端浏览器地址栏导致的高度跳变 */
@supports (height: 100dvh) {
    .detail-modal { height: 100dvh; }
    .fixed.inset-0, .fixed[class*="inset-0"] { height: 100dvh; }
}