/* --- Standalone Theme Variables (Replaces Dependency on Main Hub) --- */
:root {
  /* Core Colors - Dark Cyber Theme */
  --main-bg-color: #0f172a;       
  --bg-secondary: #1e293b;        
  --bg-primary: #0f172a;          
  
  /* Text Colors */
  --text-primary: #f8fafc;        
  --text-secondary: #94a3b8;      
  
  /* Accents */
  --accent: #3b82f6;              
  --accent-transparent: rgba(59, 130, 246, 0.2);
  --border-color: rgba(59, 130, 246, 0.3); 
  
  /* Feedback Colors */
  --error: #ef4444;               
  --success: #22c55e;             
  
  /* Shadows */
  --frosted-glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* --- Base & Helpers --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background-color: var(--main-bg-color); 
  background-image: radial-gradient(circle at 50% 0%, #1e293b 0%, #0f172a 70%); 
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* --- COMPACT Standalone Header (Kept Small to save space) --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem; /* Tight margin to pull content up */
    gap: 0.75rem;
    animation: fadeIn 0.8s ease-out;
}

.app-logo {
    font-size: 1.75rem;
    color: var(--accent);
    filter: drop-shadow(0 0 10px var(--accent-transparent));
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.app-title .divider {
    color: var(--text-secondary);
    margin: 0 0.5rem;
    font-weight: 300;
    opacity: 0.6;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.relative { position: relative; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-4 { margin-right: 1rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.whitespace-nowrap { white-space: nowrap; }
.font-bold { font-weight: 600; }
.flex-col { display: flex; flex-direction: column; }
.flex-grow { flex-grow: 1; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-4 { gap: 1rem; }

/* --- Main Layout (Restored to Original Size) --- */
.container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem 2rem 6rem 2rem; /* Kept top padding slightly smaller for the header */
  display: flex;
  flex-direction: column;
  gap: 1.5rem; /* Restored original gap */
}

.fields-container-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem; /* Restored original padding */
  box-shadow: var(--frosted-glass-shadow);
  backdrop-filter: blur(10px); 
}

.grid { display: grid; gap: 1rem; }
.grid.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* --- Form Elements (Restored to Original Size) --- */
.input-box, .textarea, select {
  width: 100%;
  padding: 12px 15px; /* Restored original padding */
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.95rem; /* Restored font size */
  outline: none;
  transition: all 0.2s ease-in-out;
}
.input-box::placeholder, .textarea::placeholder { color: var(--text-secondary); opacity: 0.7; }
.input-box:focus, .textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-transparent);
}

.textarea-container { position: relative; width: 100%; }
.textarea { 
    min-height: 250px; /* Restored original height */
    resize: vertical; 
    font-family: 'Consolas', 'Monaco', monospace; 
    line-height: 1.4; 
}

/* --- Buttons (Restored to Original Size) --- */
.btn-primary, .btn-secondary, .btn-clear, .btn-remove {
  color: #ffffff;
  font-weight: 500;
  padding: 0.7rem 1.4rem; /* Restored original padding */
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem; /* Restored font size */
}
.btn-primary:hover, .btn-secondary:hover, .btn-clear:hover, .btn-remove:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-primary { background-color: var(--accent); box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5); }

.btn-secondary { background-color: transparent; color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background-color: rgba(59, 130, 246, 0.05); }

.btn-clear, .btn-remove { background-color: var(--error); }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-success { background-color: var(--success) !important; color: #ffffff !important; }

.btn-icon {
  width: 40px; /* Restored size */
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
}
.sample-data-btn-absolute {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 2;
}

/* --- Sections & Lists (Restored to Original Size) --- */
.section-header-box { padding-bottom: 0.75rem; margin-bottom: 0.5rem; }
.section-title {
  font-weight: 600;
  font-size: 1.1rem; /* Restored size */
  color: var(--text-primary);
  display: flex;
  align-items: center;
  width: 100%;
}

.field-count {
  background-color: var(--accent);
  color: #ffffff;
  padding: 0.1rem 0.6rem;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 700;
  margin-left: 0.75rem;
}

.list-box {
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 8px;
  height: 450px; /* Restored height */
  overflow-y: auto;
  background-color: var(--bg-primary);
}

.field-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0.6rem;
  background-color: var(--bg-secondary);
  border-radius: 6px;
  gap: 0.5rem;
  border: 1px solid rgba(255,255,255,0.05);
  transition: background-color 0.2s;
  font-size: 0.95rem;
}
.field-item:hover { background-color: rgba(255,255,255,0.03); }

.edit-icon { cursor: pointer; color: var(--accent); font-size: 1em; margin: 0 0.5rem; opacity: 0.8; }
.edit-icon:hover { color: #ffffff; opacity: 1; }

/* --- Output Box --- */
.output-box {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  height: 400px; /* Restored height */
  overflow: hidden; 
  display: flex;
  position: relative;
}
.line-numbers {
  flex-shrink: 0;
  padding: 1rem 0.8rem;
  text-align: right;
  border-right: 1px solid var(--border-color);
  background-color: #0b1120; 
  color: var(--text-secondary);
  user-select: none;
  font-family: 'Consolas', monospace;
  font-size: 0.9rem;
  overflow: hidden;
}
.line-numbers span { display: block; line-height: 1.5; }
.code-content {
  flex-grow: 1;
  padding: 1rem;
  line-height: 1.5;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  color: #e2e8f0;
  overflow-y: auto;
}

#testDecoderBtn {
    position: absolute;
    top: 15px;
    right: 25px; 
    z-index: 5;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* --- Switches --- */
.switch { position: relative; display: inline-block; width: 44px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-primary); border: 1px solid var(--border-color);
  transition: .4s; border-radius: 34px;
}
.slider:before {
  position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px;
  background-color: var(--text-secondary);
  transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent); border-color: var(--accent); }
