/*
Theme Name: محلل الكريبتو
Theme URI: https://example.com/crypto-analyzer
Author: Crypto Analyzer MVP
Author URI: https://example.com
Description: قالب ووردبريس عربي لتحليل العملات الرقمية - شموع تفاعلية، مناطق دخول وأهداف ووقف خسارة، تحليل فني، أخبار، وذكاء اصطناعي. أداة مساعدة فقط وليست نصيحة مالية.
Version: 1.6.0
Requires at least: 5.8
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: crypto-analyzer
Tags: rtl-language-support, custom-menu, one-column
*/

/* ===== Base ===== */
:root {
  --bg: #0B0E11;
  --bg-card: #161A1E;
  --bg-input: #1E2329;
  --border: #2B3139;
  --text: #EAECEF;
  --muted: #848E9C;
  --yellow: #F0B90B;
  --green: #0ECB81;
  --red: #F6465D;
}

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

body.crypto-analyzer-theme {
  background: var(--bg);
  color: var(--text);
  font-family: "Tajawal", "Cairo", Arial, sans-serif;
  direction: rtl;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--yellow); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.ca-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 16px;
}

.ca-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ca-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ca-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--yellow);
  color: #000;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.ca-logo h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.ca-logo p {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}

.ca-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ca-select, .ca-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.2s;
}

.ca-select:focus, .ca-btn:hover {
  border-color: var(--yellow);
  outline: none;
}

.ca-btn-primary {
  background: var(--yellow);
  color: #000;
  font-weight: 600;
  border: none;
}

.ca-btn-primary:hover {
  background: #d4a50a;
}

.ca-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ca-intervals {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.ca-intervals { flex-wrap: wrap; }
.ca-intervals button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.ca-intervals button.active {
  background: var(--yellow);
  color: #000;
  font-weight: 600;
}

/* Disclaimer */
.ca-disclaimer {
  background: #1a1a00;
  border-bottom: 1px solid rgba(240, 185, 11, 0.3);
  text-align: center;
  padding: 8px 16px;
  font-size: 12px;
  color: #f5e6a3;
}

/* Main */
.ca-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 992px) {
  .ca-main {
    grid-template-columns: 2fr 1fr;
  }
}

.ca-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.ca-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--yellow);
  margin-bottom: 12px;
}

/* Chart */
.ca-chart-wrap {
  width: 100%;
  height: 460px;
  position: relative;
}

.ca-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.ca-price {
  font-family: monospace;
  font-size: 18px;
  color: var(--yellow);
  font-weight: 600;
}

.ca-trend {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
}

.ca-trend-up { background: rgba(14, 203, 129, 0.15); color: var(--green); }
.ca-trend-down { background: rgba(246, 70, 93, 0.15); color: var(--red); }
.ca-trend-side { background: #2a2e35; color: var(--muted); }

/* Zones grid */
.ca-zones {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.ca-zone-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
}

.ca-zone-item .label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.ca-zone-item .value {
  font-family: monospace;
  font-size: 14px;
  font-weight: 600;
}

.ca-zone-item .value.green { color: var(--green); }
.ca-zone-item .value.red { color: var(--red); }
.ca-zone-item .value.yellow { color: var(--yellow); }

/* TA rows */
.ca-ta-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.ca-ta-row:last-child { border-bottom: none; }
.ca-ta-row .label { color: var(--muted); }
.ca-ta-row .value { font-family: monospace; }

/* Patterns */
.ca-patterns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ca-pattern {
  background: var(--bg);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
}

/* AI box */
.ca-ai-box {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  min-height: 140px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.ca-ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

/* News */
.ca-news-item {
  display: block;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  transition: 0.2s;
}

.ca-news-item:hover { color: var(--yellow); }
.ca-news-item:last-child { border-bottom: none; }
.ca-news-source {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* Loading */
.ca-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: ca-spin 0.8s linear infinite;
  margin: 40px auto;
}

@keyframes ca-spin {
  to { transform: rotate(360deg); }
}

.ca-loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 460px;
}

/* Footer */
.ca-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

/* Admin notice */
.ca-admin-notice {
  background: #1a1a00;
  border: 1px solid var(--yellow);
  color: #f5e6a3;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px;
  font-size: 13px;
}

/* ===== إحصائيات الصفقات (جديد v1.3) ===== */
.ca-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .ca-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ca-stat-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 8px;
  text-align: center;
  border: 1px solid var(--border);
}

