/* ============================================
   拌面生成站 — 全局基础样式
   极简 · 科技感 · SF Pro 风格
   ============================================ */

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables */
:root {
    --bg-primary: #FAFAFA;
    --bg-white: #FFFFFF;
    --bg-input: #F5F5F7;
    --text-primary: #1A1A1A;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-placeholder: #AEAEB2;
    --accent: #0071E3;
    --accent-hover: #0077ED;
    --accent-light: rgba(0, 113, 227, 0.08);
    --border: #E5E5E5;
    --border-light: #F0F0F0;
    --danger: #FF3B30;
    --success: #34C759;
    --warning: #FF9500;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
    --font-stack: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
                  'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --max-width: 1200px;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-stack);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 17px; }

p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

.container-sm {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-stack);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-light);
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--accent);
    padding: 8px 16px;
}

.btn-ghost:hover {
    background: var(--accent-light);
}

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

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-family: var(--font-stack);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

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

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 10px;
    padding-right: 36px;
    height: 42px;
    cursor: pointer;
    line-height: 1;
}

.form-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   自定义下拉框
   ============================================ */
.cs-wrapper {
    position: relative;
    width: 100%;
    outline: none;
}

.cs-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 42px;
    padding: 0 36px 0 16px;
    font-size: 15px;
    font-family: var(--font-stack);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.cs-display svg {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.cs-wrapper.open .cs-display {
    border-color: var(--accent);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.cs-wrapper.open .cs-display svg {
    transform: rotate(180deg);
}

.cs-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease, opacity 0.15s ease;
    opacity: 0;
}

.cs-wrapper.open .cs-list {
    max-height: 300px;
    opacity: 1;
    overflow-y: auto;
}

.cs-item {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s ease;
    white-space: nowrap;
}

.cs-item:hover {
    background: var(--bg-input);
}

.cs-item.selected {
    color: var(--accent);
    font-weight: 500;
    background: var(--accent-light);
}

.cs-item.cs-placeholder {
    color: var(--text-muted);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .cs-display {
        height: 46px;
        font-size: 16px;
        padding: 0 36px 0 14px;
    }

    .cs-item {
        padding: 12px 14px;
        font-size: 15px;
    }
}

.form-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-error {
    font-size: 13px;
    color: var(--danger);
    margin-top: 6px;
}

/* Cards */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

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

.card-title {
    font-size: 17px;
    font-weight: 600;
}

/* Alert / Toast */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: var(--success);
    color: #fff;
}

.toast-error {
    background: var(--danger);
    color: #fff;
}

.toast-info {
    background: var(--accent);
    color: #fff;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    line-height: 1;
}

.badge-pending {
    background: #FFF3E0;
    color: var(--warning);
}

.badge-approved {
    background: #E8F5E9;
    color: var(--success);
}

.badge-rejected {
    background: #FFEBEE;
    color: var(--danger);
}

/* Table */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
}

table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-input);
}

table tr:hover {
    background: rgba(0, 113, 227, 0.02);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-lg { font-size: 18px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-dark {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--accent);
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

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

/* ============================================
   Responsive 移动端适配
   ============================================ */

@media (max-width: 768px) {
    :root {
        --max-width: 100%;
    }

    h1 { font-size: 22px; }
    h2 { font-size: 18px; }
    h3 { font-size: 16px; }

    .container {
        padding: 0 14px;
    }

    .card {
        padding: 16px;
    }

    /* 按钮全宽 */
    .btn-lg {
        width: 100%;
        padding: 14px;
    }

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

    .form-label {
        font-size: 13px;
    }

    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px; /* 防止 iOS 缩放 */
        padding: 10px 14px;
        height: 46px;
    }

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

    /* 表格 */
    table th,
    table td {
        padding: 8px 10px;
        font-size: 12px;
    }

    /* 弹窗 */
    .modal {
        width: 92%;
        padding: 24px;
        margin: 16px;
    }

    /* Toast */
    .toast {
        left: 16px;
        right: 16px;
        top: 16px;
        max-width: none;
        font-size: 13px;
    }

    /* 统计卡片 */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stats-card {
        padding: 14px;
    }

    .stats-card .value {
        font-size: 24px;
    }

    /* 筛选栏换行 */
    .form-select {
        font-size: 14px;
        height: 38px;
        padding: 6px 32px 6px 10px;
    }

    /* 分页 */
    .pagination button {
        padding: 6px 10px;
        font-size: 12px;
    }
}
