/*
Theme Name: GainWave
Theme URI: https://gainwave.local
Author: Volkan
Description: Lavender Light trading dashboard theme
Version: 2.2.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
Text Domain: gainwave
*/

/* ==============================================
   DESIGN TOKENS
   ============================================== */
:root {
  --bg:         #f0f0f8;
  --surface:    #ffffff;
  --ink:        #1e1b2e;
  --ink-soft:   #8b85a7;
  --lav-100:    #f5f0ff;
  --lav-200:    #e9e0ff;
  --lav-300:    #d4c4f7;
  --lav-400:    #b8a0e8;
  --lav-500:    #9d7ed8;
  --lav-600:    #8a6bc8;
  --lav-700:    #7b5fb8;
  --rose:       #e8b4d0;
  --mint:       #22c55e;
  --red:        #ef4444;
  --amber:      #f59e0b;

  --shadow-xs:  0 1px 2px rgba(30,27,46,0.04);
  --shadow-sm:  0 2px 8px rgba(30,27,46,0.06);
  --shadow:     0 4px 20px rgba(30,27,46,0.08);
  --shadow-md:  0 8px 30px rgba(30,27,46,0.10);
  --shadow-lg:  0 16px 48px rgba(30,27,46,0.12);

  --radius:     18px;
  --radius-sm:  12px;
  --font-body:  'Inter', system-ui, -apple-system, sans-serif;
  --font-pixel: 'Press Start 2P', monospace;
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--lav-700); text-decoration: none; }
a:hover { text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--lav-400);
  outline-offset: 2px;
  border-radius: 4px;
}

img { max-width: 100%; height: auto; }

.gw-wrap { max-width: 960px; margin: 0 auto; padding: 0 24px; }

/* ==============================================
   HEADER
   ============================================== */
.gw-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 24px 0;
}
.gw-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gw-logo {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--ink);
  letter-spacing: 1px;
  line-height: 1.2;
  display: inline-block;
}
.gw-logo .accent { color: var(--lav-700); }
.gw-nav { display: flex; align-items: center; gap: 8px; }
.gw-nav a {
  color: rgba(30,27,46,0.7);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 10px;
  transition: all 0.2s ease;
}
.gw-nav a:hover {
  color: var(--ink);
  background: rgba(255,255,255,0.5);
}
.gw-nav a.gw-btn-nav {
  background: var(--surface);
  color: var(--lav-700);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  border: 1px solid rgba(157,126,216,0.15);
}
.gw-nav a.gw-btn-nav:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* ==============================================
   BUTTONS
   ============================================== */
.gw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--lav-600), var(--lav-700));
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 4px 14px rgba(123,95,184,0.3);
}
.gw-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(123,95,184,0.4);
}
.gw-btn:active:not(:disabled) { transform: translateY(0); }
.gw-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.gw-btn-ghost {
  background: var(--surface);
  color: var(--ink-soft);
  box-shadow: var(--shadow-xs);
  border: 1px solid rgba(139,133,167,0.2);
}
.gw-btn-ghost:hover:not(:disabled) {
  background: var(--surface);
  border-color: rgba(157,126,216,0.3);
  color: var(--lav-700);
  box-shadow: var(--shadow-sm);
}

.gw-btn-danger {
  background: linear-gradient(135deg, #f87171, var(--red));
  box-shadow: 0 4px 14px rgba(239,68,68,0.25);
}
.gw-btn-danger:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(239,68,68,0.35);
}

.gw-btn-sm {
  padding: 8px 16px;
  font-size: 12px;
  border-radius: 10px;
}

.gw-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: gw-spin 0.7s linear infinite;
}
@keyframes gw-spin { to { transform: rotate(360deg); } }

/* ==============================================
   CARDS
   ============================================== */
.gw-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.gw-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.gw-card h2, .gw-card h3 { margin-top: 0; }
.gw-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin: 0 0 16px;
}

/* ==============================================
   HERO / WAVE HEADER
   ============================================== */
