/* 文件: /assets/css/style.css (已更新布局样式) */

/* --- 统一后台布局样式 --- */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* 在桌面端也默认禁止body滚动，由子容器控制 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f4f7f9;
    color: #333;
    line-height: 1.5;
    font-size: 14px;
}

.dashboard-layout { 
    display: flex; 
    height: 100vh; 
    width: 100%;
}
.sidebar {
    width: 220px;
    background-color: #2c3e50;
    color: white;
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-sizing: border-box;
}
.sidebar .brand { text-align: center; color: #ecf0f1; border-bottom: 1px solid #34495e; padding-bottom: 15px; }
.sidebar ul { list-style: none; padding: 0; margin-top: 30px; }
.sidebar .nav-link {
    display: block;
    padding: 12px 15px;
    color: #bdc3c7;
    text-decoration: none;
    border-radius: 4px;
    margin-bottom: 5px;
    transition: background-color 0.3s, color 0.3s;
}
.sidebar .nav-link:hover { background-color: #34495e; color: #ecf0f1; }
.sidebar .nav-link.active { background-color: #1abc9c; color: white; font-weight: bold; }
.user-info-footer { margin-top: auto; text-align: center; font-size: 14px; color: #bdc3c7;}
.user-info-footer a { color: #e74c3c; text-decoration: none; display: block; margin-top: 5px; }
.user-info-footer a:hover { text-decoration: underline; }
.main-content { 
    flex-grow: 1; 
    padding: 20px; 
    background-color: #f4f7f9; 
    overflow-y: auto;  /* 这是允许滚动的主容器 */
    -webkit-overflow-scrolling: touch; /* 在iOS上开启流畅滚动 */
    height: 100%;
    box-sizing: border-box;
}
.view { display: none; }
.view.active { display: block; }
h1, h2 { color: #1a237e; border-bottom: 2px solid #e0e0e0; padding-bottom: 8px; margin-top: 0; }
h1 { margin-bottom: 20px; }
h2 { margin-bottom: 10px; }
/* --- 登录页样式 (特殊处理) --- */
body.login-page {
    overflow: auto; /* 登录页允许body滚动，因为它没有复杂的内部滚动容器 */
}
#login-container {
    width: 100%; max-width: 360px; padding: 30px; background-color: #fff;
    border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin: 80px auto; /* 使用margin使其在可滚动的body中居中 */
}
#login-container h1 { text-align: center; margin-bottom: 25px; border-bottom: none; }
#login-container .input-group { margin-bottom: 20px; }
#login-container label { display: block; margin-bottom: 5px; font-weight: bold; }
#login-container input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
#login-container button { width: 100%; padding: 12px; font-size: 16px; }
#login-error-message { margin-top: 15px; text-align: center; }

/* --- 通用组件样式 --- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; background-color: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); box-sizing: border-box; }
.section { margin-bottom: 15px; }
textarea { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; margin-bottom: 10px; overflow-y: hidden; resize: none; }
.recipient-info-textarea { padding: 6px; font-family: inherit; font-size: inherit; resize: vertical; height: 30px; }
button { background-color: #3f51b5; color: white; border: none; padding: 10px 15px; text-align: center; text-decoration: none; display: inline-block; font-size: 14px; margin: 4px 2px; cursor: pointer; border-radius: 4px; transition: background-color 0.3s; }
button:hover { background-color: #303f9f; }
button:disabled { background-color: #9fa8da; cursor: not-allowed; }
button.confirm { background-color: #28a745; }
button.confirm:hover { background-color: #218838; }
.add-item-btn { background-color: #17a2b8; }
.add-item-btn:hover { background-color: #138496; }
.delete-btn { background-color: #dc3545; font-size: 12px; padding: 4px 8px; }
.delete-btn:hover { background-color: #c82333; }
#preview-section { position: relative; }
#preview-table { width: 100%; border-collapse: collapse; margin-top: 15px; table-layout: fixed; }
.autocomplete-container { position: relative; }
#preview-table th, #preview-table td { border: 1px solid #ddd; padding: 8px; text-align: left; vertical-align: top; word-break: break-all; }
#preview-table th { background-color: #f2f2f2; }
input[type="text"], input[type="number"], select { width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
#desktop-add-order-btn { padding: 4px 10px; font-size: 12px; margin: 0; }
.salesperson-col { width: 10%; }
.recipient-col { width: 25%; }
.item-name-col { width: 25%; }
.quantity-col { width: 6%; }
.price-col { width: 8%; }
.orderid-col { width: 13%; }
.customer-col { width: 13%; }
.action-col { width: 7%; text-align: center; }
.error { color: #d32f2f; font-weight: bold; background-color: #ffebee; padding: 10px; border-radius: 4px; }
#toast-notification { visibility: hidden; min-width: 250px; margin-left: -125px; color: #fff; text-align: center; border-radius: 4px; padding: 16px; position: fixed; z-index: 1001; left: 50%; bottom: 50px; font-size: 17px; opacity: 0; transition: opacity 0.5s, visibility 0.5s; }
#toast-notification.show { visibility: visible; opacity: 1; }
.toast-success { background-color: #43a047; }
.toast-error { background-color: #d32f2f; }
.autocomplete-items { position: absolute; border: 1px solid #d4d4d4; border-top: none; z-index: 9999; background-color: #fff; max-height: 200px; overflow-y: auto; box-shadow: 0 4px 8px rgba(0,0,0,0.1); width: 100%; box-sizing: border-box; }
.autocomplete-items div { padding: 10px; cursor: pointer; background-color: #fff; border-bottom: 1px solid #d4d4d4; }
.autocomplete-items div:hover { background-color: #e9e9e9; }
.autocomplete-active { background-color: DodgerBlue !important; color: #ffffff; }
#mobile-preview-container { display: none; }

/* --- 发货页样式 --- */
#shipping-view .container { max-width: 800px; } /* 适当加宽以容纳新表单 */
#shipping-view h1 { text-align: center; color: #1a1a1a; margin-bottom: 24px; }
#shipping-view .input-group { display: flex; gap: 10px; margin-bottom: 20px; }
#order-id-input { flex-grow: 1; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; }
#search-btn { padding: 10px 20px; font-size: 16px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s; }
#search-btn:hover { background-color: #0056b3; }
#search-btn:disabled, #print-btn:disabled, #notification-submit-btn:disabled { background-color: #a0a0a0; cursor: not-allowed; }
#order-card { display: none; margin-top: 20px; }
.recipient-info { background-color: #e9f5ff; padding: 15px; border-radius: 6px; margin-bottom: 15px; border-left: 5px solid #007bff; }
.products-table { width: 100%; border-collapse: collapse; }
.products-table th, .products-table td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; }
.products-table th { background-color: #f2f2f2; }
.products-table .quantity-input { width: 60px; text-align: center; border: 1px solid #ccc; border-radius: 3px; }
#print-btn { width: 100%; padding: 12px; font-size: 18px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer; margin-top: 20px; transition: background-color 0.3s; }
#print-btn:hover { background-color: #218838; }
.message { margin-top: 20px; padding: 15px; border-radius: 4px; text-align: center; font-weight: bold; }
.message.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.message.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.message.loading { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* --- 通知模块的样式 --- */
#notification-view .input-group-vertical { display: flex; flex-direction: column; margin-bottom: 15px; }
#notification-view .input-group-vertical label { margin-bottom: 5px; font-weight: bold; }
#notification-view textarea { min-height: 150px; resize: vertical; }
#notification-submit-btn { width: 100%; padding: 12px; font-size: 16px; background-color: #ff9800; }
#notification-submit-btn:hover { background-color: #f57c00; }
.btn-small { padding: 5px 10px; font-size: 12px; margin-right: 5px; background-color: #6c757d; }
.btn-small:hover { background-color: #5a6268; }

/* --- 响应式布局 --- */
@media screen and (min-width: 769px) {
    #mobile-global-controls { display: none; }
}

@media screen and (max-width: 768px) {
    body { background-color: #fff; }
    .main-content { padding: 0; }
    .container { padding: 10px; box-shadow: none; border-radius: 0; height: 100%; box-sizing: border-box; }
    .dashboard-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; flex-direction: row; align-items: center; justify-content: space-between; box-sizing: border-box; }
    .sidebar .brand { font-size: 1.2em; border: none; }
    .sidebar ul { display: flex; gap: 5px; margin: 0; }
    .sidebar .nav-link { padding: 8px 10px; }
    .user-info-footer { display: none; }
    h1 {font-size: 1.5em;}
    #login-container input, .mobile-card input[type="text"], .mobile-card input[type="number"], .mobile-card textarea, .items-table input, #order-id-input, #tracking-number-input, #notify-content { font-size: 16px !important; }
    #preview-table { display: none; }
    #desktop-add-order-btn { display: none; }
    #mobile-preview-container { display: flex; flex-direction: column; gap: 15px; margin-top: 15px; }
    .mobile-card { border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); overflow: visible; position: relative; }
    .mobile-card-header { display: flex; gap: 10px; background-color: #f8f9fa; padding: 10px 40px 10px 10px; border-bottom: 1px solid #ddd; flex-wrap: wrap; }
    .delete-card-btn { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1; padding: 0; }
    .mobile-card-header .autocomplete-container { flex: 1; min-width: 100px; }
    .mobile-card-header .salesperson-input-container { flex-grow: 0.8; }
    .mobile-card-body { padding: 10px; }
    .mobile-card-body .orderid-input { margin-bottom: 10px; }
    .items-table { width: 100%; border-collapse: collapse; }
    .items-table th, .items-table td { padding: 8px 4px; border: none; border-bottom: 1px solid #eee; text-align: left; vertical-align: middle; }
    .items-table tr:last-child td { border-bottom: none; }
    .items-table thead th { font-weight: bold; color: #333; background-color: #f8f9fa; }
    .items-table input { width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
    .items-table input[type="number"] { text-align: right; }
    .mobile-item-name-col { width: auto; }
    .mobile-quantity-col { width: 50px; }
    .mobile-price-col { width: 75px; }
    .mobile-action-col { width: 50px; text-align: center; }
    .add-item-to-order-btn { width: 100%; margin-top: 10px; background-color: #20c997; padding: 6px 12px; font-size: 13px; }
    .add-item-to-order-btn:hover { background-color: #1baa80; }
    #mobile-global-controls { margin-top: 15px; display: flex; gap: 10px; }
    #mobile-global-controls button { flex: 1; padding: 8px 12px; font-size: 14px; }
}

/* --- V3 新增：发货页结构化地址样式 --- */
.structured-address-group {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}
.structured-address-group .input-field,
#tracking-result-area .input-field {
    display: flex;
    flex-direction: column;
}
.structured-address-group .input-field.full-width {
    grid-column: 1 / -1;
}

/* [新增] 省市区行的特殊样式 */
.address-row {
    grid-column: 1 / -1; /* 让这个容器占据整行 */
    display: flex;
    gap: 15px;
}
.address-row .input-field {
    flex: 1; /* 让省、市、区输入框平分空间 */
}


.structured-address-group label,
#tracking-result-area label {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 14px;
    color: #333;
}
.structured-address-group input,
.structured-address-group select,
#tracking-result-area input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}
#shipping-actions-container {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
#shipping-actions-container button {
    flex: 1 1 auto; /* 允许按钮在小屏幕上换行 */
    padding: 10px 15px;
    min-width: 120px; /* 保证按钮不会被过度压缩 */
}
#push-to-erp-shipping-btn { background-color: #00796b; }
#push-shipping-notification-btn { background-color: #ff9800; }
#print-packing-slip-btn { background-color: #6c757d; }

@media screen and (max-width: 768px) {
    .structured-address-group {
        grid-template-columns: 1fr;
    }
    /* [新增] 移动端省市区行的样式 */
    .address-row {
        flex-direction: column; /* 在移动端，让省、市、区垂直排列 */
    }
}