/***************************************
 * Loris Tools - CSS Structure
 * 
 * 1. CSS Variables
 * 2. Base & Reset
 * 3. Typography
 * 4. Layout & Grid
 * 5. Navigation
 * 6. Components
 ***************************************/

/* 1. CSS Variables */
:root {
  --bg-dark: #0f0f0f;
  --bg-surface: #0f0f0ff2;
  --accent: #444444;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a6b3;
  --border: rgba(255, 255, 255, 0.07);
  --green: #00b068;
  --red: #ea3943;
  --hyperliquid-green: #00e5af;
}

/* 2. Base & Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  max-width: 100%;
  overflow-x: hidden;
}

/* 3. Typography */
h1,
h2,
h3,
h4,
h5,
p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
}

/* 4. Layout & Grid */
.container,
.container-fluid,
.container-lg,
.container-md,
.container-sm,
.container-xl {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

.row {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  display: flex !important;
}

[class^="col-"] {
  padding: 4px !important;
  margin: 0 !important;
}

/* 5. Navigation */
.navbar {
  width: 100%;
  background-color: var(--bg-surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.75rem;
  display: flex !important;
  align-items: center !important;
  position: relative !important;
  z-index: 1030;
  min-height: 50px;
}

.navbar-brand {
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--hyperliquid-green) !important;
  font-family: 'Silkscreen', cursive;
  margin-right: 3rem;
  display: flex;
  align-items: center;
  height: 34px;
}

.navbar-brand:hover {
  opacity: 0.9;
}

.navbar-toggler {
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  background-color: transparent;
  color: var(--text-primary);
}

.navbar-toggler:focus {
  outline: none;
  box-shadow: none;
  border-color: var(--hyperliquid-green);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(240, 240, 240, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar-nav {
  display: flex;
  flex-direction: row;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: nowrap;
}

.navbar .nav-link {
  color: var(--text-primary) !important;
  padding: 1.0rem 1.25rem;
  padding-right: 1.0rem !important;
  padding-left: 1.0rem !important;
  margin: 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  letter-spacing: 0.01em;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 4px;
  background: transparent;
  overflow: hidden;
}

/* Subtle hover background */
.navbar .nav-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: -1;
}

.navbar .nav-link:hover {
  color: var(--hyperliquid-green) !important;
}

.navbar .nav-link:hover::before {
  opacity: 1;
}

/* Remove old underline */
.navbar .nav-link::after {
  display: none;
}

/* Active state - matches login/signup button styling */
.navbar .nav-link.active {
  background: transparent;
  border: 1px solid #00e5af;
  color: var(--hyperliquid-green) !important;
  transform: translateY(0);
}

.navbar .nav-link.active::before {
  opacity: 0;
}

/* Active hover state */
.navbar .nav-link.active:hover {
  background: rgba(0, 229, 175, 0.1);
  border: 1px solid #00e5af;
  transform: translateY(0);
}

.navbar .nav-link i {
  margin-right: 0.5rem;
  font-size: 1rem;
  position: relative;
  top: 1px;
}

/* 6. Components */
/* Badges */
.coming-soon-badge {
  display: inline-flex;
  align-items: center;
  background-color: rgba(0, 229, 175, 0.15);
  color: var(--hyperliquid-green);
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.4rem;
  font-weight: 500;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.5px;
  border: 1px solid rgba(0, 229, 175, 0.2);
}

/* Buttons */
.btn-follow,
.btn-feedback {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.4rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 300;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  letter-spacing: 0.02em;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  height: 34px;
  gap: 0.5rem;
}

.btn-follow:hover {
  background-color: var(--bg-dark);
  color: var(--hyperliquid-green);
  border-color: var(--hyperliquid-green);
}

.btn-feedback:hover {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-feedback i {
  font-size: 0.85rem;
  position: relative;
  top: 0;
}

.timeframe-btn,
.layout-btn {
  padding: 5px 10px;
  border-radius: 4px;
  background-color: var(--bg-dark);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
  line-height: 1;
}

.timeframe-btn:hover,
.timeframe-btn.active,
.layout-btn:hover,
.layout-btn.active {
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.layout-btn.text-muted {
  opacity: 0.5;
}

.layout-btn.active.text-muted {
  opacity: 0.5;
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Charts */
.chart-container {
  height: calc(100vh - 166px);
  overflow: hidden;
  background-color: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.chart-row {
  height: 50%;
  display: flex !important;
  width: 100%;
}

.quad-layout,
.dual-layout,
.single-layout {
  height: 100%;
  width: 100%;
  display: none;
}

.quad-layout {
  display: flex;
  flex-direction: column;
}

.dual-layout.active,
.quad-layout.active,
.single-layout.active {
  display: flex;
  flex-direction: column;
}

.tradingview-widget-container {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.tradingview-widget-container__widget {
  flex: 1;
  min-height: 0;
  height: calc(100% - 32px);
  width: 100%;
}

/* Ensure proper sizing when table is hidden */
.col-lg-12 .chart-container {
  width: 100% !important;
}

/* Market table transitions */
.col-lg-3,
.col-lg-9,
.col-lg-12 {
  transition: all 0.3s ease-in-out;
}

/* Market table animation */
.col-lg-3 {
  opacity: 1;
  transform: translateX(0);
  visibility: visible;
}

.col-lg-3.d-none {
  opacity: 0;
  transform: translateX(100%);
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s linear 0.3s;
}

/* Market Overview */
.market-overview {
  background-color: var(--bg-surface);
  border-radius: 4px;
  border: 1px solid var(--border);
  height: auto;
  min-height: 60px;
  padding: 8px;
}

.market-stat-compact {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
  gap: 4px;
}

.market-stat-compact:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.market-stat-title {
  font-size: 10px;
  color: var(--text-secondary);
}

.market-stat-value {
  font-family: 'Chivo Mono', monospace;
  font-weight: bold;
  margin-right: 4px;
}

.market-stat-change {
  font-size: 9px;
  padding-left: 4px;
  border-left: 1px solid var(--border);
}

.market-stat-change.positive {
  color: var(--green);
}

.market-stat-change.negative {
  color: var(--red);
}

/* Tables */
.table-dark {
  background-color: var(--bg-dark);
}

.table-dark th {
  font-size: 11px;
  background-color: var(--bg-surface) !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text-secondary);
  padding: 4px 12px;
  text-align: left;
}

#cryptoTable {
  width: 100%;
  font-size: 11px;
  margin: 0;
  color: var(--text-primary);
  border-collapse: collapse;
}

#cryptoTable td {
  padding: 2px 12px;
  line-height: 0.5rem;
  white-space: nowrap;
  border: none !important;
  font-size: 11px !important;
  height: 11px !important;
}

/* Alternating row colors */
#cryptoTable tbody tr:nth-child(odd) {
  background-color: var(--bg-dark);
}

#cryptoTable tbody tr:nth-child(even) {
  background-color: var(--bg-surface);
}

#cryptoTable tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Column alignments */
#cryptoTable td:nth-child(1) {
  text-align: left;
}

#cryptoTable td:nth-child(2),
#cryptoTable td:nth-child(3),
#cryptoTable td:nth-child(4) {
  text-align: right;
}

