*,
*::before,
*::after {
  box-sizing: border-box;
}

iframe[src*='websim'],
[id*='websim-badge'],
[class*='websim-badge'],
websim-badge,
body > div:has(a[href*='websim.com']),
a[href*='websim.com'] {
  display: none !important;
  visibility: hidden !important;
}

body {
  font-family: Arial, sans-serif;
  /* background-color: #e0f2f7; */ /* Old blue color */
  background-color: #e6e0f7; /* New purple color */
  margin: 0;
  padding: 0;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  width: min(800px, calc(100% - 24px));
  max-width: 800px;
  min-width: 0;
  margin: 12px auto;
}

h1, h2 {
  text-align: center;
  /* color: #333; */ /* Default dark grey */
  color: #4a148c; /* Darker purple for headings */
}

.ai-hero-wrapper {
  margin: 10px auto 20px auto;
  max-width: 720px;
  border-radius: 12px;
  overflow: visible;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  background: radial-gradient(circle at top left, #f3e5f5, #ede7f6 40%, #ffffff 80%);
}

#ai-hero {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

#settings, #status, #tradingLog, #deployment-info, #admin-panel {
  margin-bottom: 20px;
}

.panel {
    border: 1px solid #e1bee7;
    padding: 15px;
    border-radius: 8px;
    background-color: #fafafa;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #6a1b9a; /* Medium purple for labels */
}

input[type="text"],
input[type="number"], select {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ab47bc; /* Lighter purple border */
  border-radius: 4px;
  box-sizing: border-box;
}

button {
  /* background-color: #4CAF50; */ /* Old green */
  background-color: #7b1fa2; /* Primary purple */
  color: white;
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 10px;
  margin-bottom: 5px;
}

button:hover {
  /* background-color: #3e8e41; */ /* Darker green */
  background-color: #6a1b9a; /* Darker purple on hover */
}

/* Specific button colors if needed */
#stopRobot {
    background-color: #d32f2f; /* Red for stop */
}
#stopRobot:hover {
    background-color: #b71c1c; /* Darker red on hover */
}


#status {
  margin-bottom: 20px;
  text-align: center;
}

#performance-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
  border-color: #d9e2df;
  background: #f5f8f6;
}
.metric { display: grid; gap: 6px; }
.metric span { color: #58655f; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.metric strong { color: #172b24; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
#metricDailyPnl.negative { color: #b3261e; }
#riskGuardStatus, #sessionGuardStatus { grid-column: 1 / -1; margin: 0; color: #58655f; font-size: 0.88rem; }
.session-limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.session-limits input { width: 100%; }
.settings-note { color: #58655f; font-size: 0.85rem; line-height: 1.45; }
.recovery-control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 12px; }
.recovery-control button { margin: 0; }
#recoveryModeButton[aria-pressed="true"] { background-color: #2e7d32; }
#recoveryModeStatus { color: #58655f; font-size: 0.85rem; }

@media (max-width: 560px) {
  .container { width: auto; max-width: none; margin: 12px; padding: 16px; }
  #performance-dashboard { gap: 8px; padding: 12px; }
  .session-limits { grid-template-columns: 1fr; gap: 0; }
  .metric strong { font-size: 1rem; }
}

#ai-learning-panel, #deployment-info {
    display: none; /* Hide by default */
}

#ai-learning-panel {
    border: 1px dashed #6a1b9a;
    background-color: #f3e5f5;
}

#ai-learning-panel summary {
  cursor: pointer;
  font-weight: bold;
  color: #4a148c;
  padding: 5px 0;
}

#ai-learning-panel pre {
    background-color: #fff;
    border: 1px solid #e1bee7;
    padding: 10px;
    border-radius: 4px;
    max-height: 300px;
    overflow: auto;
    font-size: 0.85em;
    white-space: pre-wrap;
    word-break: break-all;
}

#tradingLog {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  border: 1px solid #ab47bc; /* Lighter purple border */
  padding: 10px;
  border-radius: 4px;
  max-height: 300px;
  overflow-y: auto;
  background-color: #fff; /* White background for log area */
}

