/* =======================================================
   全局重置与变量 — Apple 风格黑白灰设计系统
   ======================================================= */
:root {
    /* 主色调：苹果经典灰阶 */
    --bg-color: #f5f5f7;            /* 苹果标志性浅灰背景 */
    --card-bg: #ffffff;             /* 纯白卡片 */
    --card-border: #d2d2d7;         /* 细边框灰 */
    --card-border-light: #e8e8ed;   /* 更浅的分隔线 */

    /* 文字色阶 */
    --text-primary: #1d1d1f;        /* 苹果深黑文字 */
    --text-secondary: #424245;      /* 次级文字 */
    --text-muted: #86868b;          /* 辅助/占位文字 */

    /* 强调色：克制使用 */
    --accent: #0071e3;              /* 苹果链接蓝 */
    --accent-light: #e8f1fd;        /* 浅蓝背景 */
    --accent-hover: #0066cc;

    /* 功能色 */
    --success: #34c759;             /* 苹果绿 */
    --success-light: #eafbf0;
    --danger: #ff3b30;              /* 苹果红 */
    --danger-light: #fff0f0;

    /* 按钮色 */
    --btn-primary: #1d1d1f;         /* 黑色主按钮 */
    --btn-primary-hover: #424245;
    --btn-secondary: #ffffff;
    --btn-secondary-border: #d2d2d7;

    /* 阴影系统 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);

    --font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 30px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[v-cloak] {
    display: none !important;
}

/* =======================================================
   顶部导航 — 磨砂玻璃效果，苹果风
   ======================================================= */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--card-border-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 22px;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.app-version {
    font-size: 11px;
    background: var(--card-bg);
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--card-border-light);
    font-weight: 500;
}

/* =======================================================
   主容器
   ======================================================= */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* =======================================================
   选项卡控制器 — 苹果 Segmented Control 风格
   ======================================================= */
.tab-control {
    display: flex;
    background: #e8e8ed;
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.tab-btn .icon {
    font-size: 13px;
}

.tab-btn.active {
    background: #ffffff;
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* =======================================================
   卡片样式 — 纯白卡片 + 柔和阴影
   ======================================================= */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 1;
}

/* 下拉展开时提升卡片层级，避免被后续卡片遮挡 */
.card.card-dropdown-active {
    z-index: 10;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--card-border-light);
    display: flex;
    align-items: center;
}