/* Price Colors */
.text-success {
  color: var(--green) !important;
}

.text-danger {
  color: var(--red) !important;
}

/* Highlighted row */
#cryptoTable tr.highlighted {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Significant changes */
#cryptoTable tr.significant-up {
  background-color: rgba(0, 176, 104, 0.1) !important;
}

#cryptoTable tr.significant-down {
  background-color: rgba(234, 57, 67, 0.1) !important;
}

/* Ticker column */
#cryptoTable td.ticker-column {
  color: var(--text-primary);
  cursor: pointer;
}

#cryptoTable td.ticker-column:hover {
  opacity: 0.8;
}

/* Search */
#market-search {
  font-family: 'Chivo Mono', monospace;
  font-size: 11px;
  background-color: var(--bg-dark) !important;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 4px 12px;
  height: 24px;
  border-radius: 4px;
  width: calc(100% - 40px);
}

#market-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
  outline: none;
}

/* 7. Pages */
/* Home Page */
body.home-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.hero-section {
  padding: 2rem 0;
  margin-top: -1rem;
  text-align: center;
  background: var(--bg-dark);
  position: relative;
  z-index: 1;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

.tagline {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.hero-description {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Feature Cards */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  width: 100%;
  margin-bottom: 2rem;
}

.feature-card {
  background-color: rgba(255, 255, 255, 0.05);
  padding: 1.5rem;
  border-radius: 4px;
  transition: transform 0.2s;
}

.feature-card:hover {
  transform: translateY(-5px);
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background-color: rgba(68, 68, 68, 0.1);
  color: var(--accent);
  margin-bottom: 1rem;
}

.feature-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.feature-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Charts Page */
body.charts-page {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden;
}

.control-panel {
  padding: 6px 10px;
  height: auto;
}

.layout-label {
  font-size: 11px;
}

/* Chart Container */
#charts-container {
  height: calc(100vh - 120px);
  width: 100%;
}

/* Layout Styles */
.quad-layout,
.dual-layout,
.single-layout {
  height: 100%;
  width: 100%;
}

.dual-layout,
.single-layout {
  display: none;
}

/* Chart Rows */
.chart-row {
  height: 50%;
  margin: 0 !important;
  padding: 0;
  display: flex !important;
  flex-direction: row !important;
  width: 100%;
}

.single-layout .chart-row {
  height: 100%;
}

.dual-layout .chart-row {
  height: 100%;
}

/* Chart Columns */
.chart-row .col-md-6 {
  height: 100%;
  padding: 0;
  flex: 0 0 50% !important;
  max-width: 50% !important;
  width: 50% !important;
}

.chart-row .col-12 {
  height: 100%;
  padding: 0;
  flex: 0 0 100% !important;
  max-width: 100% !important;
  width: 100% !important;
}

/* Chart Cell */
.chart-cell {
  height: 100%;
}

/* TradingView Container */
.tradingview-widget-container {
  height: 100%;
  width: 100%;
}

.tradingview-widget-container__widget {
  height: 100%;
  width: 100%;
}

/* Table Styles */
.tableWrapper {
  height: calc(100vh - 120px);
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
}

.table-responsive {
  max-height: calc(100vh - 170px);
  overflow-y: auto;
}

.table-header {
  margin-bottom: 0.25rem;
}

.search-container {
  display: flex;
  align-items: center;
  width: 100%;
}

#refresh-table {
  padding: 2px 4px;
  min-width: 22px;
}

