/* ========================================
   Energy Trading Platform - User Frontend
   Unified Theme CSS v2
   ======================================== */

:root {
  --primary: #00cc44; --primary-dark: #009933; --primary-light: #66ff99;
  --secondary: #0077cc; --accent: #6c5ce7; --energy: #fdcb6e;
  --bg: #0a1628; --bg-card: rgba(15,30,55,0.85); --bg-card-hover: rgba(20,40,70,0.9);
  --bg-glass: rgba(255,255,255,0.04); --bg-overlay: rgba(10,22,40,0.6);
  --border: rgba(0,200,60,0.15); --border-glow: rgba(0,200,60,0.4);
  --shadow: 0 4px 24px rgba(0,0,0,0.3); --shadow-glow: 0 0 30px rgba(0,200,60,0.15);
  --text: #e2e8f0; --text-muted: #94a3b8; --text-bright: #ffffff;
  --success: #009933; --warning: #fdcb6e; --danger: #e17055; --info: #74b9ff;
  --radius: 12px; --radius-lg: 20px; --radius-sm: 8px;
  --gap: 16px; --gap-sm: 8px; --gap-lg: 24px;
  --transition: 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  padding-top: 36px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}

/* Background layers */
.grid-bg {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(rgba(0,200,60,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,200,60,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: -2;
  background: radial-gradient(ellipse 200px 300px at 85% 30%, rgba(0,200,60,0.06) 0%, transparent 100%),
              radial-gradient(ellipse 250px 350px at 15% 75%, rgba(9,132,227,0.05) 0%, transparent 100%),
              radial-gradient(circle 600px at 50% 50%, rgba(0,200,60,0.04) 0%, transparent 70%),
              linear-gradient(180deg, #0a1628 0%, #0c1d38 30%, #0d2240 60%, #0a1628 100%);
}

/* Container */
.container { max-width: 800px; margin: 0 auto; padding: var(--gap); }

/* Header bar */
.header-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: rgba(10,22,40,0.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.header-title { font-size: 16px; font-weight: 700; color: var(--text-bright); }
.header-right { display: flex; align-items: center; gap: var(--gap-sm); }
.header-balance { font-size: 12px; color: var(--text-muted); cursor: pointer; }
.header-balance strong { color: var(--primary); font-size: 13px; }

/* Language bar */
.lang-bar { position: fixed; top: 0; right: 0; z-index: 9999; text-align: right; padding: 6px 16px; background: rgba(15,25,50,0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 0 0 0 8px; }
.lang-select {
  padding: 4px 10px; border-radius: 4px; background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); font-size: 13px; cursor: pointer; outline: none;
}

/* Bottom navigation */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(10,22,40,0.95); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border); z-index: 99;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
  justify-content: space-around;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px; color: var(--text-muted); text-decoration: none;
  font-size: 10px; font-weight: 500; transition: var(--transition);
}
.bottom-nav a .nav-icon { font-size: 20px; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--primary); }

/* Cards */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 16px; margin-bottom: var(--gap); border: 1px solid var(--border); }
.balance-card {
  background: linear-gradient(135deg, rgba(0,153,51,0.2), rgba(0,200,60,0.08));
  border: 1px solid rgba(0,200,60,0.2); border-radius: var(--radius-lg);
  padding: 24px 20px; margin-bottom: var(--gap); text-align: center;
  backdrop-filter: blur(10px);
}
.balance-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.balance-amount { font-size: 32px; font-weight: 800; color: var(--primary); }
.balance-stats { display: flex; justify-content: space-around; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.balance-stat-item { text-align: center; }
.stat-num { font-size: 18px; font-weight: 700; color: var(--text-bright); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.section-title { font-size: 18px; font-weight: 700; color: var(--text-bright); margin: var(--gap) 0 var(--gap-sm); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm); font-size: 14px;
  font-weight: 600; cursor: pointer; transition: var(--transition); text-decoration: none;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary-dark); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { opacity: 0.9; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: rgba(0,200,60,0.1); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.action-row { display: flex; gap: var(--gap-sm); margin-bottom: var(--gap); }
.action-row .btn { flex: 1; }

/* Forms */
.form-group { margin-bottom: var(--gap); }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-input, .form-select {
  width: 100%; padding: 10px 14px; background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-family: inherit;
  transition: var(--transition); outline: none;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,200,60,0.1); }
.form-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-select option { background: var(--bg); color: var(--text); }

/* Product grid */
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap-sm); }
.product-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: var(--transition);
}
.product-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.product-img {
  height: 120px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(0,200,60,0.1), rgba(0,119,204,0.05));
  font-size: 48px; position: relative; overflow: hidden;
}
.product-img img { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; }
.product-badge {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.5);
  color: var(--primary-light); font-size: 10px; padding: 2px 8px; border-radius: 10px;
}
.product-info { padding: 12px; }
.product-name { font-size: 14px; font-weight: 700; color: var(--text-bright); }
.product-price { font-size: 20px; font-weight: 800; color: var(--primary); margin: 4px 0; }
.product-daily { font-size: 12px; color: var(--text-muted); }
.product-total { font-size: 11px; color: var(--text-muted); }

