/* YouTube Widget */
.youtube-widget {
    position: fixed;
    top: 100px;
    left: 20px;
    width: 360px;
    height: 360px;
    background: #1e1e1e;
    border: 1px solid var(--gold-primary);
    border-radius: 8px;
    z-index: 10001; /* Above chat widget */
    box-shadow: 0 5px 20px rgba(0,0,0,0.7);
    display: none; /* Hidden by default */
    flex-direction: column;
    overflow: hidden;
    resize: both; /* Allow resizing */
    min-width: 300px;
    min-height: 40px;
}

[dir="rtl"] .youtube-widget {
    left: auto;
    right: 20px;
}

.youtube-widget.minimized {
    resize: none;
    height: auto !important;
}

.youtube-header {
    padding: 8px 12px;
    background: linear-gradient(45deg, #000, #333);
    color: var(--gold-primary);
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
    user-select: none;
}

.youtube-title {
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.youtube-controls i {
    cursor: pointer;
    margin-left: 10px;
    color: #888;
    transition: color 0.2s;
    font-size: 0.9rem;
}

[dir="rtl"] .youtube-controls i {
    margin-left: 0;
    margin-right: 10px;
}

.youtube-controls i:hover {
    color: #fff;
}

.youtube-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
}

.youtube-search {
    display: flex;
    padding: 8px;
    background: #1e1e1e;
    border-bottom: 1px solid #333;
}

.youtube-search input {
    flex: 1;
    background: #333;
    border: 1px solid #444;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    outline: none;
}

.youtube-search input:focus {
    border-color: var(--gold-primary);
}

.youtube-search button {
    background: var(--gold-primary);
    border: none;
    color: #000;
    padding: 4px 12px;
    border-radius: 4px;
    margin-left: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.youtube-search button:hover {
    background: #fff;
}

[dir="rtl"] .youtube-search button {
    margin-left: 0;
    margin-right: 5px;
}

.youtube-iframe-container {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

.youtube-iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

:root {
  --market-up: #0ecb81;
  --market-down: #f6465d;
  --market-card-bg: #1e222d;
  --market-border: #2b3139;
  --market-text: #848e9c;
  --market-hover: #2b3139;
}

/* 1. Global "Native" Feel - Optimized */
* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

/* Performance optimization for interactive elements */
.btn, button, a.btn, .market-card {
  will-change: transform;
}

/* 3. Interactive Feedback (Button Press) - Optimized */
.btn, button, a.btn {
  transition: transform 0.1s ease, opacity 0.1s ease;
}

.btn:active, button:active, a.btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .btn, button, a.btn {
    transition-duration: 0.01ms !important;
  }
}

/* 4. Input Fields Exceptions */
input, textarea {
  /* Allow text selection in inputs */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  
  /* Restore context menu for copy/paste */
  -webkit-touch-callout: default;
}

/* Fix for 100vh on mobile browsers */
.full-height {
  height: 100vh;
  height: -webkit-fill-available;
}

/* --- Market Specific Styles - Consolidated --- */
.market-ticker-container {
    background: #0b0e11;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    padding: 8px 0;
    border-bottom: 1px solid var(--market-border);
}

.market-ticker-track {
    display: inline-block;
    animation: ticker 150s linear infinite;
}

@keyframes ticker {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

@media (max-width: 576px) {
  .market-ticker-track {
    animation-duration: 190s;
  }
}

.ticker-item {
    display: inline-block;
    padding: 0 20px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
}

.ticker-up { color: var(--market-up); }
.ticker-down { color: var(--market-down); }

.market-card {
    background: var(--market-card-bg);
    border: 1px solid var(--market-border);
    border-radius: 8px;
    margin-bottom: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.market-card:active {
    transform: scale(0.98);
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.market-card-header {
    padding: 15px;
    border-bottom: 1px solid var(--market-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.market-card-body {
    padding: 15px;
}

.market-price-large {
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Roboto Mono', monospace;
}

.btn-buy {
    background-color: var(--market-up);
    color: #fff;
    border: none;
    font-weight: bold;
}
.btn-sell {
    background-color: var(--market-down);
    color: #fff;
    border: none;
    font-weight: bold;
}

/* Order Book Styling */
.order-book-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 8px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
    cursor: pointer;
}
.order-book-row:hover {
    background-color: var(--market-hover);
}

/* Neon Text for Portfolio */
.text-neon-gold {
    color: var(--gold-primary, #ffd700);
    text-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
}

/* Utility Classes */
.text-up { color: var(--market-up) !important; }
.text-down { color: var(--market-down) !important; }

.nav-tabs-dark .nav-link {
    color: var(--market-text);
    border: none;
    border-bottom: 2px solid transparent;
}
.nav-tabs-dark .nav-link.active {
    color: var(--gold-primary, #ffd700);
    background: transparent;
    border-bottom: 2px solid var(--gold-primary, #ffd700);
}
.nav-tabs-dark .nav-link:hover {
    color: #fff;
    border-color: transparent;
}

.h-40vh-rel {
    height: 40vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

.form-control-dark {
    background-color: #2b3139;
    border: 1px solid #2b3139;
    color: #fff;
}
.form-control-dark:focus {
    background-color: #2b3139;
    border-color: var(--gold-color);
    color: #fff;
    box-shadow: none;
}

.market-asset-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #2b3139;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: var(--market-card-bg);
  margin-left: 10px; /* RTL aware if needed */
}

/* News Ticker Styles */
.news-ticker-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: #000;
    border-top: 1px solid var(--gold-primary);
    z-index: 9998; /* Below chat widget */
    display: flex;
    align-items: center;
    color: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
}

.news-ticker-label {
    background: var(--gold-primary);
    color: #000;
    height: 100%;
    padding: 0 15px;
    display: flex;
    align-items: center;
    font-weight: bold;
    z-index: 2;
    font-family: 'Cairo', sans-serif;
    white-space: nowrap;
}

.news-ticker-content {
    flex: 1;
    overflow: hidden;
    height: 100%;
    position: relative;
    background: rgba(0,0,0,0.8);
}

.news-ticker-move {
    display: flex;
    align-items: center;
    height: 100%;
    white-space: nowrap;
    position: absolute;
    animation: ticker-move 30s linear infinite;
}

.news-ticker-item {
    display: inline-flex;
    align-items: center;
    padding: 0 30px;
    color: #fff;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
}

.news-ticker-item i {
    margin: 0 8px; /* Space between icon and text */
}

@keyframes ticker-move {
    0% { transform: translateX(100vw); }
    100% { transform: translateX(-100%); }
}

/* RTL Support for News Ticker */
[dir="rtl"] .news-ticker-move {
    animation: ticker-move-rtl 30s linear infinite;
    flex-direction: row-reverse; /* Ensure items flow correctly if needed */
}

@keyframes ticker-move-rtl {
    0% { transform: translateX(-100vw); }
    100% { transform: translateX(100%); }
}

/* Adjust PWA Install Button */
#pwa-install-btn {
    bottom: 80px !important;
}

/* YouTube Widget Enhanced */
.youtube-results {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #1a1a1a;
}

.youtube-result-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    transition: background 0.2s;
}

.youtube-result-item:hover {
    background: #2a2a2a;
}

.youtube-result-thumb {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.youtube-result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.youtube-result-title {
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.youtube-result-channel {
    font-size: 0.75rem;
    color: #aaa;
}

.youtube-player-view {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.youtube-back-bar {
    padding: 5px 10px;
    background: #222;
    border-bottom: 1px solid #333;
    text-align: right; /* RTL friendly */
}

/* Scrollbar for results */
.youtube-results::-webkit-scrollbar {
    width: 6px;
}

.youtube-results::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}