/* Mobile Styles */
@media (max-width: 767px) {
  .market-overview {
    margin: 8px !important;
    width: calc(100% - 16px) !important;
  }

  .control-panel {
    display: none !important;
  }

  /* Force proper heights for mobile */
  #charts-container {
    height: 46vh !important;
    overflow: hidden !important;
  }

  .quad-layout,
  .dual-layout,
  .single-layout {
    height: 46vh !important;
    overflow: hidden !important;
  }

  .chart-row {
    flex-direction: column !important;
    height: 46vh !important;
    overflow: hidden !important;
  }

  .chart-cell {
    height: 46vh !important;
    overflow: hidden !important;
  }

  .tradingview-widget-container {
    height: 46vh !important;
    overflow: hidden !important;
  }

  .tradingview-widget-container__widget {
    height: 46vh !important;
    overflow: hidden !important;
  }

  /* Table section */
  .col-lg-3 {
    height: 50vh !important;
  }

  .tableWrapper {
    height: 50vh !important;
  }

  .table-responsive {
    max-height: calc(50vh - 40px) !important;
  }

  /* Layout adjustments */
  .row {
    flex-direction: column !important;
  }

  .col-lg-9,
  .col-lg-3 {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  .chart-row .col-md-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 46vh !important;
    overflow: hidden !important;
  }

  /* Ensure TradingView iframe is contained */
  .tradingview-widget-container iframe {
    height: 46vh !important;
    max-height: 46vh !important;
    overflow: hidden !important;
  }

  .navbar {
    flex-wrap: nowrap !important;
    padding: 0.4rem 1rem !important;
  }

  .navbar-brand {
    font-size: 1.2rem;
    margin-right: 1rem;
  }

  .navbar-nav {
    flex-direction: row !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 5px;
    margin-right: 1rem;
  }

  .navbar-nav::-webkit-scrollbar {
    display: none;
  }

  .navbar .nav-link {
    white-space: nowrap;
    padding: 0.5rem 1rem !important;
    font-size: 0.9rem !important;
    border-radius: 4px;
  }

  /* Tablet active state */
  .navbar .nav-link.active {
    background: transparent;
    border: 1px solid #00e5af;
    transform: translateY(0);
  }

  .btn-follow {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
  }

  .coming-soon-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
  }

  .dual-layout .chart-row,
  .dual-layout .col-md-6 {
    height: 48vh !important;
  }

  .tableWrapper .table-responsive {
    padding: 0;
    -webkit-overflow-scrolling: touch;
  }

  #cryptoTable thead {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  #cryptoTable th {
    padding: 6px 4px;
  }
}

