/* 全域樣式 */
:root {
    /* 前台溫馨色系 */
    --primary-color: #d4a574;
    --primary-dark: #b8895f;
    --secondary-color: #8b6f47;
    --accent-gold: #d4a574;

    /* 後台科技色系 */
    --admin-primary: #2563eb;
    --admin-secondary: #1e40af;
    --admin-accent: #60a5fa;
    --admin-dark: #1e293b;
    --admin-darker: #0f172a;

    /* 通用色系 */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;

    /* 中性色 */
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --text-dark: #1e293b;
    --text-gray: #64748b;
    --border-color: #e2e8f0;
}

body {
    font-family: 'Noto Sans TC', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* 導航列 */
.navbar-brand {
    font-size: 1.5rem;
}

/* 後台側邊欄 - 現代科技風格 */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--admin-darker) 0%, var(--admin-dark) 100%) !important;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

/* Sidebar Header - 固定不滾動 */
.sidebar-header {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sidebar Body - 可滾動區域 */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 1rem;
}

/* Sidebar Footer - 固定不滾動 */
.sidebar-footer {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 主要內容區域 - 為了避免被 sidebar 遮擋 */
.main-content {
    margin-left: 220px;
    width: calc(100% - 220px);
    background-color: var(--bg-light);
}

.sidebar .nav-link {
    border-radius: 0.75rem;
    transition: all 0.3s ease;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--admin-accent);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.sidebar .nav-link:hover {
    background-color: rgba(96, 165, 250, 0.1);
    transform: translateX(4px);
}

.sidebar .nav-link:hover::before {
    transform: scaleY(1);
}

.sidebar .nav-link.active {
    background: linear-gradient(90deg, var(--admin-primary) 0%, var(--admin-accent) 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar .nav-link.active::before {
    transform: scaleY(1);
}

.sidebar .nav-link i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

/* 卡片樣式 - 現代簡約 */
.card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    background: var(--bg-white);
}

.card:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-header {
    border-radius: 1rem 1rem 0 0 !important;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-white) !important;
    padding: 1.25rem 1.5rem;
}

/* 商品卡片 */
.product-card {
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 1rem;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.product-card img {
    transition: transform 0.3s ease;
}

.product-card:hover img {
    transform: scale(1.05);
}

/* 首頁橫幅 - 溫馨烘焙色系 */
.hero-section {
    background: linear-gradient(135deg, #fef3e2 0%, #f9e8d0 50%, #f4dcc0 100%);
}

/* 按鈕樣式 - 前台溫馨風格 */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-color) 100%);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.4);
    transform: translateY(-2px);
}

/* 後台按鈕 - 科技藍 */
.admin-page .btn-primary,
.sidebar ~ .main-content .btn-primary {
    background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-secondary) 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.admin-page .btn-primary:hover,
.sidebar ~ .main-content .btn-primary:hover {
    background: linear-gradient(135deg, var(--admin-secondary) 0%, var(--admin-primary) 100%);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
    transform: translateY(-2px);
}

/* 統計卡片 - 玻璃擬態效果 */
.stat-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.25rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

/* 表格樣式 - 現代簡約 */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
    padding: 1rem;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table-hover tbody tr:hover {
    background-color: rgba(37, 99, 235, 0.05);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table tbody td {
    vertical-align: middle;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* 徽章樣式 */
.badge {
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.025em;
}

.bg-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%) !important;
}

.bg-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%) !important;
}

.bg-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%) !important;
}

.bg-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #2563eb 100%) !important;
}

/* 物件適配 */
.object-fit-cover {
    object-fit: cover;
}

/* 響應式調整 */

