/**
 * 两山·茶管家 - 通用组件库
 * 提供可复用的UI组件样式
 */

/* ==================== 按钮组件 ==================== */

/* 主按钮 - 绿色渐变 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #2E7D32 0%, #388E3C 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.25);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(46, 125, 50, 0.4);
    transform: translateY(-2px);
}

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

/* 次要按钮 - 白底绿边 */
.btn-secondary {
    background: white;
    color: #2E7D32;
    border: 2px solid #2E7D32;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-secondary:hover {
    background: #2E7D32;
    color: white;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
    transform: translateY(-2px);
}

/* 幽灵按钮 - 透明底 */
.btn-ghost {
    background: transparent;
    color: #2E7D32;
    border: 2px solid rgba(46, 125, 50, 0.3);
}

.btn-ghost:hover {
    border-color: #2E7D32;
    background: rgba(46, 125, 50, 0.05);
}

/* 文字按钮 */
.btn-text {
    background: transparent;
    color: #2E7D32;
    padding: 8px 16px;
}

.btn-text:hover {
    background: rgba(46, 125, 50, 0.08);
}

/* 按钮尺寸 */
.btn-sm {
    padding: 8px 20px;
    font-size: 13px;
}

.btn-lg {
    padding: 16px 40px;
    font-size: 17px;
}

.btn-xl {
    padding: 20px 48px;
    font-size: 18px;
}

/* 按钮形状 */
.btn-rounded {
    border-radius: 50px;
}

.btn-square {
    border-radius: 4px;
}

/* 按钮状态 */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== 卡片组件 ==================== */

.card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.04),
        0 8px 16px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.card-hover:hover {
    box-shadow:
        0 8px 16px rgba(0, 0, 0, 0.08),
        0 16px 32px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

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

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    margin-bottom: 20px;
}

.card-footer {
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

/* ==================== 输入框组件 ==================== */

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

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

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E0E0E0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: #2E7D32;
    box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.1);
}

.form-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.form-input.error {
    border-color: #f44336;
}

.form-error {
    margin-top: 6px;
    font-size: 13px;
    color: #f44336;
}

.form-help {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== 标签徽章组件 ==================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    color: #2E7D32;
}

.badge-success {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-warning {
    background: #FFF3E0;
    color: #F57C00;
}

.badge-danger {
    background: #FFEBEE;
    color: #E53935;
}

.badge-info {
    background: #E3F2FD;
    color: #1976D2;
}

.badge-pill {
    border-radius: 20px;
    padding: 6px 16px;
}

/* ==================== 提示框组件 ==================== */

.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-success {
    background: #E8F5E9;
    color: #2E7D32;
    border-left: 4px solid #2E7D32;
}

.alert-warning {
    background: #FFF3E0;
    color: #F57C00;
    border-left: 4px solid #F57C00;
}

.alert-danger {
    background: #FFEBEE;
    color: #E53935;
    border-left: 4px solid #E53935;
}

.alert-info {
    background: #E3F2FD;
    color: #1976D2;
    border-left: 4px solid #1976D2;
}

/* ==================== 标签页组件 ==================== */

.tabs {
    display: flex;
    gap: 32px;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 24px;
}

.tab {
    padding: 12px 0;
    font-size: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    border: none;
    background: transparent;
}

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

.tab.active {
    color: var(--primary-color);
    font-weight: 600;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

/* ==================== 分页组件 ==================== */

.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-top: 32px;
}

.page-item {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.page-item:hover {
    border-color: #2E7D32;
    color: #2E7D32;
}

.page-item.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}

.page-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==================== 加载指示器 ==================== */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(46, 125, 50, 0.1);
    border-top-color: #2E7D32;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

/* ==================== 模态框组件 ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #f5f5f5;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ==================== 表格组件 ==================== */

.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #f0f0f0;
}

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

.table th {
    background: #fafafa;
    padding: 16px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid #f0f0f0;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: var(--text-secondary);
}

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

.table tr:hover {
    background: #fafafa;
}

