@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #090c15;
    --bg-secondary: #101525;
    --bg-card: rgba(56, 74, 125, 0.12); /* Tinted with brand blue #384A7D */
    --border-color: rgba(56, 74, 125, 0.25); /* Brand blue border tint */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --primary: #C8A852; /* Brand Gold */
    --primary-glow: rgba(200, 168, 82, 0.35);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --warning: #C8A852; /* Warning matches gold */
    --danger: #ef4444;
    --info: #818cf8;
    --brand-blue: #384A7D;
    --brand-gold: #C8A852;
    --font-sans: 'Heiti TC', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

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

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 74, 125, 0.25) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(200, 168, 82, 0.12) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Glassmorphism Container Utility */
.glass-panel {
    background: rgba(14, 19, 33, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    padding: 24px;
    transition: var(--transition-normal);
}
.glass-panel:hover {
    border-color: rgba(200, 168, 82, 0.35); /* Glow using brand gold */
    box-shadow: 0 8px 32px 0 rgba(200, 168, 82, 0.05);
}

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Header & Navigation */
header {
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, var(--primary), #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo span {
    font-weight: 400;
    color: var(--text-secondary);
}

/* Brand Logo Containers */
.logo-container {
    background: transparent;
    padding: 6px 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    text-decoration: none;
}
.logo-container:hover {
    transform: scale(1.02);
}
.logo-img {
    height: 38px;
    width: auto;
    object-fit: contain;
    display: block;
}

.logo-container-large {
    background: transparent;
    padding: 10px 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    transition: var(--transition-fast);
}
.logo-container-large:hover {
    transform: translateY(-2px);
}
.logo-img-large {
    height: 64px;
    width: auto;
    object-fit: contain;
    display: block;
}

.user-nav-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-badge::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-gold), #b09144);
    color: #0c0f17;
    box-shadow: 0 4px 14px 0 var(--primary-glow);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(200, 168, 82, 0.5);
    background: linear-gradient(135deg, #d7b864, var(--brand-gold));
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.35);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #059669;
    box-shadow: 0 4px 14px 0 var(--success-glow);
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    transition: var(--transition-fast);
    width: 100%;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 2px var(--primary-glow);
}
.form-control::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

/* Login/Registration Pages layout */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 70px);
    padding: 40px 20px;
}

.auth-card {
    width: 100%;
    max-width: 480px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.auth-footer a:hover {
    text-decoration: underline;
}

/* Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 50px;
}

@media (max-width: 968px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-card-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(to right, #ffffff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-blocked {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Alert Boxes */
.alert-box {
    border-left: 4px solid var(--primary);
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0 12px 12px 0;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.alert-box-warning {
    border-left-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.alert-box-content {
    flex: 1;
}

.alert-box-title {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 4px;
}

.alert-box-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Referral link panel */
.ref-link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 10px;
    margin-top: 10px;
}

.ref-link-card input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    flex: 1;
    outline: none;
}

/* Donation flow / grid */
.uplines-list, .donations-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.donation-item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 12px;
    transition: var(--transition-fast);
}

.donation-item-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
}

.donation-info h4 {
    font-size: 16px;
    font-weight: 600;
}

.donation-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.donation-action {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Tables styling */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Modal styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    padding: 30px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: modalFadeIn var(--transition-normal);
}

@keyframes modalFadeIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.modal-close {
    cursor: pointer;
    font-size: 24px;
    color: var(--text-secondary);
    border: none;
    background: transparent;
    transition: var(--transition-fast);
}
.modal-close:hover {
    color: var(--text-primary);
}

/* Visual Tree styling */
.tree-container {
    width: 100%;
    background: rgba(11, 15, 25, 0.3);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 30px;
    overflow: auto;
    min-height: 450px;
}

.tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.tree ul {
    padding-top: 20px; 
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
}

.tree li {
    float: left; 
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 10px 0 10px;
    transition: all 0.5s;
}

/* Usamos ::before e ::after para desenhar os conectores da rede */
.tree li::before, .tree li::after{
    content: '';
    position: absolute; 
    top: 0; 
    right: 50%;
    border-top: 1.5px solid var(--border-color);
    width: 50%; 
    height: 20px;
}
.tree li::after{
    right: auto; 
    left: 50%;
    border-left: 1.5px solid var(--border-color);
}

/* Remover conectores para filhos únicos */
.tree li:only-child::after, .tree li:only-child::before {
    display: none;
}

.tree li:only-child{ 
    padding-top: 0;
}

.tree li:first-child::before, .tree li:last-child::after{
    border: 0 none;
}

.tree li:last-child::before{
    border-right: 1.5px solid var(--border-color);
    border-radius: 0 5px 0 0;
}
.tree li:first-child::after{
    border-radius: 5px 0 0 0;
}

.tree ul ul::before{
    content: '';
    position: absolute; 
    top: 0; 
    left: 50%;
    border-left: 1.5px solid var(--border-color);
    width: 0; 
    height: 20px;
}

.tree-node {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    display: inline-block;
    min-width: 150px;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    transition: var(--transition-fast);
}

.tree-node:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--primary-glow);
}

.tree-node .node-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.tree-node .node-role {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.tree-node .node-status {
    margin-top: 4px;
}

.tree-node.pending {
    border-color: rgba(245, 158, 11, 0.4);
}
.tree-node.pending:hover {
    border-color: var(--warning);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.2);
}

.tab-nav {
    display: flex;
    gap: 10px;
    border-bottom: 1.5px solid var(--border-color);
    padding-bottom: 2px;
    margin-bottom: 24px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-family: var(--font-sans);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border-bottom: 2.5px solid transparent;
    font-size: 15px;
}
.tab-btn:hover {
    color: var(--text-primary);
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
}

/* Visual list grid helper */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.custom-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.custom-card h4 {
    font-size: 17px;
    font-weight: 700;
}

.custom-card p {
    font-size: 14px;
    color: var(--text-secondary);
}

.custom-card .card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

/* Responsive Utilities & Form Layouts */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 14px;
    }
    
    .stat-card-value {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0 12px;
    }
    
    .logo-container {
        padding: 5px 0;
    }
    
    .logo-img {
        height: 32px;
    }
    
    .user-badge {
        display: none;
    }
}
