/* ==================== CSS 变量 ==================== */
:root {
    /* 浅色模式 */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #e8e8ed;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --border-color: #d2d2d7;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-heavy: rgba(0, 0, 0, 0.2);
    --accent: #007AFF;
    --accent-hover: #0051D5;
    --danger: #FF3B30;
    --danger-hover: #D70015;
    --success: #34C759;
    --backdrop: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] {
    /* 深色模式 */
    --bg-primary: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --bg-tertiary: #3a3a3c;
    --text-primary: #ffffff;
    --text-secondary: #98989d;
    --text-tertiary: #636366;
    --border-color: #38383a;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-heavy: rgba(0, 0, 0, 0.5);
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --danger: #FF453A;
    --danger-hover: #FF6961;
    --success: #32D74B;
    --backdrop: rgba(0, 0, 0, 0.6);
}

/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 应用容器 ==================== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* ==================== 顶部工具栏 ==================== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.logo-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}

.top-actions {
    display: flex;
    gap: 12px;
}

/* ==================== 按钮样式 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* 链接式按钮（a 标签套 .btn，如"联系客服"），去掉默认下划线 */
a.btn {
    text-decoration: none;
}

/* 弹窗底部的左侧操作按钮，把"关闭"挤到右边 */
.modal-footer .btn-contact {
    margin-right: auto;
}

/* ==================== 主内容区 ==================== */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
}

.left-sidebar {
    width: 280px;
    min-width: 280px;
}

