/* ========== 摩瑪建材 會員管理後台樣式 ========== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    min-height: 100vh;
    color: #fff;
}

/* ========== Header ========== */

.header {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-group {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 2px;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: #d4af37;
}

.brand-name span {
    font-weight: 300;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.header-title {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 1rem;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.back-link {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.back-link:hover {
    color: #d4af37;
}

/* Admin Navigation */
.admin-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-nav > a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.admin-nav > a:hover {
    color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-btn {
    color: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-dropdown:hover .nav-dropdown-btn {
    color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
}

.nav-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(20, 20, 40, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 8px;
    min-width: 150px;
    padding: 0.5rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 200;
}

.nav-dropdown:hover .nav-dropdown-content {
    display: block;
}

.nav-dropdown-content a {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.nav-dropdown-content a:hover {
    color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .admin-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ========== Main Content ========== */

.main-content {
    padding: 2rem;
    min-height: calc(100vh - 80px);
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== Toolbar ========== */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #d4af37;
}

.member-count {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.search-input {
    padding: 0.6rem 1rem;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 0.9rem;
    width: 220px;
    transition: border-color 0.3s;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.search-input:focus {
    outline: none;
    border-color: #d4af37;
}

/* ========== Buttons ========== */

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn.primary {
    background: linear-gradient(135deg, #d4af37, #aa8a2e);
    color: #fff;
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn.danger {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: #fff;
}

.btn.danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(229, 62, 62, 0.4);
}

/* ========== Table ========== */

.table-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    overflow: hidden;
}

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

.member-table th,
.member-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.member-table th {
    background: rgba(212, 175, 55, 0.1);
    color: #d4af37;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.member-table tbody tr:hover {
    background: rgba(212, 175, 55, 0.05);
}

.member-name {
    font-weight: 500;
}

.member-note {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

.admin-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 4px;
    vertical-align: middle;
}

.sales-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 4px;
    vertical-align: middle;
}

/* Checkbox 樣式 */
.checkbox-group {
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #d4af37;
    cursor: pointer;
}

.checkbox-text {
    color: #fff;
    font-weight: 500;
}

.checkbox-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
}

.no-results {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 3rem !important;
}

/* Level Badges */
.level-badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.level-badge.level-designer,
.level-badge.level-architect,
.level-badge.level-bni_national {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

.level-badge.level-bni_taichung,
.level-badge.level-hardware_store {
    background: rgba(33, 150, 243, 0.2);
    color: #64b5f6;
}

.level-badge.level-distributor_basic,
.level-badge.level-distributor_invested,
.level-badge.level-subsidiary {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
}

/* Discount Badges */
.discount-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

.discount-badge.gold {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
}

.discount-badge.vip {
    background: rgba(156, 39, 176, 0.2);
    color: #ba68c8;
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn.edit {
    background: rgba(33, 150, 243, 0.2);
    color: #64b5f6;
}

.action-btn.edit:hover {
    background: rgba(33, 150, 243, 0.4);
}

.action-btn.delete {
    background: rgba(244, 67, 54, 0.2);
    color: #e57373;
}

.action-btn.delete:hover {
    background: rgba(244, 67, 54, 0.4);
}

/* ========== Empty State ========== */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(212, 175, 55, 0.3);
    border-radius: 12px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* ========== Modal ========== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 1000;
}

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

.modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.open .modal {
    transform: scale(1);
}

.modal.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #d4af37;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

.modal-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin-bottom: 0.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.form-group .required {
    color: #ff6b6b;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #d4af37;
}

.form-group input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-group select {
    cursor: pointer;
}

.form-group select option {
    background: #1a1a2e;
    color: #fff;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.form-actions .btn {
    flex: 1;
}

.text-muted {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
}

/* ========== Toast ========== */

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1001;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ========== 統計儀表板 v2.0 ========== */

.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.stat-card:hover {
    border-color: rgba(212, 175, 55, 0.5);
    transform: translateY(-2px);
}

.stat-card.active {
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #d4af37;
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.5rem;
}

.stat-card.vip .stat-number {
    color: #ba68c8;
}

.stat-card.gold .stat-number {
    color: #ffc107;
}

.stat-card.sales .stat-number {
    color: #81c784;
}

/* ========== 快速篩選 ========== */

.filter-section {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.filter-chip {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-chip:hover {
    border-color: rgba(212, 175, 55, 0.5);
    color: #fff;
}

.filter-chip.active {
    background: rgba(212, 175, 55, 0.2);
    border-color: #d4af37;
    color: #d4af37;
}

.filter-chip .count {
    margin-left: 0.5rem;
    padding: 0.15rem 0.4rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-size: 0.75rem;
}

.filter-chip.active .count {
    background: rgba(212, 175, 55, 0.3);
}

/* ========== 批量操作 ========== */

.bulk-actions {
    display: none;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.bulk-actions.show {
    display: flex;
}

.bulk-info {
    color: #d4af37;
    font-weight: 500;
}

.bulk-btns {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

/* ========== 表格增強 ========== */

.member-table .select-cell {
    width: 40px;
    text-align: center;
}

.member-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #d4af37;
    cursor: pointer;
}

.member-table tbody tr.selected {
    background: rgba(212, 175, 55, 0.1);
}

/* ========== 動畫效果 ========== */

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

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

.stat-card {
    animation: slideIn 0.3s ease-out;
}

.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }
.stat-card:nth-child(5) { animation-delay: 0.2s; }

.member-table tbody tr {
    animation: slideIn 0.2s ease-out;
}

/* ========== 快速操作提示 ========== */

.keyboard-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 0.5rem;
}

.kbd {
    padding: 0.1rem 0.4rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.7rem;
}

/* ========== RWD ========== */

@media (max-width: 1024px) {
    .member-table th:nth-child(6),
    .member-table td:nth-child(6) {
        display: none;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .header-title {
        order: -1;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        justify-content: center;
    }

    .keyboard-hint {
        display: none;
    }

    .search-input {
        width: 100%;
    }

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

    .member-table th:nth-child(1),
    .member-table td:nth-child(1),
    .member-table th:nth-child(4),
    .member-table td:nth-child(4),
    .member-table th:nth-child(6),
    .member-table td:nth-child(6) {
        display: none;
    }

    .bulk-actions {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .bulk-btns {
        margin-left: 0;
        flex-wrap: wrap;
        justify-content: center;
    }

    .action-btns {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }

    .member-table th,
    .member-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    .level-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}