input:checked + .slider:before { transform: translateX(22px); background-color: #fff; }

input[type="checkbox"] {
  appearance: none; width: 18px; height: 18px;
  border: 2px solid var(--border-color); border-radius: 4px;
  background-color: var(--bg-primary); position: relative; cursor: pointer; margin-right: 8px;
}
input[type="checkbox"]:checked {
  background-color: var(--accent); border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: '✔'; color: #fff; font-size: 12px;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.7); z-index: 100;
  display: flex; justify-content: center; align-items: center;
  backdrop-filter: blur(5px);
}
.modal-content {
  background-color: var(--bg-secondary); padding: 1.5rem;
  border-radius: 12px; border: 1px solid var(--border-color);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  width: 90%; max-width: 1200px; max-height: 85vh;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; margin-bottom: 1rem;
}
.modal-header-actions { display: flex; align-items: center; gap: 0.75rem; }
.modal-body { overflow-y: auto; font-family: 'Consolas', monospace; white-space: pre-wrap; font-size: 0.9em; padding-right: 0.5rem;}
.log-result { margin-bottom: 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 1rem; }
.log-result:last-child { border-bottom: none; }
.log-result b { color: var(--accent); }

/* --- Other Components --- */
.error-message { color: var(--error); font-size: 0.9rem; transition: opacity 0.3s ease; opacity: 0; height: 0; overflow: hidden;}
.error-message.show { opacity: 1; height: auto; margin-top: 0.5rem;}

.loading-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 99; transition: opacity 0.3s; backdrop-filter: blur(2px);}
.loading-spinner {
    display: none; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 50px; height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 100;
}
@keyframes spin { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }

.tooltip-icon {
  position: relative; display: inline-block; cursor: help;
  font-size: 0.75em; width: 18px; height: 18px; line-height: 18px;
  text-align: center; border-radius: 50%;
  background-color: rgba(255,255,255,0.1); color: var(--text-secondary);
  margin-left: 0.5em; border: 1px solid var(--border-color);
}
.tooltip-icon:hover { background-color: var(--accent); color: white; border-color: var(--accent); }

