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

:root {
  --violet: #8B5CF6;
  --violet-light: #A78BFA;
  --violet-bg: rgba(139, 92, 246, 0.08);
  --pink: #EC4899;
  --gradient: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --bg-page: #f0f2f5;
  --bg-main: #f5f5f5;
  --card: #ffffff;
  --border: #f3f4f6;
  --border-hover: #e5e7eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-2xl: 40px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--violet); text-decoration: none; }
a:hover { color: var(--violet-light); }
button, input, textarea, select { font: inherit; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== DESKTOP LAYOUT ===== */
.user-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 30;
  box-shadow: var(--shadow);
}

.sidebar-brand { padding: 28px 24px 20px; border-bottom: 1px solid var(--border); }
.sidebar-brand h1 { font-size: 28px; font-weight: 900; letter-spacing: -0.5px; }
.sidebar-brand p { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: var(--violet-bg); color: var(--violet); }
.sidebar-nav a.active {
  background: var(--violet-bg);
  color: var(--violet);
  border-left-color: var(--violet);
}
.sidebar-nav .nav-icon { width: 22px; height: 22px; flex-shrink: 0; }

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--gradient);
  padding: 2px;
  flex-shrink: 0;
}
.sidebar-avatar-inner {
  width: 100%; height: 100%;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .balance { font-size: 11px; color: var(--text-muted); }
.sidebar-logout { color: #d1d5db; cursor: pointer; transition: color 0.2s; }
.sidebar-logout:hover { color: var(--danger); }

.main-content {
  flex: 1;
  margin-left: 250px;
  min-height: 100vh;
  background: var(--bg-main);
  overflow-y: auto;
}

.main-inner { padding: 32px; max-width: 1200px; }
.main-inner-wide { padding: 32px; max-width: 100%; }

/* ===== MOBILE BOTTOM NAV ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
  flex: 1;
  text-align: center;
}
.bottom-nav a.active { color: var(--violet); }
.bottom-nav a .nav-icon { width: 22px; height: 22px; }

/* ===== COMPONENTS ===== */

.page-title { margin-bottom: 28px; }
.page-title h1 { font-size: 28px; font-weight: 900; color: var(--text); }
.page-title p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.page-title .flex-row { display: flex; align-items: center; justify-content: space-between; }

.card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-lg { border-radius: var(--radius-2xl); padding: 36px; }
.card-sm { border-radius: var(--radius-lg); padding: 20px; }

.balance-tag {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: rgba(139, 92, 246, 0.08);
  color: var(--violet);
  padding: 8px 18px;
  border-radius: 999px;
  min-width: 72px;
  line-height: 1;
}
.balance-tag-amount {
  font-size: 18px;
  font-weight: 900;
}
.balance-tag-label {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.7;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 13px 24px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover { box-shadow: 0 12px 32px rgba(139, 92, 246, 0.4); }
.btn-outline {
  background: #fff;
  color: var(--text-secondary);
  border: 1px solid var(--border-hover);
}
.btn-outline:hover { border-color: var(--violet); color: var(--violet); }
.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 8px 16px; font-size: 12px; min-height: 36px; border-radius: 10px; }
.btn-lg { padding: 16px 32px; font-size: 16px; min-height: 56px; border-radius: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-page);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: all 0.2s;
}
.form-input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139,92,246,0.1); background: #fff; }
.form-input::placeholder { color: var(--text-muted); }
textarea.form-input { resize: vertical; min-height: 120px; }
select.form-input { cursor: pointer; }