/* Device items */
.device-item {
  display: flex; align-items: center; gap: var(--gap); padding: 12px;
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: var(--gap-sm);
}
.device-icon {
  font-size: 28px; width: 44px; height: 44px; display: flex; align-items: center;
  justify-content: center; background: rgba(0,200,60,0.1); border-radius: var(--radius-sm); flex-shrink: 0;
}
.device-info { flex: 1; min-width: 0; }
.device-name { font-size: 14px; font-weight: 600; color: var(--text-bright); margin-bottom: 4px; }
.device-progress { height: 6px; background: var(--bg-glass); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.device-progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary-dark), var(--primary)); border-radius: 3px; transition: width 0.5s ease; }
.device-progress-bar.completed { background: var(--success); }
.device-profit { font-size: 12px; color: var(--text-muted); }

/* Tabs */
.tabs { display: flex; gap: 2px; background: var(--bg-glass); border-radius: var(--radius-sm); padding: 3px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab { padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: 6px; transition: var(--transition); white-space: nowrap; user-select: none; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary-dark); color: #fff; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-content { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--gap-lg); max-width: 500px; width: 100%; max-height: 80vh; overflow-y: auto; backdrop-filter: blur(20px); }
.modal-title { font-size: 18px; font-weight: 700; color: var(--text-bright); margin-bottom: var(--gap); }
.modal-close { float: right; background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; padding: 4px 8px; }
.modal-close:hover { color: var(--text-bright); }

/* Auth pages */
.auth-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-logo { margin-bottom: 16px; }
.auth-title { font-size: 28px; font-weight: 800; color: var(--text-bright); margin-bottom: 4px; text-align: center; }
.auth-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; text-align: center; }
.auth-card { width: 100%; max-width: 400px; background: rgba(15,30,55,0.9); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; backdrop-filter: blur(20px); }

/* Announcement banner */
.announcement-banner { padding: 10px 16px; background: rgba(253,203,110,0.1); border: 1px solid rgba(253,203,110,0.2); border-radius: var(--radius-sm); font-size: 13px; color: var(--energy); margin-bottom: var(--gap); text-align: center; }