.gw-hero {
  position: relative;
  padding: 100px 0 80px;
  overflow: hidden;
}
.gw-hero-bg {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 380px;
  background:
    radial-gradient(ellipse 70% 50% at 25% 40%, rgba(212,196,247,0.6) 0%, transparent 70%),
    radial-gradient(ellipse 60% 45% at 75% 30%, rgba(232,180,208,0.4) 0%, transparent 60%),
    radial-gradient(ellipse 80% 40% at 50% 20%, rgba(233,224,255,0.5) 0%, transparent 60%);
  border-radius: 0 0 60% 60%;
  z-index: 0;
}
.gw-hero-wave {
  position: absolute;
  top: 60px; left: 0; right: 0;
  height: 300px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320'%3E%3Cpath fill='%23d4c4f7' fill-opacity='0.25' d='M0,192L48,197.3C96,203,192,213,288,192C384,171,480,117,576,112C672,107,768,149,864,170.7C960,192,1056,192,1152,176C1248,160,1344,128,1392,112L1440,96L1440,0L1392,0C1344,0,1248,0,1152,0C1056,0,960,0,864,0C768,0,672,0,576,0C480,0,384,0,288,0C192,0,96,0,48,0L0,0Z'%3E%3C/path%3E%3Cpath fill='%23e8b4d0' fill-opacity='0.15' d='M0,256L48,240C96,224,192,192,288,181.3C384,171,480,181,576,197.3C672,213,768,235,864,229.3C960,224,1056,192,1152,181.3C1248,171,1344,181,1392,186.7L1440,192L1440,0L1392,0C1344,0,1248,0,1152,0C1056,0,960,0,864,0C768,0,672,0,576,0C480,0,384,0,288,0C192,0,96,0,48,0L0,0Z'%3E%3C/path%3E%3C/svg%3E") no-repeat center bottom;
  background-size: cover;
  z-index: 0;
  pointer-events: none;
}
.gw-hero-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  padding-top: 60px;
}
.gw-hero .gw-brand {
  font-family: var(--font-pixel);
  font-size: clamp(20px, 3.5vw, 32px);
  margin: 0 0 16px;
  line-height: 1.6;
}
.gw-hero p.lede {
  max-width: 480px;
  margin: 0 auto 28px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.7;
}
.gw-hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ==============================================
   STATS ROW
   ============================================== */
.gw-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: -30px auto 0;
  position: relative;
  z-index: 2;
  padding: 0 24px;
  max-width: 960px;
}
@media (max-width: 640px) {
  .gw-stats { grid-template-columns: repeat(2, 1fr); }
}
.gw-stat {
  text-align: center;
  padding: 24px 16px;
}
.gw-stat .num {
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.gw-stat .lbl {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

/* ==============================================
   FEATURES
   ============================================== */
.gw-section { padding: 60px 0 80px; }
.gw-section h2.gw-h {
  text-align: center;
  font-size: 22px;
  margin: 0 0 6px;
  font-weight: 700;
}
.gw-section p.gw-sub {
  text-align: center;
  color: var(--ink-soft);
  margin: 0 0 32px;
  font-size: 14px;
}
.gw-features {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 860px) {
  .gw-features { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .gw-features { grid-template-columns: 1fr; }
}
.gw-feature {
  text-align: center;
  padding: 32px 20px;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.gw-feature:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}
.gw-feature .ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--lav-100), #fff);
  color: var(--lav-600);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}
.gw-feature:hover .ico {
  background: linear-gradient(135deg, var(--lav-200), var(--lav-100));
  transform: scale(1.06);
}
.gw-feature .ico svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gw-feature h3 { font-size: 14px; font-weight: 600; margin: 0 0 4px; color: var(--ink); }
.gw-feature p { font-size: 13px; color: var(--ink-soft); margin: 0; line-height: 1.5; }

/* ==============================================
   DASHBOARD
   ============================================== */
.gw-dash { padding: 32px 0 80px; }
.gw-dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.gw-dash-head h1 { font-size: 20px; margin: 0; font-weight: 700; }

.gw-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}
.gw-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #d1d5db; }
.gw-badge.running .dot { background: var(--mint); box-shadow: 0 0 0 3px rgba(34,197,94,0.2); }
.gw-badge.running { color: #16a34a; }
.gw-badge.paused .dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(245,158,11,0.2); }
.gw-badge.paused { color: #b45309; }
.gw-badge.stopped .dot { background: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,0.2); }
.gw-badge.stopped { color: #dc2626; }

/* ----- Dashboard Grid (THIS IS THE FIX) ----- */
.gw-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  align-items: start;
}
.gw-widgets {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  align-items: start;
}
/* Direct children must fill their grid area */
.gw-widgets > .gw-widget {
  min-width: 0;
}
.gw-widget {
  position: relative;
}
.gw-col-4 { grid-column: span 4; }
.gw-col-6 { grid-column: span 6; }
.gw-col-8 { grid-column: span 8; }
.gw-col-12 { grid-column: span 12; }

@media (max-width: 860px) {
  .gw-col-4, .gw-col-6, .gw-col-8 { grid-column: span 12; }
}