#logList {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

#logList li {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 5px 0;
  border-bottom: 1px solid #e1bee7; /* Very light purple separator */
  font-size: 0.9em;
  color: #333; /* Keep log text readable */
}

#logList li:last-child {
  border-bottom: none;
}

#derivConnectionStatus {
    font-weight: bold;
    margin-left: 10px;
    /* Color set dynamically via JS */
}

#deployment-info {
  margin-top: 25px;
  padding: 15px;
  border: 1px dashed #6a1b9a;
  border-radius: 8px;
  background-color: #f3e5f5;
}

#deployment-info h2 {
    margin-top: 0;
    font-size: 1.2em;
}

#deployment-info summary {
  cursor: pointer;
  font-weight: bold;
  color: #4a148c;
  padding-bottom: 5px;
}

#deployment-info p {
  margin-top: 10px;
  line-height: 1.5;
  color: #333;
}

/* --- New Auth and UI Styles --- */

#auth-container {
    text-align: center;
    border: 1px solid #ab47bc;
    padding: 20px;
    border-radius: 8px;
    background-color: #f3e5f5;
}

#auth-container label {
    margin-top: 10px;
}

#authStatus {
    margin-top: 15px;
    font-weight: bold;
    color: #d32f2f; /* Red for error messages */
}

.security-note {
    margin-top: 20px;
    font-size: 0.8em;
    color: #6a1b9a;
    border-top: 1px dashed #ce93d8;
    padding-top: 10px;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #f3e5f5;
    border-radius: 8px;
    margin-bottom: 20px;
}

#welcome-message {
    font-weight: bold;
    color: #4a148c;
    margin: 0;
}

#logoutButton {
    background-color: #6a1b9a;
}
#logoutButton:hover {
    background-color: #4a148c;
}

#admin-panel h2 {
    margin-top: 0;
}

.admin-section {
    border-top: 2px solid #e1bee7;
    margin-top: 20px;
    padding-top: 20px;
}
.admin-section:first-of-type {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}
.admin-section h3 {
    margin-top: 0;
    color: #6a1b9a;
}

#generatedCodeOutput {
    width: 100%;
    margin-top: 10px;
    background-color: #e1bee7;
    color: #333;
    font-weight: bold;
    text-align: center;
}

#user-code-list-container, #admin-activity-log-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ce93d8;
    border-radius: 4px;
    padding: 10px;
    background-color: #fff;
}

#userCodeList, #adminActivityLogList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#userCodeList li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 5px;
    border-bottom: 1px solid #f3e5f5;
    flex-wrap: wrap;
}

#adminActivityLogList li {
    padding: 5px 0;
    border-bottom: 1px solid #e1bee7; /* Very light purple separator */
    font-size: 0.9em;
    color: #333;
}

#userCodeList li:last-child {
    border-bottom: none;
}

.code-value {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    flex-basis: 35%;
    word-break: break-all;
}

.code-linked-status {
    font-style: italic;
    color: #666;
    flex-basis: 20%;
    text-align: center;
    font-size: 0.9em;
}

.code-status {
    font-weight: bold;
    flex-basis: 20%;
    text-align: center;
}

.code-status.active {
    color: #4CAF50; /* Green */
}

.code-status.inactive {
    color: #d32f2f; /* Red */
}

.code-actions {
    flex-basis: 20%;
    text-align: right;
}

.code-actions button {
    padding: 5px 10px;
    font-size: 0.9em;
    margin: 0;
}

.code-actions .revoke-btn {
    background-color: #f44336;
}
.code-actions .revoke-btn:hover {
    background-color: #d32f2f;
}

.code-actions .activate-btn {
    background-color: #4CAF50;
}
.code-actions .activate-btn:hover {
    background-color: #388e3c;
}

.code-actions .delete-btn {
    background-color: #9e9e9e;
    margin-left: 5px;
}
.code-actions .delete-btn:hover {
    background-color: #757575;
}