.right-sidebar {
    width: 320px;
    min-width: 320px;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.image-count {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== 图片列表 ==================== */
.image-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.image-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.image-item.active {
    background: var(--accent);
    color: white;
}

.image-item.active .image-item-info span {
    color: rgba(255, 255, 255, 0.8);
}

.image-item-thumb {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

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

.image-item-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-item-size {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.image-item-remove {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.image-item-remove:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

/* ==================== 预览区 ==================== */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    overflow: hidden;
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    background: var(--bg-primary);
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(0, 122, 255, 0.05);
    transform: scale(1.02);
}

.drop-zone svg {
    color: var(--text-tertiary);
    margin-bottom: 20px;
}

.drop-zone h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.drop-zone p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.preview-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--shadow-heavy);
}

.preview-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 4px 16px var(--shadow);
    font-size: 13px;
    color: var(--text-secondary);
}

.preview-info span {
    white-space: nowrap;
}

/* ==================== EXIF 面板 ==================== */
.exif-panel {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.exif-section {
    margin-bottom: 24px;
}

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

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.gps-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.gps-group .form-group {
    flex: 1;
    margin-bottom: 0;
}

.gps-group button {
    padding: 10px 16px;
    white-space: nowrap;
}

/* ==================== 底部工具栏 ==================== */
.bottom-bar {
    padding: 12px 20px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.batch-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.batch-tools {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.mobile-edit-toggle {
    display: none;
}

.mobile-list-toggle {
    display: none;
}

/* ==================== 空状态 ==================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-tertiary);
    text-align: center;
    padding: 40px 20px;
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
    line-height: 1.6;
}

/* ==================== 模态框 ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--backdrop);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

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

.modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 20px 60px var(--shadow-heavy);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.gps-input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.gps-input-group .form-group {
    flex: 1;
}

/* ==================== Toast 提示 ==================== */
/* ==================== 授权 / 剩余次数 ==================== */

/* 顶栏的剩余次数标记 */
.quota-badge {
    margin-left: 6px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 500;
    line-height: 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    white-space: nowrap;
}

.quota-badge.warn {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
}

.quota-badge.danger {
    background: #ff3b30;
    color: #fff;
}

/* 授权弹窗里的剩余次数块 */
.auth-status {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 16px;
    margin-bottom: 18px;
    border-radius: 12px;
    background: var(--bg-secondary);
}

.auth-status-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-status-value {
    font-size: 22px;
    font-weight: 500;
    color: var(--accent);
}

/* 输入框与按钮并排 */
.device-code-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.device-code-row input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.5px;
}

/* 表单下方提示文字 */
.form-hint {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.form-hint.error {
    color: #ff3b30;
}

.form-hint.success {
    color: #34c759;
}

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 20px;
    box-shadow: 0 8px 32px var(--shadow-heavy);
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    max-width: 90vw;
    max-height: 40vh;
    overflow-y: auto;
    word-break: break-word;
    white-space: normal;
    line-height: 1.5;
}

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

/* ==================== 滚动条样式 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1024px) {
    .left-sidebar {
        width: 240px;
        min-width: 240px;
    }

    .right-sidebar {
        width: 280px;
        min-width: 280px;
    }
}

@media (max-width: 768px) {
    .top-bar {
        padding: 10px 16px;
    }

    .logo span {
        display: none;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .btn svg {
        width: 18px;
        height: 18px;
    }

    .top-actions .btn span {
        display: none;
    }

    /* 移动端侧边栏处理 */
    .main-content {
        position: relative;
    }

    .left-sidebar,
    .right-sidebar {
        position: fixed;
        top: 57px;
        bottom: 69px;
        z-index: 50;
        transition: transform 0.3s ease;
        box-shadow: 0 0 20px var(--shadow-heavy);
    }

    .left-sidebar {
        left: 0;
        width: 280px;
        transform: translateX(-100%);
    }

    .right-sidebar {
        right: 0;
        left: auto;
        width: 100%;
        max-width: 100%;
        transform: translateX(100%);
    }

    .left-sidebar.show {
        transform: translateX(0);
    }

    .right-sidebar.show {
        transform: translateX(0);
    }

    /* 添加遮罩层 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 57px;
        left: 0;
        right: 0;
        bottom: 69px;
        background: var(--backdrop);
        z-index: 49;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .preview-area {
        width: 100%;
    }

    /* 显示移动端编辑按钮 */
    .mobile-edit-toggle {
        display: inline-flex !important;
    }

    /* 显示移动端列表按钮 */
    .mobile-list-toggle {
        display: inline-flex !important;
    }

    /* 批量工具按钮文字隐藏 */
    .batch-tools .btn-text {
        display: none;
    }

    .batch-tools {
        justify-content: center;
    }

    .modal-content {
        width: 95%;
        max-width: none;
    }

    .preview-info {
        flex-direction: column;
        gap: 4px;
        font-size: 12px;
    }

    /* 底部工具栏优化 */
    .bottom-bar {
        padding: 8px 12px;
    }

    .batch-tools-header {
        flex-wrap: wrap;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .top-bar,
    .bottom-bar,
    .sidebar {
        display: none;
    }

    .preview-area {
        width: 100%;
    }
}

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

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

/* ==================== 辅助类 ==================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

/* ==================== 预设选择器样式 ==================== */
.preset-section {
    margin-bottom: 24px;
}

.preset-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.preset-section-title svg {
    flex-shrink: 0;
}

/* 搜索输入框（带图标） */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper .search-input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-tertiary);
    pointer-events: none;
    flex-shrink: 0;
}

.search-input-wrapper input {
    width: 100%;
    padding-left: 38px;
}

.preset-brand-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-brand-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.preset-brand-item.expanded {
    background: var(--accent);
    color: white;
}

.preset-brand-name {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 500;
}

.preset-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.preset-brand-icon svg {
    width: 18px;
    height: 18px;
}

.preset-brand-item.expanded .preset-brand-icon {
    color: white;
}

.preset-brand-arrow {
    font-size: 18px;
    transition: transform 0.2s ease;
}

.preset-brand-item.expanded .preset-brand-arrow {
    transform: rotate(90deg);
}

.preset-models-list {
    margin-top: 8px;
    padding-left: 16px;
    display: none;
}

.preset-models-list.show {
    display: block;
}

.preset-model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin-bottom: 6px;
    background: var(--bg-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-model-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.preset-model-item.selected {
    background: var(--accent);
    color: white;
}

.preset-model-name {
    font-size: 14px;
    font-weight: 500;
}

.preset-model-actions {
    display: flex;
    gap: 8px;
}

.preset-favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: transform 0.2s ease, color 0.2s ease;
}

.preset-favorite-btn svg {
    width: 18px;
    height: 18px;
}

.preset-favorite-btn:hover {
    transform: scale(1.2);
    color: var(--text-secondary);
}

.preset-favorite-btn.active {
    color: #FFB300;
    filter: drop-shadow(0 0 4px rgba(255, 179, 0, 0.5));
}

.preset-apply-btn {
    padding: 4px 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-apply-btn:hover {
    background: var(--accent-hover);
}

.preset-model-item.selected .preset-apply-btn {
    background: white;
    color: var(--accent);
}

.preset-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-search-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.preset-search-item.selected {
    background: var(--accent);
    color: white;
}

.preset-search-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preset-search-brand {
    font-size: 12px;
    opacity: 0.8;
}

.preset-search-model {
    font-size: 14px;
    font-weight: 500;
}

.preset-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

.preset-empty svg {
    margin-bottom: 16px;
    opacity: 0.5;
}