/* ==================== 下拉菜单组件 ==================== */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-width: 180px;
    z-index: 100;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.3s ease;
}

.dropdown:hover .dropdown-menu,
.dropdown-menu.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.dropdown-item {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-item:hover {
    background: #f5f5f5;
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    background: #f0f0f0;
    margin: 4px 0;
}

/* ==================== 工具提示 ==================== */

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.85);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
}

/* ==================== 响应式网格 ==================== */

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -12px;
}

.col {
    flex: 1;
    padding: 0 12px;
}

.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 0 12px;
}

.col-4 {
    flex: 0 0 33.333%;
    max-width: 33.333%;
    padding: 0 12px;
}

.col-3 {
    flex: 0 0 25%;
    max-width: 25%;
    padding: 0 12px;
}

@media (max-width: 768px) {
    .col-6, .col-4, .col-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ==================== 间距工具类 ==================== */

.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mt-xl { margin-top: 32px; }

.mb-sm { margin-bottom: 12px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.mb-xl { margin-bottom: 32px; }

.pt-sm { padding-top: 12px; }
.pt-md { padding-top: 16px; }
.pt-lg { padding-top: 24px; }
.pt-xl { padding-top: 32px; }

.pb-sm { padding-bottom: 12px; }
.pb-md { padding-bottom: 16px; }
.pb-lg { padding-bottom: 24px; }
.pb-xl { padding-bottom: 32px; }

/* ==================== 文本工具类 ==================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: #2E7D32; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-disabled); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-normal { font-weight: 400; }

/* ==================== ✅ 移动端导航菜单 ==================== */

/* 汉堡菜单按钮 - 默认隐藏 */
.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover {
    background: rgba(46, 125, 50, 0.1);
    border-radius: 50%;
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

/* 移动端导航覆盖层 */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-overlay.active {
    display: block;
    opacity: 1;
}

/* 移动端响应式断点 */
@media (max-width: 768px) {
    /* 显示汉堡菜单按钮 */
    .mobile-menu-btn {
        display: flex;
    }

    /* 移动端导航菜单样式 */
    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: white;
        z-index: 1000;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
    }

    .main-nav.mobile-open {
        right: 0;
    }

    .main-nav .container {
        padding: 20px 0;
        max-width: none;
    }

    .nav-menu {
        flex-direction: column;
        gap: 0;
    }

    .nav-menu > li {
        width: 100%;
    }

    .nav-menu > li > a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 20px;
        color: var(--text-primary);
        border-radius: 0;
        white-space: normal;
        font-size: 15px;
        border-bottom: 1px solid #f0f0f0;
    }

    .nav-menu > li > a:hover,
    .nav-menu > li > a.active {
        background: rgba(46, 125, 50, 0.05);
        color: var(--primary-color);
        transform: none;
    }

    .nav-menu > li > a i.fa-chevron-down {
        margin-left: auto;
        font-size: 12px;
    }

    /* 移动端下拉菜单 */
    .has-dropdown:hover .nav-dropdown {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .nav-dropdown {
        position: static;
        transform: none;
        box-shadow: none;
        border-radius: 0;
        background: #f9f9f9;
        padding: 0;
        margin: 0;
        display: none;
        border-top: 1px solid #f0f0f0;
    }

    .has-dropdown.mobile-expanded .nav-dropdown {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    .nav-dropdown::before {
        display: none;
    }

    .nav-dropdown a {
        padding: 12px 20px 12px 40px;
        font-size: 14px;
        border-bottom: 1px solid #f0f0f0;
    }

    .nav-dropdown a:hover {
        transform: none;
    }

    /* 移动端下添加展开/收起功能 */
    .has-dropdown > a {
        cursor: pointer;
        position: relative;
    }

    .has-dropdown > a::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        position: absolute;
        right: 20px;
        transition: transform 0.3s ease;
    }

    .has-dropdown.mobile-expanded > a::after {
        transform: rotate(180deg);
    }

    /* 隐藏桌面端的小箭头图标 */
    .has-dropdown > a i.fa-chevron-down {
        display: none;
    }
}