/* Invite hero */
.invite-hero { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border-radius: 16px; padding: 20px; margin-bottom: var(--gap); text-align: center; }
.invite-hero .code { font-size: 28px; font-weight: 800; letter-spacing: 3px; margin: 8px 0; background: rgba(255,255,255,0.15); display: inline-block; padding: 6px 20px; border-radius: 8px; }
.invite-hero .lbl { font-size: 12px; opacity: 0.8; }
.invite-row { display: flex; gap: 8px; margin-top: 8px; }
.invite-row input { flex: 1; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.invite-row button { background: rgba(255,255,255,0.2); color: #fff; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; }

/* Commission card */
.comm-card { background: linear-gradient(135deg, #2e7d32, #1b5e20); color: #fff; border-radius: 12px; padding: 14px 18px; margin-bottom: var(--gap); display: flex; justify-content: space-between; align-items: center; }
.comm-card .val { font-size: 22px; font-weight: 700; }
.comm-card .lbl { font-size: 12px; opacity: 0.85; }

/* Team member row */
.member-row { display: flex; align-items: center; gap: 10px; padding: 10px; margin: 4px 0; background: rgba(255,255,255,0.03); border-radius: 8px; }
.member-row .icon { font-size: 20px; width: 30px; text-align: center; }
.member-row .info { flex: 1; }
.member-row .name { font-weight: 600; color: #e2e8f0; }
.member-row .sub { font-size: 11px; color: #94a3b8; }
.member-row .comm { color: #009933; font-weight: 700; }

/* Channel grid for deposit */
.channel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.channel-card { border: 2px solid var(--border); border-radius: 12px; padding: 14px 12px; cursor: pointer; transition: all 0.2s; text-align: center; background: var(--bg-card); }
.channel-card:hover { border-color: var(--primary); }
.channel-card.selected { border-color: var(--primary); background: rgba(0,153,51,0.08); box-shadow: 0 0 0 2px rgba(0,153,51,0.2); }
.channel-card .ch-icon { font-size: 28px; margin-bottom: 4px; }
.channel-card .ch-name { font-weight: 600; font-size: 14px; color: var(--text); }
.channel-card .ch-detail { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; word-break: break-all; }

/* Upload box */
.upload-box { border: 2px dashed var(--border); border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; transition: all 0.2s; background: var(--bg-card); position: relative; min-height: 120px; display: flex; align-items: center; justify-content: center; }
.upload-box:hover { border-color: var(--primary); }
.upload-box.has-file { border-style: solid; border-color: var(--success); padding: 8px; }
.upload-box .upload-placeholder { color: var(--text-muted); }
.upload-box .upload-placeholder .plus { font-size: 36px; display: block; margin-bottom: 4px; color: var(--primary); }
.upload-box img { max-width: 100%; max-height: 200px; border-radius: 8px; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 30px; }
.loading-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; color: #fff; backdrop-filter: blur(10px); animation: toast-in 0.3s ease; box-shadow: var(--shadow); max-width: 360px; }
.toast-success { background: rgba(0,184,148,0.9); }
.toast-error { background: rgba(225,112,85,0.9); }
.toast-warning { background: rgba(253,203,110,0.9); color: #1a1a2e; }
.toast-info { background: rgba(116,185,255,0.9); }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* Energy pulse animation */
@keyframes energy-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(0,200,60,0.4); } 50% { box-shadow: 0 0 0 12px rgba(0,200,60,0); } }
.energy-pulse { animation: energy-pulse 2s infinite; }

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt { margin-top: var(--gap); }
.mb { margin-bottom: var(--gap); }
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
  html { font-size: 15px; }
  .container { padding: var(--gap-sm); }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: var(--gap-sm); }
  .product-img { height: 100px; font-size: 36px; }
  .balance-amount { font-size: 28px; }
  .action-row { flex-direction: column; }.auth-title { font-size: 24px; }
  .toast-container { right: 10px; left: 10px; }
  .toast { max-width: 100%; }
  .modal-content { max-width: 95vw; padding: var(--gap); }
  .channel-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .product-grid { grid-template-columns: 1fr; }
  .balance-stats { flex-direction: column; gap: var(--gap-sm); }
  .channel-grid { grid-template-columns: 1fr; }
}
/* === Desktop Top Navigation === */
.top-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,22,40,0.95); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.top-nav-inner {
  max-width: 800px; margin: 0 auto; display: flex;
  justify-content: space-around; align-items: center; padding: 0 var(--gap);
}
.top-nav a {
  display: flex; align-items: center; gap: 6px; padding: 12px 16px;
  color: var(--text-muted); text-decoration: none; font-size: 14px;
  font-weight: 500; border-bottom: 2px solid transparent; transition: var(--transition); white-space: nowrap;
}
.top-nav a:hover { color: var(--text-bright); border-bottom-color: rgba(0,200,60,0.3); }
.top-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.top-nav a .nav-icon { font-size: 16px; }

/* Responsive nav switching */
@media (max-width: 768px) {
  .top-nav { display: none; }
  .bottom-nav { display: flex; justify-content: space-around; }
  body { padding-bottom: 70px; }
}
@media (min-width: 769px) {
  .bottom-nav { display: none; }
}
