/* 极简移动端设计 - 参考微信/支付宝风格 */

:root {
    --primary: #07C160;
    --primary-dark: #06AD56;
    --danger: #FA5151;
    --text: #1A1A1A;
    --text-secondary: #888;
    --bg: #F5F5F5;
    --card: #FFF;
    --border: #E5E5E5;
    --tab-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
    --text: #E5E5E5;
    --text-secondary: #888;
    --bg: #111;
    --card: #1A1A1A;
    --border: #333;
}

/* 深色模式下的额外样式调整 */
[data-theme="dark"] .section {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="dark"] .settings-group {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="dark"] .file-item:active {
    background: var(--border);
}

[data-theme="dark"] .file-btn {
    background: var(--border);
}

[data-theme="dark"] .file-btn:active {
    background: #444;
}

[data-theme="dark"] .results-list {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="dark"] .progress-box {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="dark"] .result-box {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="dark"] .tab-bar {
    box-shadow: 0 -1px 10px rgba(0,0,0,0.3);
}

[data-theme="dark"] .modal-box {
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

[data-theme="dark"] .btn-secondary:active {
    background: var(--border);
}

[data-theme="dark"] .modal-actions button:active {
    background: var(--border);
}

[data-theme="dark"] .select-field {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* 应用容器 */
.app {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 页面 */
.page {
    display: none !important;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--tab-height);
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.page.active {
    display: flex !important;
}

.page-header {
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.page-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page-footer {
    padding: 12px 16px;
    background: var(--card);
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 区块 */
.section {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.section-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

/* 输入框 */
.input-field {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.1);
    background: var(--card);
}

.input-field::placeholder {
    color: var(--text-secondary);
}

.input-area {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.6;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-area:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.1);
    background: var(--card);
}

.input-area::placeholder {
    color: var(--text-secondary);
}

.search-input {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    outline: none;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

/* 下拉框 */
.select-field {
    flex: 1;
    height: 44px;
    padding: 0 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.select-field:focus {
    border-color: var(--primary);
}

.filter-row {
    display: flex;
    gap: 12px;
    margin: 16px 0;
}

/* 链接计数 */
.link-count {
    font-size: 13px;
    color: var(--primary);
    margin-top: 10px;
    text-align: right;
    font-weight: 500;
}

/* 按钮 */
.btn-primary {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #FFF;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(7, 193, 96, 0.2);
}

.btn-primary:disabled {
    background: var(--border);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    flex: 1;
    height: 44px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:active {
    background: var(--bg);
}

.btn-danger {
    flex: 1;
    height: 44px;
    border: 1.5px solid var(--danger);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    background: var(--card);
    color: var(--danger);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger:active {
    background: rgba(250, 81, 81, 0.1);
}

.btn-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Cookie配置区域按钮布局 */
.settings-group .btn-row {
    flex-wrap: nowrap;
}

.settings-group .btn-row button {
    flex: 1;
    white-space: nowrap;
}

/* 进度条 */
.progress-box {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.progress-text {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 12px;
    font-weight: 500;
}

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, #10D070 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* 结果区域 */
.result-box {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.result-item {
    display: flex;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.result-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.result-item:first-child {
    padding-top: 0;
}

.result-title {
    font-size: 15px;
    color: var(--text);
    font-weight: 500;
}

.result-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.result-success {
    color: var(--primary);
}

.result-error {
    color: var(--danger);
}

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-text {
    font-size: 15px;
    color: var(--text-secondary);
}

/* 文件列表 */
.file-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.file-item:active {
    background: var(--bg);
}

.file-item:first-child {
    border-radius: 12px 12px 0 0;
}

.file-item:last-child {
    border-radius: 0 0 12px 12px;
    border-bottom: none;
}

.file-item:only-child {
    border-radius: 12px;
}

.file-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #FFB74D 0%, #FF9800 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-right: 12px;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.file-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.file-actions {
    display: flex;
    gap: 8px;
    margin-left: 12px;
}

.file-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--bg);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.file-btn:active {
    background: var(--border);
}

/* 搜索结果 */
.search-results {
    margin-top: 20px;
}

.results-header {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.results-list {
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.result-card {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.result-card:last-child {
    border-bottom: none;
}

.result-card-title {
    font-size: 15px;
    color: var(--text);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 500;
    line-height: 1.4;
}

.result-card-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.result-card-btn {
    height: 34px;
    padding: 0 20px;
    border: none;
    border-radius: 17px;
    font-size: 14px;
    font-weight: 500;
    background: var(--primary);
    color: #FFF;
    cursor: pointer;
    transition: transform 0.1s;
}

.result-card-btn:active {
    transform: scale(0.96);
}

/* 设置 */
.settings-group {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.settings-header .settings-title {
    margin-bottom: 0;
}

.settings-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-text:active {
    opacity: 0.7;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.settings-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.settings-item:first-child {
    padding-top: 0;
}

.settings-item span {
    font-size: 15px;
    color: var(--text);
}

/* 开关 */
.switch {
    position: relative;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: 28px;
    transition: 0.3s;
}

.slider:before {
    content: '';
    position: absolute;
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background: #FFF;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider:before {
    transform: translateX(22px);
}

/* 底部导航 */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-height);
    padding-bottom: var(--safe-bottom);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    box-shadow: 0 -1px 10px rgba(0,0,0,0.05);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.tab-item.active {
    color: var(--primary);
}

.tab-icon {
    font-size: 22px;
    margin-bottom: 2px;
    line-height: 1;
}

.tab-text {
    font-size: 11px;
    font-weight: 500;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-box {
    width: 100%;
    max-width: 320px;
    background: var(--card);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-title {
    padding: 24px 24px 0;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    color: var(--text);
}

.modal-content {
    padding: 16px 24px 24px;
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    border-top: 1px solid var(--border);
}

.modal-actions button {
    flex: 1;
    height: 48px;
    border: none;
    background: none;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-actions button:active {
    background: var(--bg);
}

.modal-actions button:first-child {
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
}

.modal-actions button:last-child {
    color: var(--primary);
}

/* Toast - 轻量级提示 */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 8px 20px;
    background: rgba(0,0,0,0.75);
    color: #FFF;
    border-radius: 18px;
    font-size: 13px;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    text-align: center;
    white-space: nowrap;
    max-width: 80%;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: rgba(7, 193, 96, 0.9);
}

.toast.error {
    background: rgba(250, 81, 81, 0.9);
}

.toast.warning {
    background: rgba(255, 195, 0, 0.9);
    color: #1A1A1A;
}

/* 加载动画 */
.loading {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 滚动条 */
.page-content::-webkit-scrollbar {
    width: 0;
}

/* 安全区域 */
@supports (padding: env(safe-area-inset-bottom)) {
    .tab-bar {
        height: calc(var(--tab-height) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .page {
        bottom: calc(var(--tab-height) + env(safe-area-inset-bottom));
    }
}