/* 平板尺寸 (768px - 991px) */
@media (max-width: 991px) {
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar {
        position: fixed;
        left: -220px;
        z-index: 1050;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    /* Modal 調整為較小尺寸 */
    .modal-xl {
        max-width: 90% !important;
    }

    .modal-lg {
        max-width: 90% !important;
    }

    /* 卡片內邊距調整 */
    .card-body {
        padding: 1rem;
    }

    /* 按鈕組自動換行 */
    .btn-group {
        flex-wrap: wrap;
    }

    /* 表格字體調整 */
    .table {
        font-size: 0.9rem;
    }
}

/* 手機尺寸 (< 768px) */
@media (max-width: 768px) {
    /* 側邊欄完全隱藏 */
    .sidebar {
        position: fixed;
        left: -220px;
        width: 220px;
        z-index: 1050;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Modal 全螢幕 */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem) !important;
    }

    .modal-fullscreen {
        margin: 0 !important;
        max-width: 100% !important;
    }

    /* 表格響應式 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 0.85rem;
        min-width: 600px; /* 確保表格不會太擠 */
    }

    .table td, .table th {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }

    /* 統計卡片堆疊顯示 */
    .stat-card {
        margin-bottom: 1rem;
    }

    /* 按鈕組調整 */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        border-radius: 0.375rem !important;
        margin-bottom: 0.25rem;
    }

    /* 導航欄調整 */
    .navbar .container-fluid {
        flex-direction: column;
        gap: 10px;
        align-items: stretch !important;
    }

    .navbar .btn {
        width: 100%;
    }

    /* 卡片內邊距 */
    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }

    /* 圖片預覽調整 */
    .image-preview {
        max-width: 100px;
        max-height: 100px;
    }

    /* 商品網格調整 */
    .product-card {
        margin-bottom: 1rem;
    }

    /* 表單欄位調整 */
    .form-label {
        font-size: 0.9rem;
    }

    .form-control, .form-select {
        font-size: 0.9rem;
    }

    /* 徽章字體調整 */
    .badge {
        font-size: 0.7rem;
        padding: 0.35rem 0.65rem;
    }

    /* 隱藏部分欄位文字，只顯示圖標 */
    .btn .bi ~ span {
        display: none;
    }

    /* Modal 內的兩欄布局改為單欄 */
    .modal-body .row > [class*='col-'] {
        width: 100%;
        max-width: 100%;
    }
}

/* 小手機尺寸 (< 576px) */
@media (max-width: 576px) {
    /* 更小的字體 */
    body {
        font-size: 14px;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.35rem; }
    h3 { font-size: 1.2rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }

    /* 按鈕尺寸調整 */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Modal 完全全螢幕 */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        height: 100%;
    }

    .modal-content {
        height: 100%;
        border-radius: 0;
    }

    /* 表格更緊湊 */
    .table {
        font-size: 0.75rem;
    }

    .table td, .table th {
        padding: 0.4rem 0.2rem;
    }

    /* 卡片內邊距 */
    .card-body {
        padding: 0.5rem;
    }

    /* 統計卡片字體調整 */
    .stat-card h3 {
        font-size: 1.5rem;
    }

    .stat-card p {
        font-size: 0.8rem;
    }

    /* 商品網格單欄顯示 */
    .col-md-4, .col-md-6, .col-lg-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* 圖片預覽更小 */
    .image-preview {
        max-width: 80px;
        max-height: 80px;
    }
}

/* 橫向手機 (landscape) */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 200px;
    }

    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* 列印樣式 */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .modal-header button,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

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

    .table {
        font-size: 10pt;
    }
}

/* 自訂卡片陰影 */
.card {
    border: none;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* Sticky 元素 */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* 載入動畫 */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

/* 自訂滾動條 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 內部備註深黃色 */
.text-internal-note {
    color: #d97706 !important;
}

.text-internal-note a {
    color: #d97706 !important;
}

.text-internal-note a:hover {
    color: #b45309 !important;
}

/* 圖片預覽樣式 */
.image-preview {
    max-width: 150px;
    max-height: 150px;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.image-preview:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* POS 系統商品網格 RWD */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }
}

@media (max-width: 576px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }
}

/* 訂單商品列表 RWD */
.order-items-list {
    max-height: 400px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .order-items-list {
        max-height: 300px;
    }
}

/* 浮動購物車按鈕 RWD */
.floating-cart-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1030;
}

@media (max-width: 768px) {
    .floating-cart-btn {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 576px) {
    .floating-cart-btn {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
    }
}

/* 購物車側邊欄 RWD */
.cart-sidebar {
    width: 450px;
}

@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%;
        right: -100%;
    }

    .cart-sidebar.active {
        right: 0;
    }
}

/* 統計卡片 RWD */
.stat-card {
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

@media (max-width: 768px) {
    .stat-card:hover {
        transform: none;
    }
}

/* 搜尋欄 RWD */
.search-bar {
    max-width: 400px;
}

@media (max-width: 768px) {
    .search-bar {
        max-width: 100%;
    }
}

/* 操作按鈕群組 RWD */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 576px) {
    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }
}

