:root {
    --bg-dark: #121418;
    --bg-card: #1b1f26;
    --text-primary: #e0e6ed;
    --text-secondary: #9aa1b0;
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --border-color: #2d333b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 3rem;
}

.brand i {
    font-size: 1.5rem;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-menu a:hover,
.nav-menu a.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.search-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 400px;
}

.search-container i {
    color: var(--text-secondary);
}

.search-container input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    width: 100%;
    font-size: 0.95rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: var(--accent-blue-hover);
}

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

.btn-secondary:hover {
    background-color: #3b424d;
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

.inventory-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.icon-box {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.icon-box.blue {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.icon-box.yellow {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
}

.icon-box.green {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.stat-card .info h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-card .info p {
    font-size: 1.5rem;
    font-weight: 700;
}

.inventory-list {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.section-header h2 {
    font-size: 1.1rem;
}

.table-container {
    flex: 1;
    overflow-y: auto;
}

.inventory-table {
    width: 100%;
    border-collapse: collapse;
}

.inventory-table th,
.inventory-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.inventory-table th {
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
}

.inventory-table tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.inventory-table td {
    font-size: 0.95rem;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    margin-right: 0.75rem;
    transition: color 0.2s;
}

.action-btn:hover {
    color: var(--text-primary);
}

.action-btn.edit:hover {
    color: var(--accent-blue);
}

.action-btn.delete:hover {
    color: var(--accent-red);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 600px;
    max-width: 90%;
    max-height: 85vh;
    /* 限制最大高度 */
    overflow-y: auto;
    /* 允许滚动 */
    position: relative;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.small-modal {
    width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-modal {
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.form-group {
    margin-bottom: 1.25rem;
}

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

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

input,
textarea,
select {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent-blue);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Active state for interactive stat cards */
.stat-card.active {
    border: 2px solid #f59e0b;
    /* Yellow border matching the icon */
    background-color: rgba(245, 158, 11, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* 移动端汉堡菜单按钮 */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.5rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 遮罩层 */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-overlay.active {
    display: block;
}

/* ==================== 平板端优化 (768px - 1024px) ==================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .inventory-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card:last-child {
        grid-column: 1 / -1;
    }
}

/* ==================== 手机端优化 (< 768px) ==================== */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    /* 显示汉堡菜单 */
    .mobile-menu-toggle {
        display: flex;
    }

    /* 侧边栏默认隐藏 */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.mobile-open {
        left: 0;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    /* 主内容区域 */
    .main-content {
        width: 100%;
        padding: 1rem;
        padding-top: 4rem;
        /* 为汉堡菜单留空间 */
    }

    /* 顶部栏 */
    .top-bar {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .search-container {
        width: 100%;
    }

    .actions {
        flex-direction: column;
        width: 100%;
    }

    .actions select,
    .actions button {
        width: 100%;
    }

    /* 统计卡片 */
    .inventory-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* 表格容器 */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .inventory-table {
        min-width: 800px;
        /* 保持最小宽度，允许横向滚动 */
        font-size: 0.875rem;
    }

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

    /* 移动端卡片式布局（可选，用于愿望单和日志） */
    .mobile-card-view {
        display: none;
    }

    @supports (display: grid) {
        .mobile-card-view {
            display: block;
        }

        .desktop-table-view {
            display: none;
        }

        .mobile-card {
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 1rem;
            margin-bottom: 1rem;
        }

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

        .mobile-card-title {
            font-weight: 600;
            font-size: 1.1rem;
        }

        .mobile-card-body {
            display: grid;
            gap: 0.5rem;
        }

        .mobile-card-row {
            display: flex;
            justify-content: space-between;
            padding: 0.25rem 0;
        }

        .mobile-card-label {
            color: var(--text-secondary);
            font-size: 0.875rem;
        }

        .mobile-card-value {
            font-weight: 500;
        }

        .mobile-card-actions {
            display: flex;
            gap: 0.5rem;
            margin-top: 1rem;
            padding-top: 1rem;
            border-top: 1px solid var(--border-color);
        }

        .mobile-card-actions button {
            flex: 1;
        }
    }

    /* 表单优化 */
    .form-row {
        flex-direction: column;
    }

    .form-group {
        width: 100% !important;
    }

    /* 按钮优化 - 增大触摸区域 */
    .btn {
        padding: 0.875rem 1.5rem;
        min-height: 44px;
        font-size: 1rem;
    }

    .action-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.75rem;
    }

    /* 输入框优化 */
    input[type="text"],
    input[type="number"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px;
        /* 防止iOS自动缩放 */
        min-height: 44px;
        padding: 0.75rem;
    }

    /* 导航菜单 */
    .nav-menu a {
        padding: 1rem;
        font-size: 1rem;
    }

    /* 用户信息 */
    .user-profile {
        padding: 1rem 0;
    }

    /* 品牌logo */
    .brand {
        margin-bottom: 2rem;
        font-size: 1.1rem;
    }
}

/* ==================== 小屏手机优化 (< 375px) ==================== */
@media (max-width: 375px) {
    .main-content {
        padding: 0.75rem;
        padding-top: 3.5rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .modal-content {
        width: 98%;
        margin: 0.5rem auto;
    }

    .btn {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }
}

/* ==================== 横屏优化 ==================== */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        padding-top: 3rem;
    }

    .modal-content {
        max-height: 85vh;
    }
}

/* ==================== 触摸设备优化 ==================== */
@media (hover: none) and (pointer: coarse) {

    /* 移除hover效果，使用active状态 */
    .btn:hover {
        transform: none;
    }

    .btn:active {
        transform: scale(0.98);
    }

    .action-btn:hover {
        transform: none;
    }

    .action-btn:active {
        opacity: 0.7;
    }

    /* 增大可点击区域 */
    .nav-menu a {
        min-height: 48px;
    }
}