/**
 * 倉存管理系統 - 主樣式表
 * 建立日期: 2025-12-07
 * 包含手機版漢堡選單
 */

/* =============================================
   CSS 變數
============================================= */
:root {
    --primary-color: #2c3e50;
    --primary-hover: #34495e;
    --secondary-color: #3498db;
    --secondary-hover: #2980b9;
    --success-color: #27ae60;
    --success-hover: #219a52;
    --warning-color: #f39c12;
    --warning-hover: #d68910;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --info-color: #17a2b8;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #333;
    --text-muted: #6c757d;
    --white: #fff;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --radius: 4px;
    --sidebar-width: 220px;
}

/* =============================================
   重置樣式
============================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: "Microsoft JhengHei", "微軟正黑體", "PingFang TC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
}

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

a:hover {
    color: var(--secondary-hover);
    text-decoration: underline;
}

/* =============================================
   登入頁面
============================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
    font-size: 24px;
}

.login-box .logo {
    text-align: center;
    margin-bottom: 20px;
    font-size: 48px;
    color: var(--secondary-color);
}

/* =============================================
   主佈局
============================================= */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* =============================================
   側邊欄
============================================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-color);
    color: var(--white);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    margin: 0;
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
}

.sidebar-menu li {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-menu a {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    padding-left: 25px;
}

.sidebar-menu a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

/* 關閉按鈕 (手機版) */
.sidebar-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--white);
    font-size: 28px;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
}

.sidebar-close:hover {
    color: var(--danger-color);
}

/* =============================================
   漢堡選單按鈕
============================================= */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 999;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    box-shadow: var(--shadow);
}

.menu-toggle:hover {
    background: var(--primary-hover);
}

/* 漢堡圖標 */
.menu-toggle span {
    display: block;
    width: 22px;
    height: 3px;
    background: var(--white);
    margin: 4px 0;
    border-radius: 2px;
    transition: all 0.3s;
}

/* 遮罩層 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* =============================================
   主內容區
============================================= */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* 頂部欄 */
.top-bar {
    background: var(--white);
    padding: 15px 20px;
    margin: -20px -20px 20px -20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar h1 {
    font-size: 20px;
    color: var(--primary-color);
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: var(--text-muted);
}

/* =============================================
   卡片樣式
============================================= */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

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

.card-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--primary-color);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--light-bg);
}

/* =============================================
   表格樣式
============================================= */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: #f1f3f4;
}

.table .text-right {
    text-align: right;
}

.table .text-center {
    text-align: center;
}

.table .actions {
    white-space: nowrap;
}

.table .btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    margin-right: 3px;
}

/* =============================================
   表單樣式
============================================= */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group label .required {
    color: var(--danger-color);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: var(--light-bg);
    cursor: not-allowed;
}

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

select.form-control {
    cursor: pointer;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.form-inline .form-group {
    margin-bottom: 0;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.form-row .form-group {
    padding: 0 10px;
    flex: 1;
    min-width: 200px;
}

/* =============================================
   按鈕樣式
============================================= */
.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--secondary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--secondary-hover);
    color: var(--white);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-success:hover {
    background: var(--success-hover);
    color: var(--white);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--white);
}

.btn-warning:hover {
    background: var(--warning-hover);
    color: var(--white);
}

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

.btn-danger:hover {
    background: var(--danger-hover);
    color: var(--white);
}

.btn-secondary {
    background: #6c757d;
    color: var(--white);
}

.btn-secondary:hover {
    background: #5a6268;
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background: var(--light-bg);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

.btn-block {
    display: block;
    width: 100%;
}

.btn + .btn {
    margin-left: 5px;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* =============================================
   提示訊息
============================================= */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error,
.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* =============================================
   分頁
============================================= */
.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 20px;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-color);
    text-decoration: none;
}

.pagination a:hover {
    background: var(--light-bg);
}

.pagination .active {
    background: var(--secondary-color);
    color: var(--white);
    border-color: var(--secondary-color);
}

.pagination .disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

/* =============================================
   狀態標籤
============================================= */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
}

.badge-success { background: var(--success-color); color: var(--white); }
.badge-warning { background: var(--warning-color); color: var(--white); }
.badge-danger { background: var(--danger-color); color: var(--white); }
.badge-info { background: var(--info-color); color: var(--white); }
.badge-secondary { background: #6c757d; color: var(--white); }

/* =============================================
   統計卡片 (Dashboard)
============================================= */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card .stat-icon {
    font-size: 36px;
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    word-break: break-all;
}

.stat-card .stat-label {
    color: var(--text-muted);
    margin-top: 5px;
    font-size: 13px;
}

/* =============================================
   Modal 彈出視窗
============================================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

/* =============================================
   手機版響應式設計
============================================= */
@media (max-width: 768px) {
    /* 顯示漢堡選單按鈕 */
    .menu-toggle {
        display: block;
    }

    /* 顯示關閉按鈕 */
    .sidebar-close {
        display: block;
    }

    /* 側邊欄默認隱藏 */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    /* 側邊欄顯示時 */
    .sidebar.show {
        transform: translateX(0);
    }

    /* 主內容區佔滿寬度 */
    .main-content {
        margin-left: 0;
        padding: 15px;
        padding-top: 70px; /* 為漢堡按鈕留空間 */
    }

    /* 頂部欄調整 */
    .top-bar {
        margin: -15px -15px 15px -15px;
        padding: 15px;
        padding-left: 60px; /* 為漢堡按鈕留空間 */
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .top-bar h1 {
        font-size: 18px;
    }

    /* 統計卡片 2x2 */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 15px 10px;
    }

    .stat-card .stat-icon {
        font-size: 28px;
    }

    .stat-card .stat-value {
        font-size: 18px;
    }

    .stat-card .stat-label {
        font-size: 12px;
    }

    /* 按鈕組垂直排列 */
    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
        margin-left: 0;
    }

    /* 表單行 */
    .form-row .form-group {
        flex: 100%;
    }

    /* 表格響應式 */
    .table-responsive {
        margin: 0 -15px;
        padding: 0 15px;
    }
}

/* 更小螢幕 */
@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .login-box {
        padding: 30px 20px;
    }

    .login-box h1 {
        font-size: 20px;
    }
}

/* =============================================
   打印樣式
============================================= */
@media print {
    body {
        background: #fff;
        font-size: 12px;
    }

    .sidebar,
    .top-bar,
    .no-print,
    .btn,
    .menu-toggle,
    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* =============================================
   工具類別
============================================= */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-muted { color: var(--text-muted); }

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

.hidden { display: none; }

/* Loading 動畫 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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