/* ===== 貨架區域 ===== */
.shelf-section {
    background: white;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    flex: 1;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
}

.section-controls {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    background: #f3f4f6;
    border-radius: 12px;
    padding: 6px;
}

.toggle-btn {
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.toggle-btn.active {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: #1f2937;
}

.add-shelf-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-shelf-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.shelf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--card-gap-desktop);
    max-height: 600px;
    overflow-y: auto;
}

/* ===== 貨架管理工具列 ===== */
.management-toolbar {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.filter-select {
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: #3b82f6;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    border-color: #3b82f6;
    background: #f8faff;
    color: #3b82f6;
}

.toolbar-btn.export {
    border-color: #10b981;
    color: #10b981;
}

.toolbar-btn.export:hover {
    background: #f0fdf4;
}

/* ===== 貨架管理網格 ===== */
.management-section {
    background: white;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.shelf-management-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--card-gap-desktop);
}

/* ===== 貨架卡片 - 支援拖拉編輯 ===== */
.shelf-card {
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.shelf-card:hover {
    border-color: #4ade80;
    background: white;
    box-shadow: 0 8px 20px rgba(74, 222, 128, 0.15);
    transform: translateY(-4px);
}

.shelf-card.edit-mode {
    border-color: #3b82f6;
    background: #eff6ff;
}

.shelf-card.draft {
    border-color: #f59e0b;
    background: #fffbeb;
}

.shelf-card.published {
    border-color: #10b981;
    background: #f0fdf4;
}

.shelf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.shelf-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.shelf-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.shelf-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.shelf-status.active {
    background: #dcfce7;
    color: #166534;
}

.shelf-status.maintenance {
    background: #fef3c7;
    color: #92400e;
}

.shelf-status.draft {
    background: #fef3c7;
    color: #92400e;
}

.shelf-status.published {
    background: #dcfce7;
    color: #166534;
}

.edit-btn, .publish-btn, .delete-btn {
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.edit-btn {
    background: #3b82f6;
    color: white;
}

.edit-btn:hover {
    background: #2563eb;
}

.edit-btn.editing {
    background: #10b981;
}

.publish-btn {
    background: #10b981;
    color: white;
}

.publish-btn:hover {
    background: #059669;
}

.publish-btn.published {
    background: #6b7280;
}

.delete-btn {
    background: #ef4444;
    color: white;
}

.delete-btn:hover {
    background: #dc2626;
}

/* ===== 貨架視覺化 - 支援拖拉 ===== */
.shelf-visual {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
    position: relative;
}

.shelf-visual.edit-mode {
    border-color: #3b82f6;
    background: #f8faff;
}

.shelf-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shelf-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.row-label {
    width: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-align: center;
}

/* ===== 商品位置 - 拖拉功能 ===== */
.product-slot {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 2px solid #d1d5db;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.product-slot:hover {
    transform: scale(1.1);
}

.product-slot.filled {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    border-color: #22c55e;
    box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
}

.product-slot.empty {
    background: #f9fafb;
    border-style: dashed;
}

.product-slot.empty:hover {
    background: #e5f3ff;
    border-color: #3b82f6;
}

.product-slot.bestseller {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #d97706;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.product-slot.bestseller::after {
    content: '★';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.product-slot.low-stock {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: #dc2626;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.product-slot.low-stock::after {
    content: '!';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

/* 拖拉中的樣式 */
.product-slot.dragging {
    opacity: 0.5;
    transform: rotate(5deg) scale(1.1);
}

.product-slot.drop-target {
    border-color: #3b82f6;
    background: #dbeafe;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.shelf-stats {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    color: #6b7280;
    font-weight: 500;
}

/* ===== 商品庫存面板 ===== */
.product-panel {
    position: fixed;
    top: var(--header-height-desktop);
    right: -400px;
    width: 400px;
    height: calc(100vh - var(--header-height-desktop));
    background: white;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    z-index: 200;
    transition: right 0.3s ease;
    padding: 24px;
    overflow-y: auto;
}

.product-panel.open {
    right: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.panel-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-item {
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s;
}

.product-item:hover {
    border-color: #3b82f6;
    background: #f8faff;
}

.product-item:active {
    cursor: grabbing;
}

.product-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.product-id {
    font-size: 12px;
    color: #6b7280;
}

/* ===== 新增貨架模態框 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 20px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.modal-overlay.show .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.shelf-size-preview {
    background: #f8faff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
}

.preview-title {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 12px;
}

.preview-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.preview-row {
    display: flex;
    gap: 6px;
}

.preview-slot {
    width: 20px;
    height: 20px;
    background: #e5e7eb;
    border-radius: 4px;
    border: 1px solid #d1d5db;
}

.modal-footer {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.btn-secondary, .btn-primary {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ===== 發佈確認對話框 ===== */
.confirm-dialog {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.confirm-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    color: white;
}

.confirm-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.confirm-message {
    color: #6b7280;
    margin-bottom: 24px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ===== 庫存表格樣式 ===== */
.inventory-table, .users-table {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-header {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr 1fr 1fr 1.5fr;
    background: #f8fafc;
    padding: 16px;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.table-row {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr 1fr 1fr 1.5fr;
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.2s;
}

.table-row:hover {
    background: #f8fafc;
}

.table-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.sufficient {
    background: #dcfce7;
    color: #166534;
}

.status-badge.low {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.critical {
    background: #fef2f2;
    color: #991b1b;
}

.status-badge.active {
    background: #dcfce7;
    color: #166534;
}

.status-badge.inactive {
    background: #f3f4f6;
    color: #6b7280;
}

.status-badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.action-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.action-btn.urgent {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.action-btn.urgent:hover {
    background: #fbbf24;
    color: white;
}

/* ===== 明星商品排行榜樣式 ===== */
.bestseller-ranking {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.ranking-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ranking-item.rank-1 {
    border-left: 4px solid #fbbf24;
}

.ranking-item.rank-2 {
    border-left: 4px solid #9ca3af;
}

.ranking-item.rank-3 {
    border-left: 4px solid #cd7c2f;
}

.rank-badge {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}

.product-info {
    flex: 1;
}

.product-name {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 4px;
}

.product-details {
    font-size: 14px;
    color: #6b7280;
}

.sales-amount {
    font-size: 20px;
    font-weight: 700;
    color: #10b981;
}

.trend {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.trend.up {
    background: #dcfce7;
    color: #166534;
}

.trend.down {
    background: #fef2f2;
    color: #991b1b;
}

/* ===== 圖表佔位符樣式 ===== */
.chart-placeholder {
    height: 300px;
    background: #f8fafc;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #d1d5db;
}

.chart-placeholder.large {
    height: 400px;
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.chart-description {
    font-size: 14px;
    color: #6b7280;
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.trend-chart {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #d1d5db;
}

/* ===== 策略建議樣式 ===== */
.strategy-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.strategy-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    border-left: 4px solid #3b82f6;
}

.strategy-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.strategy-content {
    flex: 1;
}

.strategy-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.strategy-desc {
    font-size: 14px;
    color: #6b7280;
}

/* ===== 銷售排行樣式 ===== */
.sales-ranking {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rank-number {
    width: 24px;
    height: 24px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.item-info {
    flex: 1;
}

.item-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.item-amount {
    font-size: 12px;
    color: #6b7280;
}

.item-percentage {
    font-size: 14px;
    font-weight: 600;
    color: #10b981;
}

/* ===== 銷售亮點樣式 ===== */
.highlight-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.highlight-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    border-left: 4px solid;
}

.highlight-item.success {
    background: #f0fdf4;
    border-left-color: #10b981;
}

.highlight-item.info {
    background: #eff6ff;
    border-left-color: #3b82f6;
}

.highlight-item.warning {
    background: #fffbeb;
    border-left-color: #f59e0b;
}

.highlight-icon {
    font-size: 20px;
}

.highlight-text {
    font-size: 14px;
    color: #374151;
}

/* ===== 進度條樣式 ===== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ===== 標籤樣式 ===== */
.tag {
    display: inline-block;
    padding: 4px 8px;
    background: #f3f4f6;
    color: #374151;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.tag.primary {
    background: #dbeafe;
    color: #1e40af;
}

.tag.success {
    background: #dcfce7;
    color: #166534;
}

.tag.warning {
    background: #fef3c7;
    color: #92400e;
}

.tag.danger {
    background: #fef2f2;
    color: #991b1b;
}

/* ===== 載入動畫 ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== 空狀態樣式 ===== */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.empty-state-description {
    font-size: 14px;
    margin-bottom: 20px;
}

/* ===== 工具提示樣式 ===== */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #374151;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}