.card-header.justify-between {
    justify-content: space-between;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.card-body {
    padding: 20px;
}

/* =======================================================
   网格布局
   ======================================================= */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.col-span-2 {
    grid-column: span 2;
}

.col-span-4 {
    grid-column: span 4;
}

/* =======================================================
   表单元素 — 苹果风输入框
   ======================================================= */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.margin-top-sm {
    margin-top: 12px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.2px;
}

.form-input {
    background: #f5f5f7;
    border: 1px solid transparent;
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: 100%;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn .form-input {
    flex: 1;
}

/* 产品自动建议下拉 */
.select-input-container {
    position: relative;
}

/* =======================================================
   自定义下拉建议列表
   ======================================================= */
.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    border-top: none;
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.custom-dropdown-item {
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--card-border-light);
}

.custom-dropdown-item:last-child {
    border-bottom: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.custom-dropdown-item:hover {
    background: var(--accent-light);
}

.custom-dropdown-item:active {
    background: rgba(0, 113, 227, 0.15);
}

/* 下拉列表滚动条美化 */
.custom-dropdown::-webkit-scrollbar {
    width: 4px;
}

.custom-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.custom-dropdown::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 2px;
}

/* =======================================================
   按钮样式
   ======================================================= */
.btn-small {
    background: #e8e8ed;
    border: 1px solid var(--card-border-light);
    color: var(--text-secondary);
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-small:hover {
    background: var(--card-border-light);
}

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

.btn-add {
    background: var(--text-primary);
    border: none;
    color: #ffffff;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add:hover {
    background: var(--btn-primary-hover);
}

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

.card-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-clear-cache {
    background: var(--danger-light);
    border: 1px solid rgba(255, 59, 48, 0.2);
    color: var(--danger);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-cache:hover {
    background: rgba(255, 59, 48, 0.12);
}

.btn-clear-cache:active {
    transform: scale(0.96);
}

.btn-delete-row {
    background: var(--danger-light);
    border: 1px solid rgba(255, 59, 48, 0.15);
    color: var(--danger);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete-row:hover {
    background: rgba(255, 59, 48, 0.12);
}

/* =======================================================
   商品条目编辑行
   ======================================================= */
.item-edit-row {
    background: #fafafa;
    border: 1px solid var(--card-border-light);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 12px;
    transition: border-color 0.2s ease;
}

.item-edit-row:hover {
    border-color: var(--card-border);
}

.item-edit-row:last-child {
    margin-bottom: 0;
}

.row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--card-border-light);
    padding-bottom: 8px;
}

.row-index {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.calculated-info {
    margin-top: 12px;
    background: #f5f5f7;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid var(--card-border-light);
}

.calculated-info strong {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
}

/* 行内计算信息容器与继续添加按钮样式 */
.calculated-info-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.calculated-info-container .calculated-info {
    flex: 1;
    margin-top: 0;
}

.btn-add-inline {
    background: var(--text-primary);
    border: none;
    color: #ffffff;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add-inline:hover {
    background: var(--btn-primary-hover);
}

.btn-add-inline:active {
    transform: scale(0.96);
}

/* =======================================================
   合计汇总卡片
   ======================================================= */
.total-summary-card {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--text-primary);
    color: #ffffff;
    border: none;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
}

.total-amount {
    font-size: 20px;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* =======================================================
   按钮组
   ======================================================= */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.secondary-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.secondary-actions .btn-secondary,
.secondary-actions .btn-toggle-info {
    flex: 1;
    padding: 13px 4px;
    font-size: 14px;
}


.btn-primary {
    background: var(--btn-primary);
    border: none;
    color: #ffffff;
    padding: 13px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

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

.btn-secondary {
    background: var(--btn-secondary);
    border: 1px solid var(--btn-secondary-border);
    color: var(--text-primary);
    padding: 13px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f5f5f7;
}

.btn-secondary:active {
    transform: scale(0.98);
}

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

.btn-dark {
    background: #e8e8ed;
    border: 1px solid var(--card-border-light);
    color: var(--text-primary);
    padding: 13px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-dark:hover {
    background: var(--card-border-light);
}

.btn-dark:active {
    transform: scale(0.98);
}

.btn-toggle-info {
    background: #ffffff;
    border: 1px dashed var(--card-border);
    color: var(--text-secondary);
    padding: 13px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-toggle-info:hover {
    background: #f5f5f7;
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-toggle-info:active {
    transform: scale(0.98);
}

/* =======================================================
   预览与提示
   ======================================================= */
.preview-tip {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 20px;
    line-height: 1.6;
    font-weight: 500;
}

/* =======================================================
   拟真发货单样式 — 核心设计 (竖版排版)
   ======================================================= */

.invoice-container-wrapper {
    width: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
    background: #e8e8ed;
    padding: 15px;
}

.invoice-scale-wrapper {
    transform-origin: top center;
    width: 700px;
    transition: transform 0.2s ease;
}

.invoice-paper {
    width: 700px;
    min-height: 990px;
    background: #ffffff;
    color: #000000;
    padding: 35px 30px;
    box-sizing: border-box;
    font-family: 'SimSun', 'STSong', 'Noto Sans SC', serif;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 强制该区域的文字和边框都是纯黑色，打印也好看 */
.invoice-paper * {
    color: #000000 !important;
    border-color: #000000 !important;
}

.invoice-title {
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.invoice-subtitle {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 5px;
    text-decoration: underline;
    margin-bottom: 25px;
}

/* 头部信息布局 */
.invoice-meta-info {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: 12px;
    row-gap: 6px;
    column-gap: 15px;
}

.meta-item {
    display: flex;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meta-item strong {
    font-weight: bold;
}

.meta-item span {
    border-bottom: 1px solid #000000;
    flex: 1;
    padding-left: 4px;
}

/* 发货单主表格 */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 13px;
}

.invoice-table th,
.invoice-table td {
    border: 1px solid #000000;
    padding: 8px 4px;
    line-height: 1.2;
    height: 32px;
}

.invoice-table th {
    font-weight: bold;
    text-align: center;
    background: #f3f4f6;
}

.invoice-table td {
    word-break: break-all;
}

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

.text-right {
    text-align: right;
    padding-right: 6px !important;
}

.font-bold {
    font-weight: bold;
}

.total-row td {
    background: #f9fafb;
}

/* 底部声明 */
.invoice-disclaimer {
    font-size: 12px;
    margin-bottom: 15px;
    font-style: italic;
}

/* 银行账户信息 */
.invoice-bank-info {
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 25px;
    border: 1px dashed #000000;
    padding: 10px 15px;
    background: #fcfcfc;
}

.bank-row {
    display: flex;
}

.bank-row strong {
    width: 75px;
}

/* 提货签字栏 */
.invoice-footer-signatures {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1.3fr;
    font-size: 13px;
    margin-top: 30px;
    border-top: 1px solid #000000;
    padding-top: 12px;
}

.sig-item {
    display: flex;
}

.sig-item span {
    border-bottom: 1px solid #000000;
    flex: 1;
    padding-left: 6px;
}

/* =======================================================
   全屏弹窗样式
   ======================================================= */
.modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 0;
}

.modal-container {
    background: transparent;
    border: none;
    border-radius: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.modal-header h3 {
    font-size: 15px;
    color: #ffffff;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: #ff6b6b;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #ff3b30;
}

.modal-body {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background: #000000;
    overflow: hidden;
}

.modal-tip {
    position: absolute;
    top: 15px;
    background: rgba(255, 255, 255, 0.9);
    color: #1d1d1f !important;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 5;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.generated-image-box {
    background: #000;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.result-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.1);
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(20px);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.btn-download {
    flex: 1;
    background: #ffffff;
    color: #1d1d1f;
    text-decoration: none;
    text-align: center;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 42px;
}

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

.btn-pdf-modal {
    flex: 1;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 42px;
}

.btn-pdf-modal:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-pdf-modal:active {
    transform: scale(0.98);
}

.btn-close-modal {
    flex: 1;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 42px;
}

.btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-close-modal:active {
    transform: scale(0.98);
}

/* =======================================================
   加载指示器
   ======================================================= */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 245, 247, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    gap: 16px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e8e8ed;
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* =======================================================
   兼容性与移动端体验优化
   ======================================================= */
@media (max-width: 480px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .col-span-2 {
        grid-column: span 1;
    }

    .card-body {
        padding: 16px;
    }

    .app-header {
        padding: 12px 16px;
    }

    .app-header h1 {
        font-size: 16px;
    }
}

/* 预览页面底部按钮横向并排布局 */
.preview-actions {
    flex-direction: row;
    gap: 8px;
    width: 100%;
}

.preview-actions .btn-primary,
.preview-actions .btn-secondary,
.preview-actions .btn-dark {
    flex: 1;
    padding: 12px 2px;
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    height: 46px;
    margin: 0;
}

