/* 深色主题样式 */
body.dark-theme {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-tertiary: #808080;
    --border-color: #333333;
    --primary-color: #007acc;
    --primary-hover: #005f99;
}

/* 深色主题特定样式调整 */
body.dark-theme .tool-card {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

body.dark-theme .tool-card:hover {
    box-shadow: 0 8px 25px rgba(0, 122, 204, 0.25);
}

body.dark-theme .skeleton-header,
body.dark-theme .skeleton-line {
    background: var(--bg-tertiary);
}

body.dark-theme .modal-content {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

body.dark-theme .btn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.dark-theme .btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* 主题切换动画 */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* 主题切换按钮特殊样式 */
#themeToggle {
    position: relative;
    overflow: hidden;
}

#themeToggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, var(--primary-color), transparent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

#themeToggle:active::before {
    width: 40px;
    height: 40px;
}

/* 深色主题图标动画 */
body.dark-theme #themeIcon.layui-icon-moon {
    animation: rotate-icon 0.3s ease-in-out;
}

@keyframes rotate-icon {
    0% {
        transform: rotate(0deg);
    }
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 浅色主题图标动画 */
body:not(.dark-theme) #themeIcon.layui-icon-sun {
    animation: rotate-icon 0.3s ease-in-out;
}

/* 焦点指示器 */
.focus-indicator {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.header-btn:focus .focus-indicator,
.btn:focus .focus-indicator {
    opacity: 1;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    :root {
        --border-color: #666666;
    }
    
    body.dark-theme {
        --border-color: #666666;
        --text-primary: #ffffff;
        --bg-primary: #000000;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 主题预览样式 */
.theme-preview {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
}

.theme-preview.show {
    display: block;
    animation: slide-in-up 0.3s ease-out;
}

@keyframes slide-in-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.theme-preview-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.theme-preview-options {
    display: flex;
    gap: 8px;
}

.theme-option {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.theme-option:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

.theme-option.active {
    border-color: var(--primary-color);
}

.theme-option.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.theme-option.light {
    background: linear-gradient(135deg, #ffffff, #f5f5f5);
}

.theme-option.dark {
    background: linear-gradient(135deg, #1e1e1e, #252526);
}

/* 自定义主题颜色变量 */
body.custom-theme {
    --primary-color: #ff6b35;
    --primary-hover: #e55a2b;
}

/* 渐变主题 */
body.gradient-theme {
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: linear-gradient(135deg, #5a67d8 0%, #667eea 100%);
    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;
    --border-color: rgba(255, 255, 255, 0.2);
}

/* 主题切换提示 */
.theme-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
}

.theme-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* 主题快捷键提示 */
.shortcut-hint {
    position: absolute;
    top: -30px;
    right: 0;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    z-index: 1000;
}

.header-btn:hover .shortcut-hint {
    opacity: 1;
}

/* 主题状态指示器 */
.theme-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.theme-indicator.auto {
    background: #4CAF50;
    animation: pulse-indicator 2s infinite;
}

.theme-indicator.light {
    background: #FFC107;
}

.theme-indicator.dark {
    background: #007ACC;
}

#themeToggle.show-indicator .theme-indicator {
    opacity: 1;
}

@keyframes pulse-indicator {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

/* 主题信息提示 */
.theme-info {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
    max-width: 250px;
}

.theme-info.show {
    opacity: 1;
    transform: translateY(0);
}

.theme-info-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.theme-info-description {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.theme-info-current {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-top: 8px;
}

/* 自动检测系统主题 */
@media (prefers-color-scheme: dark) {
    body.auto-theme {
        --bg-primary: #1e1e1e;
        --bg-secondary: #252526;
        --bg-tertiary: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --text-tertiary: #808080;
        --border-color: #333333;
    }
}

/* 主题切换进度指示器 */
.theme-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.theme-loading.active {
    opacity: 1;
    animation: loading-progress 0.5s ease-in-out;
}

@keyframes loading-progress {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}