/* ============================================================
   胶料管理系统 - 全平台响应式样式 (iOS / Android / HarmonyOS)
   ============================================================ */

/* ----- CSS 变量 ----- */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --accent: #0891b2;
    --bg-light: #f8fafc;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --bottom-nav-height: 60px;
    --touch-min: 44px;
}

/* ----- 全局重置 ----- */
*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: var(--bg-light);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 1rem);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ----- 导航栏 ----- */
.navbar {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    padding-top: calc(0.5rem + var(--safe-top));
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.logo-img {
    height: 32px; width: 32px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    padding: 3px;
}

/* ----- 卡片 ----- */
.card {
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08) !important; }
.card-header {
    border-bottom: 1px solid var(--border);
    border-radius: 12px 12px 0 0 !important;
}

/* ----- 表格（桌面端） ----- */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background-color: var(--primary-light); }

.amb-code {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--primary-dark);
    font-weight: 500;
}

/* ========== 移动端卡片视图 ========== */
.glue-card {
    border-left: 4px solid var(--primary) !important;
    border-radius: 10px !important;
    transition: transform 0.15s, box-shadow 0.15s;
}
.glue-card:active {
    transform: scale(0.985);
    box-shadow: 0 1px 6px rgba(0,0,0,0.06) !important;
}

.amb-code-mobile {
    background: #f1f5f9;
    color: var(--primary-dark);
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: monospace;
}
.text-separator { color: #cbd5e1; }

/* ----- 移动端底部导航栏 ----- */
.mobile-bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1050;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 48px; min-height: var(--touch-min);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    gap: 2px;
    transition: color 0.15s;
}
.bottom-nav-item i { font-size: 1.3rem; }
.bottom-nav-item.active,
.bottom-nav-item:active { color: var(--primary); }

/* ----- 表单 ----- */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}
.form-label {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}
.form-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* 移动端表单全宽 */
@media (max-width: 767.98px) {
    .form-control, .form-select, .btn {
        font-size: 16px !important; /* 防止 iOS 缩放 */
    }
    .form-control { min-height: var(--touch-min); }
    .btn { min-height: var(--touch-min); padding: 0.5rem 1rem; }
    .card-body { padding: 0.75rem !important; }
}

/* ----- 按钮 ----- */
.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background-color: var(--primary-dark); border-color: var(--primary-dark); }

/* 移动端按钮全宽化 */
.btn-group-sm > .btn { min-height: 36px; }

/* ----- 徽章 ----- */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}
.badge-sm { font-size: 0.7rem; padding: 0.2em 0.5em; }

/* ----- Alert 提示 ----- */
.custom-alert {
    border-radius: 10px;
    font-size: 0.9rem;
}

/* ----- 空状态 ----- */
.empty-state { padding: 2rem 0; }

/* ----- 页脚 ----- */
.footer {
    border-top: 1px solid var(--border);
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ----- 面包屑 ----- */
.breadcrumb { font-size: 0.9rem; }

/* ----- 页面标题 ----- */
.page-title { font-weight: 700; color: var(--text); }

/* ----- 导入导出 Toast ----- */
.toast-container-custom {
    position: fixed; top: 1rem; right: 1rem; z-index: 9999;
}

/* ========== 响应式断点 ========== */

/* 平板 (md: ≥768px) */
@media (min-width: 768px) {
    body { padding-bottom: 2rem; }
    .navbar-brand { font-size: 1.25rem; }
    .logo-img { height: 36px; width: 36px; }
}

/* 手机 (sm: <576px) */
@media (max-width: 575.98px) {
    .navbar-brand span { font-size: 0.95rem; }
    .page-title { font-size: 1.15rem; }
    .container { padding-left: 12px; padding-right: 12px; }
    input, select, textarea { font-size: 16px !important; }
    .btn-sm { font-size: 0.85rem; }
}

/* iPhone X+ 刘海屏适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
}