.input-icon {
  position: relative;
}
.input-icon .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.input-icon input { padding-left: 42px; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed #e5e7eb;
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-page);
}
.upload-zone:hover { border-color: var(--violet-light); background: rgba(139,92,246,0.03); }
.upload-zone .upload-icon { font-size: 40px; margin-bottom: 8px; }
.upload-zone .upload-text { font-size: 14px; font-weight: 600; color: var(--text); }
.upload-zone .upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Tags */
.tag {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.tag-violet { background: rgba(139,92,246,0.08); color: var(--violet); }
.tag-violet:hover { background: rgba(139,92,246,0.15); }

/* Flash */
.flash {
  padding: 14px 20px;
  border-radius: 16px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
}
.flash-success { background: rgba(16,185,129,0.08); color: #059669; border: 1px solid rgba(16,185,129,0.2); }
.flash-error { background: rgba(239,68,68,0.08); color: #dc2626; border: 1px solid rgba(239,68,68,0.2); }

/* Status Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
}
.badge-success { background: rgba(16,185,129,0.1); color: #059669; }
.badge-pending { background: rgba(245,158,11,0.1); color: #d97706; }
.badge-failed { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-info { background: rgba(139,92,246,0.08); color: var(--violet); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:hover td { background: rgba(139,92,246,0.02); }
td .td-amount { font-weight: 700; }
td .td-amount.positive { color: #059669; }
td .td-amount.negative { color: #dc2626; }

/* Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.gallery-item {
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  transition: all 0.2s;
}
.gallery-item:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.gallery-item img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; }
.gallery-item .info { padding: 12px; font-size: 12px; color: var(--text-secondary); }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 900; color: var(--text); }
.stat-card.accent { background: var(--gradient); color: #fff; border: none; }
.stat-card.accent .stat-label { color: rgba(255,255,255,0.7); }
.stat-card.accent .stat-value { color: #fff; }

/* Two Column Layout */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.two-col-wide { display: grid; grid-template-columns: 1fr 1.5fr; gap: 24px; align-items: start; }

/* Mode Toggle */
.mode-toggle {
  display: flex;
  background: var(--bg-page);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}
.mode-toggle button {
  flex: 1;
  padding: 10px 20px;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s;
}
.mode-toggle button.active { background: #fff; color: var(--violet); box-shadow: var(--shadow); }

/* Asset Grid */
.asset-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.asset-thumb {
  width: 56px; height: 56px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.asset-thumb:hover, .asset-thumb.selected { border-color: var(--violet); }

/* Material Grid */
.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.material-card {
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  transition: all 0.2s;
}
.material-card:hover { box-shadow: var(--shadow-md); }
.material-card img { width: 100%; height: 160px; object-fit: cover; }
.material-card .info { padding: 10px 14px 14px; }
.material-card .info .name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-card .info .meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* Result Area */
.result-area { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.result-empty {
  border: 2px dashed var(--border);
  border-radius: 20px;
  padding: 48px;
  text-align: center;
  color: var(--text-muted);
}
.result-loading {
  border-radius: 20px;
  padding: 48px;
  text-align: center;
  background: rgba(139,92,246,0.04);
  color: var(--violet);
}

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-dark { border-color: rgba(139,92,246,0.2); border-top-color: var(--violet); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; }

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.loading-overlay .spinner { width: 40px; height: 40px; border-width: 3px; margin-bottom: 16px; }
.loading-overlay .text { font-size: 14px; font-weight: 500; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 32px;
  z-index: 201;
  max-width: 500px;
  width: calc(100% - 32px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}

/* Auth Card (login/register) */
.auth-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card {
  background: #fff;
  border-radius: var(--radius-2xl);
  padding: 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.08);
}
.auth-card h1 { font-size: 36px; font-weight: 900; }
.auth-card h2 { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.auth-card .subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

/* Profile */
.profile-section { display: flex; flex-direction: column; align-items: center; padding: 32px 0; }
.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 24px;
  background: var(--gradient);
  padding: 2px;
  margin-bottom: 16px;
}
.profile-avatar-inner {
  width: 100%; height: 100%;
  border-radius: 22px;
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  color: var(--violet-light);
}
.profile-name { font-size: 24px; font-weight: 900; }
.profile-id { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.profile-stats { display: flex; gap: 32px; margin-top: 24px; }
.profile-stat { text-align: center; }
.profile-stat .num { font-size: 22px; font-weight: 900; }
.profile-stat .label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-top: 4px; }

.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.menu-item:hover { background: rgba(139,92,246,0.04); }
.menu-item .left { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; color: var(--text); }
.menu-item .right { color: var(--text-muted); }

/* Works List */
.works-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.work-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.work-card:hover { box-shadow: var(--shadow-md); }
.work-card .work-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.work-card .work-id { font-size: 10px; font-family: monospace; color: var(--text-muted); background: var(--bg-page); padding: 4px 8px; border-radius: 6px; }
.work-card .work-body { display: flex; gap: 16px; }
.work-card .work-thumb { width: 80px; height: 80px; border-radius: 16px; background: var(--bg-page); flex-shrink: 0; overflow: hidden; }
.work-card .work-thumb img { width: 100%; height: 100%; object-fit: cover; }
.work-card .work-info { flex: 1; min-width: 0; }
.work-card .work-prompt { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.work-card .work-meta { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 8px; }
.work-card .work-meta-left { font-size: 11px; color: var(--text-muted); }

/* Auth forms */
.auth-form { display: flex; flex-direction: column; gap: 16px; }

/* ===== RESPONSIVE ===== */
@media (min-width: 769px) {
  .mobile-only { display: none !important; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .main-inner, .main-inner-wide { padding: 16px; }

  .bottom-nav { display: block; }

  .page-title h1 { font-size: 24px; }
  .card, .card-lg { border-radius: var(--radius-lg); padding: 20px; }

  .stats-grid { grid-template-columns: 1fr; }
  .two-col, .two-col-wide { grid-template-columns: 1fr; }
  .works-grid { grid-template-columns: 1fr; }
  .material-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .auth-wrapper { align-items: flex-start; padding-top: 48px; }
  .auth-card { padding: 28px; border-radius: var(--radius-lg); }

  .modal { padding: 24px; border-radius: var(--radius-lg); }
  .table-wrap table { font-size: 12px; }
  th, td { padding: 10px 8px; }

  .btn { min-height: 44px; }
  .profile-stats { gap: 20px; }
}

@media (max-width: 480px) {
  .auth-card h1 { font-size: 28px; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .material-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
