/* ============================================================
   仓库发货订单登记管理系统 - 自定义样式
   基于 Bootstrap 5
   ============================================================ */

:root {
    --sidebar-width: 230px;
    --sidebar-collapsed-width: 60px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --topbar-height: 56px;
}

* { box-sizing: border-box; }

html, body {
    overflow-x: hidden;
}

body {
    background-color: #f1f5f9;
    font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    margin: 0;
}

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 1030;
    transition: transform .25s ease;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

.app-content {
    flex: 1;
    padding: 20px;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar-brand {
    padding: 18px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand i { font-size: 1.4rem; color: #60a5fa; }

.sidebar-nav { padding: 8px 0; }

.menu-group { margin-bottom: 4px; }

.menu-group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 22px;
    color: #e2e8f0;
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.menu-group-title i:first-child { font-size: 1.05rem; width: 20px; text-align: center; }
.menu-group-title:hover { background: var(--sidebar-hover); color: #fff; }
.menu-group-title .menu-arrow {
    margin-left: auto;
    font-size: .7rem;
    transition: transform .2s;
    color: #64748b;
}

.menu-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
}

.menu-group.expanded .menu-group-items {
    max-height: 500px;
    overflow-y: auto;
}

.menu-group.expanded .menu-arrow {
    transform: rotate(180deg);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 22px 9px 54px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all .15s;
    border-left: 3px solid transparent;
    font-size: .9rem;
    position: relative;
}
.sidebar-link::before {
    content: '';
    position: absolute;
    left: 38px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #475569;
    transition: background .15s;
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.sidebar-link:hover::before { background: #60a5fa; }
.sidebar-link.active {
    background: rgba(59,130,246,.15);
    color: #fff;
    border-left-color: var(--sidebar-active);
}
.sidebar-link.active::before { background: #3b82f6; width: 6px; height: 6px; }

.menu-single {
    padding: 11px 22px;
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .5px;
    color: #e2e8f0;
    text-transform: uppercase;
}
.menu-single i:first-child {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    margin-right: 0;
}
.menu-single::before {
    display: none;
}
.menu-single:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.menu-single.active {
    background: rgba(59,130,246,.15);
    color: #fff;
    border-left-color: var(--sidebar-active);
}

/* ---------- Topbar ---------- */
.app-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.btn-toggle {
    background: none; border: none;
    font-size: 1.4rem; color: #475569;
    cursor: pointer; padding: 4px 8px;
}
.topbar-title {
    margin-left: 10px;
    font-size: 1.05rem; font-weight: 600; color: #1e293b;
}
.topbar-actions {
    margin-left: auto;
    display: flex; align-items: center; gap: 14px;
}
.user-info { color: #475569; font-size: .9rem; }

/* ---------- Footer ---------- */
.app-footer {
    padding: 14px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: .85rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

/* ---------- Cards & Tables ---------- */
.card { border: none; box-shadow: 0 1px 3px rgba(0,0,0,.06); overflow: hidden; }
.card-header { background: #fff; border-bottom: 1px solid #e2e8f0; font-weight: 600; }
.card-body { overflow: hidden; }
.table { margin-bottom: 0; }
.table th { font-weight: 600; color: #475569; background: #f8fafc; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table td { white-space: nowrap; }
.table-responsive {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    height: 500px !important;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    position: relative;
    background: #fff;
}
.table-responsive::-webkit-scrollbar { height: 10px; width: 10px; }
.table-responsive::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.order-table th, .order-table td { vertical-align: middle; }
.order-table thead th { position: sticky; top: 0; background: #f8fafc; z-index: 10; }
.order-table tbody tr:hover { background: #f8fafc; }

/* Pagination */
.pagination-wrap { padding: 12px 0 0; display: flex; align-items: center; gap: 12px; }
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.pagination li { margin: 0; }
.pagination li a,
.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #475569;
    font-size: .875rem;
    text-decoration: none;
    transition: all .15s ease;
    cursor: pointer;
    user-select: none;
    line-height: 1;
}
.pagination li a:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #f0f7ff;
}
.pagination li.active span {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
    font-weight: 600;
}
.pagination li.disabled span {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}
.pagination-info { color: #64748b; font-size: .875rem; margin-right: auto; }

/* ---------- Stat cards ---------- */
.stat-card {
    border-left: 4px solid var(--sidebar-active);
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: #1e293b; }
.stat-card .stat-label { color: #64748b; font-size: .85rem; }

/* ---------- System info ---------- */
.sys-info-table { font-size: .875rem; }
.sys-info-table td { padding: .55rem .75rem; vertical-align: middle; }
.sys-info-table tr:nth-child(even) td { background: #f8fafc; }
.sys-info-key {
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
    width: 35%;
}
.sys-info-table td:not(.sys-info-key) {
    color: #1e293b;
    word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: .82rem;
}
.sys-progress {
    height: 10px;
    border-radius: 6px;
    background: #e2e8f0;
    overflow: hidden;
}
.sys-progress .progress-bar {
    transition: width .4s ease;
    border-radius: 6px;
}

/* ---------- Login page ---------- */
.login-body {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-icon {
    width: 64px; height: 64px;
    background: #eff6ff; color: #3b82f6;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.8rem; margin-bottom: 12px;
}
.login-header h3 { margin: 0 0 6px; font-size: 1.25rem; color: #1e293b; }
.login-tip {
    margin-top: 18px; text-align: center;
    color: #94a3b8; font-size: .82rem;
}
.login-footer {
    margin-top: 20px; padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    text-align: center; font-size: .75rem; color: #94a3b8;
    line-height: 1.8;
}
.login-beian-link {
    color: #94a3b8; text-decoration: none; transition: color .15s;
}
.login-beian-link:hover { color: #3b82f6; text-decoration: none; }
.login-beian-sep { margin: 0 6px; color: #cbd5e1; }
.login-wrapper { max-width: 500px; padding: 20px; }
.login-card { padding: 36px 32px; }

.captcha-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.captcha-input-wrap {
    flex: 1 1 auto;
    min-width: 0;
}
.captcha-img-wrapper {
    flex: 0 0 208px;
    width: 208px;
    height: 52px;
    background: #f8fafc;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 3px 4px;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 0;
    box-sizing: border-box;
}
.captcha-img-wrapper img {
    display: block;
    width: 200px !important;
    height: 46px !important;
    border-radius: 3px;
    max-width: none !important;
    object-fit: none;
}

/* ---------- Badges ---------- */
.badge { font-weight: 500; }

/* ---------- Pagination ---------- */
.pagination { margin: 16px 0 0; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; color: #334155; }
.required::after { content: " *"; color: #dc3545; }

/* ---------- Order form ---------- */
.item-row td { vertical-align: middle; }
.product-select, .qty-input, .price-input { min-width: 140px; }
.subtotal-cell { font-weight: 600; color: #1e293b; }
.total-bar {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
}

/* ---------- Sidebar Collapsed (Desktop) ---------- */
.app-wrapper.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
    overflow: hidden;
}
.app-wrapper.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed-width);
}
.app-wrapper.sidebar-collapsed .sidebar-brand span,
.app-wrapper.sidebar-collapsed .sidebar-link span {
    display: none;
}
.app-wrapper.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 18px 10px;
}
.app-wrapper.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 11px;
}
.app-wrapper.sidebar-collapsed .sidebar-link i {
    font-size: 1.2rem;
    width: auto;
}
/* Collapsed: hide sub-items, show only category icons */
.app-wrapper.sidebar-collapsed .menu-group-items,
.app-wrapper.sidebar-collapsed .menu-group-title span,
.app-wrapper.sidebar-collapsed .menu-group-title .menu-arrow {
    display: none;
}
.app-wrapper.sidebar-collapsed .menu-group-title {
    justify-content: center;
    padding: 11px;
    font-size: 1.2rem;
}
.app-wrapper.sidebar-collapsed .menu-single {
    justify-content: center;
    padding: 11px;
    font-size: 1.2rem;
}
.app-wrapper.sidebar-collapsed .menu-single i {
    font-size: 1.2rem;
    width: auto;
}
.app-wrapper.sidebar-collapsed .menu-group {
    margin-bottom: 2px;
}

/* ---------- Mobile Overlay ---------- */
.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1025;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s, visibility .25s;
}
.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .app-sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .topbar-title { display: none; }
    .app-wrapper.sidebar-collapsed .app-sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }
    .app-wrapper.sidebar-collapsed .app-sidebar.show {
        transform: translateX(0);
    }
    /* Mobile menu adjustments */
    .menu-group-title { padding: 10px 16px; font-size: .8rem; }
    .menu-single { padding: 10px 16px; font-size: .8rem; }
    .sidebar-link { padding: 8px 16px 8px 44px; font-size: .85rem; }
    .sidebar-link::before { left: 28px; }
}

/* ---------- Responsive Table to Card ---------- */
@media (max-width: 768px) {
    .app-content { padding: 12px; }
    .card-header { padding: 12px 14px; font-size: .95rem; }
    .card-body { padding: 12px; }
    
    /* Mobile card layout: no independent scroll, no fixed height, no min-width */
    .table-responsive { 
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        border: none;
        border-radius: 0;
        background: transparent;
    }
    /* Override inline min-width on tables in mobile card view */
    .table-responsive table { min-width: 0 !important; width: 100%; }
    
    /* Hide table headers on mobile */
    .table-responsive table thead { display: none; }
    
    /* Each row becomes a card */
    .table-responsive table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 4px;
        box-shadow: 0 1px 3px rgba(0,0,0,.05);
    }
    
    /* Each cell becomes a label:value pair */
    .table-responsive table tbody tr td {
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        padding: 8px 12px;
        border: none;
        border-bottom: 1px solid #f1f5f9;
        font-size: .88rem;
        white-space: normal !important;
        text-align: right;
    }
    
    .table-responsive table tbody tr td:last-child {
        border-bottom: none;
    }
    
    /* data-label becomes the field name */
    .table-responsive table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        flex: 0 0 100px;
        margin-right: 12px;
        white-space: nowrap;
        text-align: left;
    }
    
    /* Special handling for action column */
    .table-responsive table tbody tr td.text-end,
    .table-responsive table tbody tr td.text-center {
        justify-content: flex-end;
    }
    
    .table-responsive table tbody tr td.text-end::before,
    .table-responsive table tbody tr td.text-center::before {
        display: none;
    }
    
    /* Hide ID column on mobile */
    .table-responsive table tbody tr td[data-label="ID"],
    .table-responsive table tbody tr td[data-label="id"] {
        display: none !important;
    }
    
    /* Search form becomes stacked */
    .search-form .col-sm-4,
    .search-form .col-sm-3,
    .search-form .col-sm-2,
    .search-form .col-sm-1 {
        width: 100%;
        margin-bottom: 8px;
    }
    
    /* Badges stay inline in cards */
    .table-responsive .badge { font-size: .75rem; }
    
    /* Pagination mobile */
    .pagination { justify-content: center; }
    .pagination li a,
    .pagination li span { min-width: 32px; height: 32px; padding: 0 8px; font-size: .8rem; }
}

/* ---------- Scan Modal ---------- */
.scan-modal .modal-body { padding: 20px; }
.scan-video {
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
    background: #000;
}
.scan-result {
    margin-top: 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: .9rem;
}

/* ---------- Camera / Photo ---------- */
.camera-container {
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
    margin-top: 8px;
}
.camera-gallery-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}
.camera-gallery-item {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 6px;
    overflow: hidden;
    background: #e2e8f0;
}
.camera-item-img-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}
.camera-item-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.camera-item-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(239, 68, 68, .85);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}
.camera-item-remove:hover {
    background: #ef4444;
}
.camera-item-watermark {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    padding: 3px 5px;
    font-size: 10px;
    line-height: 1.3;
    text-align: left;
    pointer-events: none;
    max-height: 50%;
    overflow: hidden;
}
.camera-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.camera-count-info {
    margin-left: auto;
}
.camera-video-preview {
    width: 100%;
    max-height: 60vh;
    border-radius: 8px;
    background: #000;
    object-fit: contain;
}
.camera-preview-wrap {
    margin-top: 12px;
}
.camera-preview-img {
    max-height: 50vh;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.image-thumb-wrapper {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: 8px;
    overflow: hidden;
    background: #e2e8f0;
    cursor: pointer;
}
.image-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .2s;
}
.image-thumb:hover {
    transform: scale(1.05);
}
.watermark-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    padding: 5px 8px;
    font-size: 11px;
    line-height: 1.4;
    text-align: left;
    pointer-events: none;
    max-height: 50%;
    overflow: hidden;
}

/* ---------- Profile ---------- */
.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: #eff6ff;
    color: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    flex-shrink: 0;
}

/* ---------- Status Tags ---------- */
.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: .78rem;
    font-weight: 500;
}
