/* ========================================
   摩瑪業務內網 - 樣式表
   MOMA Sales Portal Stylesheet
   ======================================== */

/* CSS Variables */
:root {
    /* 品牌色 */
    --primary-cyan: #00d9ff;
    --primary-purple: #533483;
    --primary-red: #e94560;

    /* 深色主題 */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #1e1e2a;
    --bg-hover: #252535;

    /* 文字色 */
    --text-primary: #ffffff;
    --text-secondary: #b4b4c4;
    --text-muted: #6e6e82;

    /* 邊框 */
    --border-color: #2a2a3a;
    --border-light: #353545;

    /* 庫存狀態 */
    --stock-high: #00d26a;
    --stock-medium: #ffc107;
    --stock-low: #ff4757;

    /* 間距 */
    --header-height: 60px;
    --sidebar-width: 240px;

    /* 動畫 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;

    /* 陰影 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================
   Header
   ======================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
}

.logo-text {
    background: linear-gradient(90deg, var(--primary-cyan), var(--text-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    flex: 1;
    max-width: 500px;
    margin: 0 40px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    height: 42px;
    padding: 0 100px 0 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-cyan);
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.15);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-red));
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ========================================
   Main Layout
   ======================================== */
.main-container {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    padding: 8px 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-list {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0, 217, 255, 0.1);
    color: var(--primary-cyan);
    border-left-color: var(--primary-cyan);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-item-count {
    margin-left: auto;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.company-info {
    text-align: center;
}

.company-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.company-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ========================================
   Content Area
   ======================================== */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    min-height: calc(100vh - var(--header-height));
}

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

.category-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.view-options {
    display: flex;
    align-items: center;
    gap: 24px;
}

.price-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.price-select {
    padding: 8px 32px 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236e6e82' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.price-select:focus {
    outline: none;
    border-color: var(--primary-cyan);
}

.result-count {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.result-count span {
    color: var(--primary-cyan);
    font-weight: 600;
}

/* ========================================
   Products Grid
   ======================================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Product Card */
.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition-normal);
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-cyan);
    box-shadow: var(--shadow-md), 0 0 20px rgba(0, 217, 255, 0.1);
}

.product-image {
    aspect-ratio: 4/3;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-image-placeholder {
    font-size: 3rem;
    opacity: 0.3;
}

.product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    background: var(--primary-purple);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.product-info {
    padding: 16px;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-model {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.product-color {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.product-prices {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.price-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.price-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-cyan);
}

.price-value.retail {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 400;
    text-decoration: line-through;
    opacity: 0.5;
}

.product-stock {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.stock-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.stock-indicator.high {
    background: var(--stock-high);
    box-shadow: 0 0 8px var(--stock-high);
}

.stock-indicator.medium {
    background: var(--stock-medium);
    box-shadow: 0 0 8px var(--stock-medium);
}

.stock-indicator.low {
    background: var(--stock-low);
    box-shadow: 0 0 8px var(--stock-low);
}

.stock-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-text {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ========================================
   Modal
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    z-index: 10;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 90vh;
}

/* Modal Detail */
.detail-header {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.detail-image {
    width: 300px;
    aspect-ratio: 4/3;
    background: var(--bg-tertiary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.detail-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.detail-image-placeholder {
    font-size: 4rem;
    opacity: 0.3;
}

.detail-info {
    flex: 1;
}

.detail-category {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-purple);
    border-radius: 4px;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.detail-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.detail-model {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.detail-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.spec-tag {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.detail-stock {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.detail-prices {
    margin-top: 24px;
}

.detail-prices h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.prices-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.price-item {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    text-align: center;
}

.price-item-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.price-item-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-cyan);
}

.price-item.highlight {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.15), rgba(83, 52, 131, 0.15));
    border: 1px solid var(--primary-cyan);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: var(--transition-normal);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
    }

    .header-center {
        margin: 0 16px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0 16px;
    }

    .logo-text {
        display: none;
    }

    .search-shortcut {
        display: none;
    }

    .content {
        padding: 16px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .view-options {
        width: 100%;
        flex-wrap: wrap;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 16px;
    }

    .detail-header {
        flex-direction: column;
    }

    .detail-image {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .prices-table {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card {
    animation: fadeIn 0.3s ease forwards;
}

.product-card:nth-child(1) { animation-delay: 0.02s; }
.product-card:nth-child(2) { animation-delay: 0.04s; }
.product-card:nth-child(3) { animation-delay: 0.06s; }
.product-card:nth-child(4) { animation-delay: 0.08s; }
.product-card:nth-child(5) { animation-delay: 0.10s; }
.product-card:nth-child(6) { animation-delay: 0.12s; }
.product-card:nth-child(7) { animation-delay: 0.14s; }
.product-card:nth-child(8) { animation-delay: 0.16s; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