@media (max-width: 991px) {
  .navbar {
    padding: 0.4rem 1rem;
  }

  .navbar-brand {
    font-size: 1.2rem;
    margin-right: 0;
  }

  .navbar-collapse {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    transition: all 0.3s ease-in-out;
  }

  .navbar-nav {
    flex-direction: column !important;
    width: 100%;
  }

  .nav-item {
    margin: 0.5rem 0;
    width: 100%;
  }

  .navbar .nav-link {
    padding: 0.75rem 1rem;
    width: 100%;
    display: flex;
    align-items: center;
    height: auto;
    border-radius: 10px;
    margin: 0.25rem 0;
  }

  /* Mobile active state */
  .navbar .nav-link.active {
    background: transparent;
    border: 1px solid #00e5af;
    transform: none;
  }

  .dropdown-menu {
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    margin-top: 0.5rem;
    position: static !important;
    float: none;
    width: 100%;
    padding: 0.5rem 0;
  }

  .dropdown-item {
    color: var(--text-primary);
    padding: 0.5rem 1rem;
  }

  .dropdown-item:hover {
    background-color: var(--accent);
    color: white;
  }

  .coming-soon-badge {
    margin-left: auto;
  }
}

@media (max-width: 768px) {
  .hero-section {
    padding: 1.5rem 0;
    margin-top: -0.5rem;
  }

  .tagline {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
  }

  .hero-description {
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }
}

/* Ranking and Direction Styles */
.rank-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--hyperliquid-green);
  color: #000;
  font-size: 11px;
  font-weight: 600;
  margin-right: 8px;
  font-family: 'Chivo Mono', monospace;
  padding: 0 6px;
}

.rank-1 {
  background: #00e5af;
}

.rank-2 {
  background: #00d0a0;
}

.rank-3 {
  background: #00c090;
}

.rank-4,
.rank-5 {
  background: #00b080;
  opacity: 0.8;
}

.direction-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.direction-buy {
  color: var(--green);
  font-weight: 500;
}

.direction-sell {
  color: var(--red);
  font-weight: 500;
}

.direction-arrow {
  color: var(--text-secondary);
  font-size: 10px;
  margin: 0 4px;
}

.opportunity-exchanges {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.opportunity-exchanges .exchange-logo {
  width: 12px;
  height: 12px;
  object-fit: contain;
}

.opportunity-direction {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* PWA Install Banner */
.pwa-install-banner {
  display: none;
  /* Hidden by default */
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(26, 26, 26, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f0f0f0;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  gap: 15px;
  font-size: 14px;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.pwa-install-banner.show {
  display: flex;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pwa-install-button {
  background-color: #000;
  color: #fff;
  border: 1px solid #444;
  border-radius: 5px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  transition: background-color 0.2s, transform 0.2s;
}

.pwa-install-button:hover {
  background-color: #111;
  transform: translateY(-1px);
}

.pwa-close-button {
  background: none;
  border: none;
  color: #888;
  font-size: 22px;
  cursor: pointer;
  padding: 0 5px;
  line-height: 1;
  transition: color 0.2s;
}

.pwa-close-button:hover {
  color: #fff;
}

@media (max-width: 768px) {
  .pwa-install-banner {
    width: auto;
    max-width: calc(100% - 20px);
    bottom: 10px;
    left: 10px;
    right: auto;
    padding: 8px 10px;
    font-size: 13px;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
  }

  .pwa-install-banner.show {
    transform: none;
  }

  .pwa-install-button {
    padding: 5px 10px;
    font-size: 12px;
  }
}