@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;700;800&family=Fira+Code:wght@400;500&display=swap');

:root {
  --bg-primary: #050505;
  --bg-secondary: #111111;
  --glass-bg: rgba(20, 20, 22, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-warning: #f59e0b;
  --glow-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

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

body {
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  background: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(6, 182, 212, 0.08) 0%, transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 20px;
}

.header {
  text-align: center;
  margin-bottom: 50px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.cyber-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 2.75rem;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}

/* Glassmorphism Cards */
.terminal,
.loading,
.response-section,
.login-box {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  padding: 35px;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 25px;
  margin-bottom: 30px;
}

.form-group {
  position: relative;
}

.input-label {
  position: absolute;
  top: -10px;
  left: 15px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, var(--bg-primary) 50%, #151517 50%);
  padding: 0 8px;
  color: var(--text-muted);
  border-radius: 4px;
  z-index: 2;
}

input, select, .account-dropdown {
  width: 100%;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  transition: all 0.3s ease;
}

input:focus, select:focus, .account-dropdown:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

/* Execute Button */
.execute-btn, .btn-small, #startBtn, #stopBtn {
  width: 100%;
  padding: 18px;
  border: none;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #fff;
  border-radius: 12px;
  margin-top: 15px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.execute-btn:hover, .btn-small:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
  filter: brightness(1.1);
}

.execute-btn:active, .btn-small:active {
  transform: translateY(1px);
}

/* Loading */
.loading {
  display: none;
  text-align: center;
  padding: 40px;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid var(--accent-blue);
  border-right: 4px solid var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

.loading p {
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 1px;
  animation: pulse 2s infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.6; } }

/* Response Section UI */
.response-section {
  display: none;
  margin-top: 40px;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  padding: 0;
  overflow: hidden;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid var(--glass-border);
}

.response-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.response-header h3::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
}

.status-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

/* Beautiful JSON Response */
pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Fira Code', monospace;
  background: transparent;
  padding: 24px;
  line-height: 1.6;
  font-size: 0.95rem;
  max-height: 500px;
  overflow-y: auto;
  color: #d1d5db;
}

