/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
    background: #f5f6fa;
    color: #2c3e50;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 颜色变量与排版 ==================== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --border-color: #e2e8f0;
    --bg-light: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ==================== 登录页面 ==================== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.login-header p {
    font-size: 14px;
    opacity: 0.85;
    font-weight: 500;
}

.login-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.login-tab {
    flex: 1;
    padding: 16px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    position: relative;
}

.login-tab:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.login-tab.active {
    color: var(--primary-color);
}

.login-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
}

.login-form {
    padding: 32px;
    display: none;
}

.login-form.active {
    display: block;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: white;
}

.btn-full {
    width: 100%;
    padding: 11px 16px;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 600;
}

/* ==================== 按钮样式 ==================== */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
    user-select: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-small {
    padding: 8px 12px;
    font-size: 12px;
}

/* ==================== 文字链接样式 ==================== */
.text-link {
    display: inline-block;
    padding: 6px 10px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s ease;
    position: relative;
}

.text-link::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 10px;
    right: 10px;
    height: 1px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.text-link:hover {
    background: rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
}

.text-link:hover::after {
    opacity: 1;
}

.text-link-primary {
    color: var(--primary-color);
}

.text-link-cancel {
    color: var(--text-secondary);
}

.text-link-cancel:hover {
    background: rgba(100, 116, 139, 0.08);
}

/* ==================== 操作链接 ==================== */
.action-links {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.action-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 400;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 5px;
    transition: all 0.2s ease;
    position: relative;
}

.action-link::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 5px;
    background: rgba(37, 99, 235, 0.08);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: -1;
}

.action-link:hover {
    color: var(--primary-hover);
    transform: translateY(-1px);
}

.action-link:hover::before {
    opacity: 1;
}

.action-link.action-delete {
    color: var(--danger-color);
}

.action-link.action-delete:hover {
    color: #dc2626;
}

.action-link.action-delete:hover::before {
    background: rgba(239, 68, 68, 0.08);
}