.tooltip-icon::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 10px); left: 50%;
  transform: translateX(-50%); background-color: var(--bg-secondary); color: var(--text-primary);
  padding: 0.8em 1em; border-radius: 8px; font-size: 0.9rem;
  width: max-content; max-width: 300px; z-index: 20;
  opacity: 0; visibility: hidden; transition: all 0.2s ease;
  text-align: left; font-weight: 400; border: 1px solid var(--border-color);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3); line-height: 1.4;
}
.tooltip-icon:hover::after { opacity: 1; visibility: visible; }

.split-button-container { position: relative; display: inline-flex; }
.split-button-main { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 1px solid rgba(255, 255, 255, 0.2); }
.split-button-toggle { border-top-left-radius: 0; border-bottom-left-radius: 0; padding-left: 0.7rem; padding-right: 0.7rem; }
.split-button-toggle i { transition: transform 0.2s ease-in-out; }
.split-button-toggle.open i { transform: rotate(180deg); }
.dropdown-menu { display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 10; flex-direction: column; gap: 4px; padding: 4px; background-color: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.dropdown-menu a {
  color: var(--text-primary); font-weight: 500;
  padding: 0.6rem 1.2rem; border-radius: 6px; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background 0.2s;
}
.dropdown-menu a:hover { background-color: var(--accent); color: white; }

.feedback-popup {
  background-color: var(--success); color: #ffffff; padding: 0.5rem 1.2rem;
  border-radius: 8px; font-weight: 600; font-size: 0.9em;
  visibility: hidden; opacity: 0; transition: all 0.3s ease;
  position: absolute; left: 50%; transform: translateX(-50%); top: -40px;
  z-index: 50; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.feedback-popup.show { visibility: visible; opacity: 1; top: -50px; }

@media (max-width: 768px) {
  .grid.two-column { grid-template-columns: 1fr; }
  .container { padding: 1rem; padding-bottom: 6rem; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 5px; border: 2px solid var(--bg-primary); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary); 
    padding: 10px;
}

/* --- Expandable Search Bar --- */
.search-wrapper {
  position: relative;
  display: flex;
  justify-content: flex-end;
  width: 36px;
  height: 36px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  border-radius: 18px;
  background-color: transparent;
}

.search-wrapper:hover,
.search-wrapper:focus-within,
.search-wrapper.active {
  width: 240px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
}

.search-icon-btn {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 2;
  background: transparent;
  border: none;
}

.search-wrapper:hover .search-icon-btn,
.search-wrapper:focus-within .search-icon-btn {
    color: var(--accent);
}

.search-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 0 15px 0 40px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  opacity: 0;
  transition: opacity 0.2s ease 0.1s;
}

.search-wrapper:hover .search-input,
.search-wrapper:focus-within .search-input,
.search-wrapper.active .search-input {
  opacity: 1;
}

/* --- Text/Utility Buttons --- */
.btn-text {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-text:hover { color: var(--accent); }

/* --- Dynamic Field Highlighting --- */
.input-box.dynamic-field-active {
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
  background-color: rgba(34, 197, 94, 0.05);
}

.input-box.dynamic-field-active:focus {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.dynamic-icon-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  margin-right: 0.5rem;
}

.dynamic-icon {
  color: var(--success);
  font-size: 1rem;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dynamic-icon.show { opacity: 1; transform: scale(1); }

/* --- Highlight Flash Animation --- */
@keyframes highlight-pulse {
    0% { background-color: rgba(34, 197, 94, 0.1); transform: scale(1); }
    50% { background-color: rgba(34, 197, 94, 0.25); transform: scale(1.02); }
    100% { background-color: transparent; transform: scale(1); }
}

.highlight-flash {
    animation: highlight-pulse 1.2s ease-out;
    border: 1px solid var(--success) !important;
}

/* --- Interactive Label (Modern Badge Style) --- */
.interactive-label {
    cursor: pointer;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    margin-right: 8px;
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
}

.interactive-label:hover {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent);
    border-color: rgba(59, 130, 246, 0.3);
}

.interactive-label:hover::after {
    content: '\f05b';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.8em;
    margin-left: 8px;
    opacity: 0.7;
}