/* ========== 摩瑪建材 經銷網路儀表板 ========== */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --gold: #c9a962;
    --gold-light: #e8d5a3;
    --gold-dark: #8b7355;
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a0;
    --text-muted: #666;
    --border: rgba(201, 169, 98, 0.2);
    --success: #4a9c6d;
    --warning: #d69e2e;
    --danger: #e53e3e;
    --info: #4299e1;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans TC', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Header */
.admin-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gold);
}

.page-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--border);
}

.admin-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-nav > a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.admin-nav > a:hover {
    color: var(--gold);
    background: rgba(201, 169, 98, 0.1);
}

.nav-dropdown { position: relative; }

.nav-dropdown-btn {
    color: var(--text-secondary);
    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: var(--gold);
    background: rgba(201, 169, 98, 0.1);
}

.nav-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    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: var(--text-secondary);
    text-decoration: none;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.nav-dropdown-content a:hover {
    color: var(--gold);
    background: rgba(201, 169, 98, 0.1);
}

/* Main */
.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Self Info Card */
.self-card {
    background: linear-gradient(135deg, var(--bg-card), rgba(201, 169, 98, 0.08));
    border: 1px solid var(--gold);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.self-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(201, 169, 98, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

.self-info { flex: 1; }

.self-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 0.25rem;
}

.self-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.self-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.self-meta-item .value {
    color: var(--text-primary);
    font-weight: 600;
}

.self-discount {
    background: var(--gold);
    color: var(--bg-primary);
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    text-align: center;
    flex-shrink: 0;
}

.self-discount small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.8;
}

/* Section */
.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.section-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gold);
}

.section-body {
    padding: 1.5rem;
}

/* Network Tree */
.network-tree {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 2;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow-x: auto;
}

.tree-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    white-space: nowrap;
}

.tree-line .indent {
    color: var(--text-muted);
    user-select: none;
}

.tree-line .node-name {
    color: var(--text-primary);
    font-weight: 600;
}

.tree-line .node-id {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.tree-line .node-discount {
    background: rgba(201, 169, 98, 0.2);
    color: var(--gold);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tree-line .node-type {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.tree-line.self {
    background: rgba(201, 169, 98, 0.1);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
}

/* Upstream Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: rgba(201, 169, 98, 0.05);
}

.type-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.type-badge.sub { background: rgba(74, 156, 109, 0.2); color: var(--success); }
.type-badge.dealer { background: rgba(201, 169, 98, 0.2); color: var(--gold); }
.type-badge.designer { background: rgba(66, 153, 225, 0.2); color: var(--info); }
.type-badge.personal { background: rgba(160, 160, 160, 0.2); color: var(--text-secondary); }
.type-badge.hq { background: rgba(201, 169, 98, 0.3); color: var(--gold-light); }

.discount-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(201, 169, 98, 0.15);
    color: var(--gold);
}

.member-count {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* No Customer Message */
.no-customer {
    text-align: center;
    padding: 4rem 2rem;
}

.no-customer-icon {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.no-customer-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.no-customer-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Loading */
.loading-container {
    text-align: center;
    padding: 4rem 2rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Toast */
.admin-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--gold);
    color: var(--bg-primary);
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.admin-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .admin-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .admin-main {
        padding: 1rem;
    }

    .self-card {
        flex-direction: column;
        text-align: center;
    }

    .self-meta {
        justify-content: center;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
    }
}