/* Metric cards */
.gw-metric .num { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gw-metric .sub { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.gw-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 12px; word-break: break-all; color: var(--ink-soft); }

/* Controls */
.gw-controls { display: flex; gap: 10px; flex-wrap: wrap; }

.gw-mode-toggle {
  display: inline-flex;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  padding: 3px;
  gap: 3px;
}
.gw-mode-toggle button {
  border: 0;
  background: transparent;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s ease;
}
.gw-mode-toggle button.active {
  background: var(--surface);
  color: var(--lav-700);
  box-shadow: var(--shadow-xs);
}
.gw-mode-toggle button:hover:not(.active):not(:disabled) { color: var(--ink); }
.gw-mode-toggle button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Forms */
.gw-field { margin-bottom: 14px; }
.gw-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gw-field input, .gw-field select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid rgba(139,133,167,0.2);
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  transition: all 0.2s ease;
}
.gw-field input:focus, .gw-field select:focus {
  border-color: var(--lav-400);
  outline: none;
  box-shadow: 0 0 0 4px rgba(157,126,216,0.1);
}
.gw-field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* Tables */
.gw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.gw-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(139,133,167,0.15);
}
.gw-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(139,133,167,0.08);
  font-variant-numeric: tabular-nums;
}
.gw-table tr:last-child td { border-bottom: 0; }
.gw-table tbody tr { transition: background 0.15s ease; }
.gw-table tbody tr:hover { background: rgba(157,126,216,0.03); }
.gw-pos { color: var(--mint); font-weight: 700; }
.gw-neg { color: var(--red); font-weight: 700; }
.gw-empty { color: var(--ink-soft); text-align: center; padding: 32px 12px; font-size: 13px; }

/* Auth */
.gw-auth {
  min-height: calc(100vh - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.gw-auth .gw-card { width: 100%; max-width: 400px; padding: 40px; }

.gw-notice {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 16px;
}
.gw-notice.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.gw-notice.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.gw-notice.info { background: var(--lav-100); border: 1px solid var(--lav-200); color: var(--lav-700); }

/* Footer */
.gw-footer {
  padding: 24px 0;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
}
.gw-footer .gw-wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ==============================================
   LIVE TICKER
   ============================================== */
.gw-live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--mint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.gw-live-dot .pulse {
  width: 6px; height: 6px;
  background: var(--mint);
  border-radius: 50%;
  animation: gw-pulse 2s ease-in-out infinite;
}
@keyframes gw-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.65); }
}

.gw-ticker {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.gw-ticker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(157,126,216,0.04);
}
.gw-ticker-name { font-weight: 700; color: var(--ink); min-width: 36px; }
.gw-ticker-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.gw-ticker-change { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }

/* ==============================================
   P&L SUMMARY
   ============================================== */
.gw-pnl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 640px) { .gw-pnl-grid { grid-template-columns: 1fr; } }
.gw-pnl-item {
  text-align: center;
  padding: 20px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.gw-pnl-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin-bottom: 8px; }
.gw-pnl-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.gw-pnl-meta { font-size: 12px; color: var(--ink-soft); }

/* ==============================================
   NEWS
   ============================================== */
.gw-news-item {
  display: flex;
  gap: 14px;
  padding: 10px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}
.gw-news-item:hover { background: var(--bg); text-decoration: none; }
.gw-news-img {
  width: 68px; height: 48px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
}
.gw-news-body { flex: 1; min-width: 0; }
.gw-news-title { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 3px; }
.gw-news-meta { font-size: 11px; color: var(--ink-soft); }
.gw-news-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid rgba(139,133,167,0.1);
}

/* ==============================================
   ACTIVITY LOG
   ============================================== */
.gw-activity-item {
  display: flex; gap: 12px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  transition: background 0.15s;
}
.gw-activity-item:hover { background: var(--bg); }
.gw-activity-time { color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 100px; font-size: 11px; }
.gw-activity-msg { color: var(--ink); flex: 1; word-break: break-word; }

/* ==============================================
   PAGINATION
   ============================================== */
.gw-pagination {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid rgba(139,133,167,0.1);
}

/* ==============================================
   WIDGET DRAG & DROP
   ============================================== */
.gw-widget-handle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  cursor: grab;
  user-select: none;
}
.gw-widget-handle:active { cursor: grabbing; }
.gw-widget-handle .gw-card-title { margin: 0; }
.gw-drag-hint {
  font-size: 14px;
  color: var(--ink-soft);
  opacity: 0.25;
  cursor: grab;
  padding: 2px 6px;
  border-radius: 4px;
  transition: opacity 0.2s;
}
.gw-card:hover .gw-drag-hint { opacity: 0.6; }
.gw-drag-hint:hover { opacity: 1 !important; background: var(--bg); }

/* Drag states */
.gw-widget.is-dragging {
  opacity: 0.5;
  transform: scale(0.96) rotate(1deg);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  cursor: grabbing;
}
.gw-widget.is-drag-over {
  outline: 2px dashed var(--lav-400);
  outline-offset: -2px;
  background: var(--lav-100);
}

/* Smooth transitions */
.gw-widget {
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1),
              box-shadow 0.25s ease,
              opacity 0.2s ease;
}

/* Keyboard hints */
kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  background: var(--bg);
  border: 1px solid rgba(139,133,167,0.15);
  border-radius: 5px;
  color: var(--ink-soft);
}