/* 資料卡片圖片 RWD */
.card img {
    max-width: 100%;
    height: auto;
}

/* 表單多選框 RWD */
select[multiple] {
    min-height: 120px;
}

@media (max-width: 768px) {
    select[multiple] {
        min-height: 100px;
    }
}

/* 分頁導航 RWD */
.pagination {
    flex-wrap: wrap;
    gap: 0.25rem;
}

@media (max-width: 576px) {
    .pagination .page-item {
        font-size: 0.85rem;
    }

    .pagination .page-link {
        padding: 0.375rem 0.625rem;
    }
}

/* QR Code 顯示 RWD */
#qrcodeDisplay canvas,
#qrcodeDisplay img {
    max-width: 100%;
    height: auto;
}

/* 訂單詳情表格 RWD */
.order-detail-table {
    width: 100%;
}

@media (max-width: 576px) {
    .order-detail-table th,
    .order-detail-table td {
        display: block;
        width: 100%;
    }

    .order-detail-table th {
        background-color: #f8f9fa;
        font-weight: bold;
    }

    .order-detail-table tr {
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        display: block;
    }
}

/* 載入動畫置中 RWD */
.loading-container {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

@media (min-width: 992px) {
    .sidebar-overlay {
        display: none !important;
    }
}

/* 側邊欄切換按鈕 - 白色背景黑箭頭設計 */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 50%;
    left: -50px; /* 初始隱藏在側邊欄左側 */
    transform: translateY(-50%);
    z-index: 1100;
    background: white;
    border: 1px solid #e0e0e0;
    border-left: none;
    border-radius: 0 8px 8px 0;
    width: 28px;
    height: 90px;
    cursor: pointer;
    box-shadow: 1px 0 8px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.hamburger-btn:hover {
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-50%) translateX(2px);
}

.hamburger-btn:active {
    transform: translateY(-50%) translateX(0);
}

/* 箭頭圖標 */
.hamburger-icon {
    position: relative;
    width: 14px;
    height: 14px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hamburger-icon::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-top: 2px solid #555;
    border-right: 2px solid #555;
    top: 50%;
    left: 50%;
    transform: translate(-30%, -50%) rotate(45deg);
    transition: all 0.3s ease;
}

/* 側邊欄關閉時：按鈕顯示在左邊緣 */
@media (max-width: 991px) {
    .hamburger-btn {
        display: flex;
        left: 0; /* 貼在左邊緣 */
    }
}

/* 側邊欄打開時：按鈕跟著滑到側邊欄右側 */
.hamburger-btn.sidebar-open {
    left: 220px; /* 移動到側邊欄右側 */
}

/* 側邊欄打開時：箭頭旋轉180度，指向左邊 */
.hamburger-btn.sidebar-open .hamburger-icon {
    transform: rotate(180deg);
}

/* 側邊欄過渡動畫 */
.sidebar {
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 按鈕跟隨側邊欄一起移動的動畫 */
@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        left: -220px;
        top: 0;
        height: 100vh;
        z-index: 1050;
        overflow-y: auto;
    }

    .sidebar.show {
        left: 0;
    }
}

/* Hover 效果優化 */
.hamburger-btn:hover .hamburger-icon::before {
    border-color: #000;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .hamburger-btn {
        width: 26px;
        height: 80px;
    }

    .hamburger-icon {
        width: 12px;
        height: 12px;
    }

    .hamburger-icon::before {
        width: 7px;
        height: 7px;
        border-width: 1.8px;
    }

    .hamburger-btn.sidebar-open {
        left: 220px;
    }
}

@media (max-width: 576px) {
    .hamburger-btn {
        width: 24px;
        height: 70px;
    }

    .hamburger-icon {
        width: 11px;
        height: 11px;
    }

    .hamburger-icon::before {
        width: 6px;
        height: 6px;
        border-width: 1.5px;
    }

    /* 小螢幕時，側邊欄打開，按鈕仍然跟著 */
    .hamburger-btn.sidebar-open {
        left: 220px;
    }
}

/* 脈衝動畫提示（可選） */
@keyframes pulse {
    0%, 100% {
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.2);
    }
}

.hamburger-btn.pulse {
    animation: pulse 2s infinite;
}

/* 訂單詳情 Modal 加寬 */
#orderDetailModal .modal-xl {
    max-width: 95%;
}

@media (min-width: 1400px) {
    #orderDetailModal .modal-xl {
        max-width: 1400px;
    }
}