/* ==================== 主容器 ==================== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

/* ==================== 头部 ==================== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

/* ==================== 统计卡片 ==================== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card span {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
}

/* ==================== 搜索和筛选 ==================== */
.search-filter {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.search-input,
.filter-select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: all 0.2s ease;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-select {
    min-width: 140px;
}

/* ==================== 产品列表 ==================== */
.product-list {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

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

thead {
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
    line-height: 1.6;
    font-weight: 400;
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: var(--bg-light);
}

tbody tr:last-child td {
    border-bottom: none;
}

  /* ==================== 库存状态指示器 ==================== */
  .stock-low {
      color: var(--danger-color);
  }
  
  .stock-medium {
      color: var(--warning-color);
  }
  
  .stock-high {
      color: var(--success-color);
  }

/* ==================== 通知区域 ==================== */
.notifications {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    padding: 24px;
    border: 1px solid var(--border-color);
}

.notifications h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.notification-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: -16px;
}

.notification-table thead {
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

.notification-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.notification-list {
    max-height: 300px;
    overflow-y: auto;
    display: table-row-group;
}

.notification-item {
    display: table-row;
    transition: all 0.2s ease;
}

.notification-item:hover {
    background: var(--bg-light);
}

.notification-item td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    vertical-align: middle;
    font-weight: 400;
}

.notification-item:last-child td {
    border-bottom: none;
}

.notification-product-name {
    color: var(--text-primary);
}

.notification-category {
    color: var(--text-secondary);
    font-size: 12px;
}

.notification-change {
}

.notification-change.stock-in {
    color: var(--success-color);
}

.notification-change.stock-out {
    color: var(--danger-color);
}

.notification-quantity {
    text-align: center;
    min-width: 60px;
}

.notification-quantity.positive {
    color: var(--success-color);
}

.notification-quantity.negative {
    color: var(--danger-color);
}

.notification-operator {
    color: var(--primary-color);
    font-size: 12px;
}

.notification-time {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-small {
    max-width: 420px;
}

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

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
}

.close {
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all 0.2s ease;
}

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

#productForm,
#stockForm {
    padding: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* ==================== 加载动画 ==================== */
.loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1001;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    border: 3px solid var(--bg-light);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

.loading p {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

 /* ==================== 消息样式（Toast浮层） ==================== */
 .toast-container {
     position: fixed;
     top: 20px;
     right: 20px;
     z-index: 10000;
     pointer-events: none;
 }
 
 .toast {
     background: white;
     border-radius: 8px;
     padding: 16px 20px;
     margin-bottom: 12px;
     font-size: 14px;
     font-weight: 500;
     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
     animation: toastSlideIn 0.3s ease;
     pointer-events: auto;
     display: flex;
     align-items: center;
     gap: 12px;
     max-width: 400px;
     min-width: 280px;
 }
 
 .toast.success {
     border-left: 4px solid var(--success-color);
 }
 
 .toast.success::before {
     content: '✓';
     color: var(--success-color);
     font-size: 18px;
     font-weight: 700;
     flex-shrink: 0;
 }
 
 .toast.success .toast-message {
     color: #047857;
 }
 
 .toast.error {
     border-left: 4px solid var(--danger-color);
 }
 
 .toast.error::before {
     content: '✕';
     color: var(--danger-color);
     font-size: 18px;
     font-weight: 700;
     flex-shrink: 0;
 }
 
 .toast.error .toast-message {
     color: #991b1b;
 }
 
 .toast.info {
     border-left: 4px solid var(--info-color);
 }
 
 .toast.info::before {
     content: 'ℹ';
     color: var(--info-color);
     font-size: 18px;
     font-weight: 700;
     flex-shrink: 0;
 }
 
 .toast.info .toast-message {
     color: var(--info-color);
 }
 
 .toast-message {
     flex: 1;
 }
 
 .toast-close {
     background: none;
     border: none;
     color: #999;
     cursor: pointer;
     font-size: 18px;
     padding: 0;
     width: 24px;
     height: 24px;
     display: flex;
     align-items: center;
     justify-content: center;
     border-radius: 4px;
     transition: all 0.2s ease;
     flex-shrink: 0;
 }
 
 .toast-close:hover {
     background: rgba(0, 0, 0, 0.05);
     color: #333;
 }
 
 @keyframes toastSlideIn {
     from {
         transform: translateX(400px);
         opacity: 0;
     }
     to {
         transform: translateX(0);
         opacity: 1;
     }
 }
 
 @keyframes toastSlideOut {
     from {
         transform: translateX(0);
         opacity: 1;
     }
     to {
         transform: translateX(400px);
         opacity: 0;
     }
 }
 
 .toast.removing {
     animation: toastSlideOut 0.3s ease;
 }

/* ==================== 库存操作相关样式 ==================== */
.stock-product-name {
    color: var(--text-primary);
    padding: 8px 0;
    font-size: 15px;
}

.stock-current {
    font-size: 20px;
    color: var(--primary-color);
    padding: 8px 0;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    header h1 {
        font-size: 22px;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .user-info {
        width: 100%;
        justify-content: center;
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border-color);
        padding-top: 16px;
        margin-top: 16px;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .search-filter {
        flex-direction: column;
    }

    .search-input {
        min-width: unset;
    }

    .filter-select {
        width: 100%;
        min-width: unset;
    }

    .action-links {
        gap: 8px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    th,
    td {
        padding: 12px 8px;
        font-size: 12px;
    }

    .action-links {
        flex-direction: column;
        gap: 8px;
    }

    .action-link {
        display: block;
        padding: 8px 12px;
    }
}

/* ==================== 分类管理样式 ==================== */
#categoriesList {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#categoriesList > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

#categoriesList > div:last-child {
    border-bottom: none;
}

#categoriesList > div:hover {
    background-color: transparent;
}

#categoriesList > div span {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 400;
    flex: 1;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background-color: var(--secondary-color);
    color: white;
    font-weight: 500;
    margin-left: 8px;
}

.btn-small:hover {
    opacity: 0.85;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-small:active {
    transform: translateY(0);
}

/* ==================== 滚动条美化 ==================== */
.notification-list::-webkit-scrollbar {
    width: 6px;
}

.notification-list::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 10px;
}

.notification-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.notification-list::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