.ca-stat-num {
  font-size: 22px;
  font-weight: 700;
  font-family: monospace;
  margin-bottom: 2px;
}

.ca-stat-label {
  font-size: 11px;
  color: var(--muted);
}

.ca-stat-win .ca-stat-num { color: var(--green); }
.ca-stat-loss .ca-stat-num { color: var(--red); }
.ca-stat-open .ca-stat-num { color: var(--yellow); }
.ca-stat-rate .ca-stat-num { color: #60a5fa; }

.ca-high-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--yellow);
  margin: 12px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.ca-trades-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ca-trade-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.ca-trade-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.ca-trade-symbol {
  font-weight: 600;
  font-size: 13px;
}

.ca-trade-dir {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.ca-trade-dir.buy {
  background: rgba(14, 203, 129, 0.15);
  color: var(--green);
}

.ca-trade-dir.sell {
  background: rgba(246, 70, 93, 0.15);
  color: var(--red);
}

.ca-trade-conf {
  margin-right: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
}

.ca-trade-prices {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
  margin-bottom: 4px;
}

.ca-trade-status {
  font-size: 11px;
  font-weight: 600;
}

.ca-trade-status.status-open { color: var(--yellow); }
.ca-trade-status.status-win { color: var(--green); }
.ca-trade-status.status-loss { color: var(--red); }

.ca-empty-trades {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  background: var(--bg);
  border-radius: 8px;
}

.ca-empty-trades small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
}

/* ===== قائمة الصفقات المفتوحة (v1.5) ===== */
.ca-open-trades-dropdown {
  position: relative;
}

.ca-btn-open-trades {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
}

.ca-btn-open-trades:hover,
.ca-btn-open-trades[aria-expanded="true"] {
  border-color: var(--yellow);
}

.ca-open-count {
  background: var(--yellow);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.ca-dropdown-arrow {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s;
}

.ca-btn-open-trades[aria-expanded="true"] .ca-dropdown-arrow {
  transform: rotate(180deg);
}

.ca-open-trades-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  max-width: 340px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 200;
  padding: 6px;
}

.ca-open-empty {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.ca-open-trade-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: right;
  transition: background 0.15s;
}

.ca-open-trade-item:hover {
  background: var(--bg-input);
}

.ca-oti-symbol {
  font-weight: 600;
  flex: 1;
}

.ca-oti-dir {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.ca-oti-dir.buy {
  background: rgba(14, 203, 129, 0.15);
  color: var(--green);
}

.ca-oti-dir.sell {
  background: rgba(246, 70, 93, 0.15);
  color: var(--red);
}

.ca-oti-conf {
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  font-family: monospace;
}

/* لوحة تفاصيل الصفقة */
.ca-trade-detail-panel {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 8px;
}

.ca-trade-detail-inner {
  background: var(--bg-card);
  border: 1px solid var(--yellow);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(240, 185, 11, 0.12);
}

.ca-trade-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ca-trade-detail-header strong {
  color: var(--yellow);
  font-size: 15px;
}

.ca-td-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.ca-td-close:hover {
  color: var(--text);
}

.ca-td-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.ca-td-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
}

.ca-td-item .label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.ca-td-item .value {
  font-family: monospace;
  font-size: 14px;
  font-weight: 600;
}

.ca-td-item .value.green { color: var(--green); }
.ca-td-item .value.red { color: var(--red); }
.ca-td-item .value.yellow { color: var(--yellow); }

.ca-td-full {
  grid-column: 1 / -1;
}

.ca-td-notes {
  font-weight: 400 !important;
  font-size: 12px !important;
  font-family: inherit !important;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 600px) {
  .ca-open-trades-menu {
    left: auto;
    right: 0;
    min-width: 260px;
  }
}


/* ===== مزامنة + تحميل على الشارت (v1.6) ===== */
.ca-oti-prox {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.ca-oti-prox.prox-tp {
  background: rgba(14, 203, 129, 0.18);
  color: var(--green);
}
.ca-oti-prox.prox-sl {
  background: rgba(246, 70, 93, 0.18);
  color: var(--red);
}
.prox-tp { color: var(--green) !important; }
.prox-sl { color: var(--red) !important; }

.ca-td-actions {
  margin-top: 12px;
}

.ca-sync-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--yellow);
  color: var(--text);
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  z-index: 9999;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 90vw;
  text-align: center;
}
.ca-sync-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ca-sync-toast strong {
  color: var(--yellow);
}
