/* CWA 庫存管理系統 - 樣式表 */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Microsoft JhengHei', 'Hiragino Sans', sans-serif;
    background: #fafbfc;
    color: #2c3e50;
    line-height: 1.7;
    font-size: 16px;
}

.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }

/* 導航列 */
.navbar {
    background: #fff;
    padding: 1.2rem 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-bottom: 1px solid #e8edf2;
}
.navbar h1 { margin-bottom: 0.5rem; font-size: 1.6rem; color: #3a9a6e; font-weight: 600; }
.navbar h1 a { color: inherit; text-decoration: none; }
.navbar ul { list-style: none; display: flex; gap: 1.5rem; flex-wrap: wrap; }
.navbar a {
    color: #5a7d9a; text-decoration: none;
    padding: 0.6rem 1.2rem; border-radius: 6px;
    transition: all 0.3s; font-weight: 400;
    font-size: 1rem;
}
.navbar a:hover, .navbar a.active { background: #edf7f2; color: #3a9a6e; }

.main-content { padding: 2rem 0; }

h2 { color: #3a9a6e; margin-bottom: 1.5rem; font-size: 1.8rem; font-weight: 500; }
h3 { color: #555; margin-bottom: 1rem; font-size: 1.3rem; }

/* 統計卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem; margin-bottom: 2rem;
}
.stat-card {
    background: white; padding: 1.8rem; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid #e8edf2;
    text-align: center; transition: all 0.3s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(58,154,110,0.12); }
.stat-card h3 { color: #888; font-size: 1rem; margin-bottom: 0.4rem; }
.stat-value { font-size: 2.6rem; font-weight: 500; color: #3a9a6e; }
.stat-card.warn  .stat-value { color: #d97706; }
.stat-card.danger .stat-value { color: #dc2626; }

/* 卡片 */
.card {
    background: white; padding: 1.8rem; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid #e8edf2;
    margin-bottom: 2rem;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; padding-bottom: 0.8rem;
    border-bottom: 1px solid #eef2f8;
}
.two-column {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

/* 表格 */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid #e0e8f0; }
table { width: 100%; border-collapse: collapse; }
thead { background: #f7faf8; }
th { padding: 0.9rem 1rem; text-align: left; font-weight: 500; color: #4a7d6a; border-bottom: 2px solid #e0e8f0; }
td { padding: 0.85rem 1rem; border-bottom: 1px solid #f0f4f2; }
tr:hover { background: #f6fbf8; }

/* ── 欄寬依內容自動調整的表格（table-layout:auto，瀏覽器原生行為） ──
   欄位寬度會依該欄實際資料長度自動分配，短資料欄自動變窄、長資料欄
   自動變寬，不需手動指定百分比。長文字欄位（備註等）可在該td加
   class="wrap-cell" 讓它換行不撐開整表。 */
.auto-fit-table { table-layout: auto; width: auto; min-width: 100%; }
.auto-fit-table th { width: auto; white-space: nowrap; }
.auto-fit-table td { white-space: nowrap; }
.auto-fit-table td.wrap-cell { white-space: normal; }

/* 徽章 */
.badge {
    display: inline-block; padding: 0.25rem 0.75rem;
    border-radius: 20px; font-size: 0.82rem; font-weight: 600;
}
.badge-normal  { background: #d1fae5; color: #065f46; }
.badge-low     { background: #fef3c7; color: #92400e; }
.badge-out     { background: #fee2e2; color: #991b1b; }
.badge-in      { background: #dbeafe; color: #1e40af; }
.badge-sale    { background: #f3e8ff; color: #6b21a8; }
.badge-loss    { background: #ffe4e6; color: #9f1239; }
.badge-transfer{ background: #e0f2fe; color: #075985; }
.badge-other   { background: #f1f5f9; color: #475569; }
.badge-enabled { background: #d1fae5; color: #065f46; }
.badge-disabled{ background: #f1f5f9; color: #6b7280; }

/* 連結 */
a { color: #3a9a6e; text-decoration: none; }
a:hover { color: #2d7a57; text-decoration: underline; }

/* 按鈕 */
button, .btn {
    background: #3a9a6e; color: white;
    padding: 0.7rem 1.4rem; border: none; border-radius: 6px;
    cursor: pointer; font-size: 14px; font-weight: 400;
    transition: all 0.3s; display: inline-flex; align-items: center; gap: 0.35rem;
    text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { background: #2d7a57; text-decoration: none; }
.btn-secondary { background: #e8edf5; color: #4a6580; }
.btn-secondary:hover { background: #dce3ef; }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: 0.35rem 0.8rem !important; font-size: 13px !important; }
.btn-xs { padding: 0.18rem 0.5rem !important; font-size: 12px !important; }

/* 表單 */
.form-section { max-width: 700px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: #4a6580; }
input[type="text"], input[type="number"], input[type="date"],
select, textarea {
    width: 100%; padding: 0.75rem 0.9rem;
    border: 1px solid #d4dae3; border-radius: 6px; font-size: 0.95rem;
    background: #fff; color: #2c3e50; transition: border 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: #3a9a6e; box-shadow: 0 0 0 3px rgba(58,154,110,0.1);
}
.form-actions { display: flex; gap: 0.8rem; margin-top: 1.5rem; }

/* 搜尋列 */
.search-bar { display: flex; gap: 0.8rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.search-bar input, .search-bar select { flex: 1; min-width: 180px; }

/* 分頁 */
.pagination { display: flex; justify-content: center; gap: 0.5rem; margin-top: 2rem; flex-wrap: wrap; }
.pagination a {
    padding: 0.45rem 0.9rem; border: 1px solid #d4dae3;
    border-radius: 5px; color: #3a9a6e;
}
.pagination a:hover { background: #3a9a6e; color: white; text-decoration: none; }
.pagination a.active { background: #3a9a6e; color: white; border-color: #3a9a6e; }
.pagination span { padding: 0.45rem 0.5rem; color: #999; }

/* 提示訊息 */
.alert { padding: 0.9rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert.success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert.warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* 麵包屑 */
.breadcrumb { margin-bottom: 1rem; color: #888; font-size: 0.9rem; }
.breadcrumb a { color: #3a9a6e; }

/* 空狀態 */
.empty-state { text-align: center; padding: 3rem; color: #999; }

/* 數量顯示 */
.qty-zero { color: #dc2626; font-weight: 700; }
.qty-low  { color: #d97706; font-weight: 600; }
.qty-ok   { color: #065f46; }

/* 入/出庫色彩 */
.tx-in  { color: #1e40af; font-weight: 600; }
.tx-out { color: #9f1239; font-weight: 600; }

/* 響應式 */
@media (max-width: 768px) {
    .container { padding: 0 12px; }
    .main-content { padding: 1.2rem 0; }
    .navbar h1 { font-size: 1.3rem; }
    .navbar ul { flex-wrap: nowrap; overflow-x: auto; gap: 0.3rem; padding-bottom: 0.2rem; }
    .navbar li { flex-shrink: 0; }
    .navbar a { white-space: nowrap; padding: 0.5rem 0.9rem; font-size: 15px; }
    h2 { font-size: 1.4rem; }
    .stats-grid, .two-column { grid-template-columns: 1fr; }
    .card { padding: 1.1rem; }
    table { font-size: 0.85rem; }
    th, td { padding: 0.5rem; }
    .search-bar { flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
}

@media print {
    .navbar, .no-print { display: none !important; }
    body { background: #fff; font-size: 12px; }
}