pre::-webkit-scrollbar { width: 8px; }
pre::-webkit-scrollbar-track { background: transparent; }
pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
pre::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.json-key { color: #7dd3fc; font-weight: 500; }
.json-string { color: #a7f3d0; }
.json-number { color: #fde68a; }
.json-boolean { color: #f9a8d4; }
.json-null { color: #94a3b8; font-style: italic; }

/* Nice Table */
/* Nice Table */
.nice-table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 10px; 
}

.nice-table th, .nice-table td { 
    padding: 12px 15px; 
    text-align: left; 
    border-bottom: 1px solid var(--glass-border); 
    font-size: 0.9rem; 
    white-space: nowrap; /* Prevents text and decimals from breaking */
}

.nice-table th { 
    font-family: 'Outfit'; 
    color: var(--text-muted); 
    font-weight: 600; 
    background: rgba(0,0,0,0.3); 
}
.nice-table td { color: #d1d5db; }
.nice-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.text-buy { color: var(--accent-green) !important; font-weight: 600; }
.text-sell { color: var(--accent-red) !important; font-weight: 600; }
.header-action { position: absolute; top: 30px; right: 40px; }

/* Action Buttons */
.quick-buttons, .transaction-buttons {
  margin-bottom: 40px;
  text-align: left;
}

.quick-buttons h3, .transaction-buttons h3 {
  margin-bottom: 20px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: #fff;
  font-size: 1.25rem;
}

.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.quick-btn, .transaction-btn {
  padding: 12px 24px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  color: #e5e7eb;
  border-radius: 10px;
  transition: all 0.2s ease;
  backdrop-filter: blur(5px);
}

.quick-btn {
  border-left: 3px solid var(--accent-blue);
}

.transaction-btn {
  border-left: 3px solid var(--accent-warning);
}

.quick-btn:hover, .transaction-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Specific Colors overrides logic hook retained */
button[data-api^="buy_"] { border-left-color: var(--accent-green); }
button[data-api^="sell_"] { border-left-color: var(--accent-red); }

button[data-api="cancel_order"], 
button[data-api="cancel_all_order"] {
  border-left-color: var(--accent-red);
}

.active-btn, 
.quick-btn:focus, 
.transaction-btn:focus,
.quick-btn.clicked,
.transaction-btn.clicked {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-left-width: 3px !important;
  box-shadow: 0 4px 15px rgba(255,255,255,0.1), 0 0 15px rgba(56, 189, 248, 0.5);
  color: #fff;
  transform: scale(1.05);
  z-index: 10;
  position: relative;
  filter: brightness(1.2);
}

/* Header Action */
.header .quick-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-decoration: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  border: 1px solid rgba(255,255,255,0.1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.header .quick-btn:hover { background: rgba(255,255,255,0.15); transform: translateY(-50%) scale(1.05); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: #111;
  border: 1px solid var(--accent-red);
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.05);
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon { font-size: 3.5rem; margin-bottom: 15px; }
.modal-content h3 { color: var(--accent-red); margin-bottom: 15px; font-family: 'Outfit'; font-size: 1.5rem; }
.modal-content p { color: var(--text-muted); margin-bottom: 30px; line-height: 1.6; }

.modal-actions { display: flex; gap: 15px; justify-content: center; }
.modal-btn {
  padding: 14px 28px; border: none; border-radius: 10px;
  cursor: pointer; font-weight: 600; font-family: 'Inter'; font-size: 1rem;
  transition: all 0.2s;
}
.modal-btn.cancel { background: rgba(255,255,255,0.1); color: #fff; }
.modal-btn.confirm { background: var(--accent-red); color: #fff; box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3); }
.modal-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }

/* Copy Icon */
.copy-icon-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 10px;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.copy-icon-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.1); transform: scale(1.05); }
.copy-icon-btn:active { background: var(--accent-green); color: #000; border-color: var(--accent-green); transform: scale(0.95); }

/* Login overrides */
.login-box {
  width: 100%;
  max-width: 440px;
  margin: auto;
  border: 1px solid rgba(255,255,255,0.05);
  background: var(--glass-bg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}
.login-box h2 {
  font-family: 'Outfit';
  font-weight: 700;
  font-size: 2rem;
  margin-bottom: 30px;
  color: #fff;
  text-align: center;
}
.login-box .input-group { margin-bottom: 20px; }
.login-box button { width: 100%; padding: 16px; border-radius: 12px; margin-top: 10px; }
.login-box .forgot { color: var(--text-muted); margin-top: 20px; display: block; text-align: center; font-size: 0.9rem; transition: color 0.2s; text-decoration: none;}
.login-box .forgot:hover { color: #fff; text-decoration: underline; }

/* Responsive adjustments */
@media (max-width: 768px) {
  .header { flex-direction: column; gap: 20px; margin-bottom: 30px; }
  .header-action { position: relative; right: auto; top: auto; transform: none; }
  .header .quick-btn { position: relative; right: auto; top: auto; transform: none; }
  .cyber-logo { font-size: 2rem; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Form Error Styles */
.error-message { 
  color: #ef4444; 
  font-size: 0.75rem; 
  margin-top: 8px; 
  display: none; 
  font-weight: 600; 
  text-transform: uppercase; 
  position: absolute; 
  bottom: -20px; 
  left: 5px;
}
.input-error { 
  border-color: #ef4444 !important; 
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

/* Fix for the white-on-white dropdown issue */
select.account-dropdown option {
    background-color: #1e293b; /* A nice dark slate color */
    color: #ffffff;            /* Keep the text white */
}

/* Optional: Ensure the main select box itself also stays dark */
select.account-dropdown {
    background-color: #0f172a; 
    color: #ffffff;
}

/* Calendar Icon Invert for dark theme */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

@media (max-width: 1024px) {
    .nice-table thead { display: none; }
    
    .nice-table, .nice-table tbody, .nice-table tr, .nice-table td {
        display: block; width: 100%;
    }
    
    .nice-table tr {
        margin-bottom: 20px;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 16px; padding: 12px;
    }
    
    .nice-table td {
        display: flex; justify-content: space-between; align-items: center;
        text-align: right; padding: 10px 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        white-space: nowrap;
    }
    
    .nice-table td:last-child { border-bottom: none; }
    
    /* This is the part that pulls the data-label from your JS */
    .nice-table td::before {
        content: attr(data-label);
        font-weight: 600; color: var(--text-muted);
        text-align: left; margin-right: 15px;
        font-family: 'Outfit', sans-serif; font-size: 0.85rem;
    }
}