/**
 * Stegalex - Classical Text Encryption & Decryption
 * MIT License - Copyright (c) 2025 NQR
 *
 * Design System:
 * - Techno aesthetic with neon accents
 * - Dual panel layout for input/output
 * - Terminal-inspired chrome
 * - Professional and modern
 */

/* ============================================================================
   GLOBAL RESET & BASE STYLES
   ============================================================================ */

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

:root {
  color-scheme: dark;

  /* Color Palette - Techno Theme */
  --color-bg-primary: #030508;
  --color-bg-panel: #0a0f14;
  --color-accent-cyan: #00f0ff;
  --color-accent-teal: #00ffaa;
  --color-accent-magenta: #ff00aa;
  --color-text-primary: #d7e8ff;
  --color-text-secondary: #8b9cb7;
  --color-border: rgba(0, 240, 255, 0.2);
  --color-button-bg: rgba(0, 240, 255, 0.15);
  --color-button-hover: rgba(0, 240, 255, 0.3);

  /* Neon glows */
  --glow-primary: 0 0 10px rgba(0, 240, 255, 0.3),
                  0 0 20px rgba(0, 240, 255, 0.15);
  --glow-secondary: 0 0 10px rgba(0, 255, 170, 0.3),
                    0 0 20px rgba(0, 255, 170, 0.15);

  /* Font */
  --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
}

body {
  font-family: var(--font-main);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  overflow: hidden;
  height: 100vh;
  line-height: 1.6;
  position: relative;
}

/* Subtle scanline overlay */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.02) 2px,
    rgba(0, 0, 0, 0.02) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

@media (prefers-reduced-motion: reduce) {
  body::after {
    display: none;
  }
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.container {
  display: flex;
  height: 100vh;
  width: 100%;
}

.control-panel {
  width: 280px;
  background: linear-gradient(180deg, var(--color-bg-panel) 0%, var(--color-bg-primary) 100%);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  flex-shrink: 0;
}

.control-panel::-webkit-scrollbar {
  width: 8px;
}

.control-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.control-panel::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.3);
  border-radius: 4px;
}

.control-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.5);
}

.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--color-border);
  overflow: hidden;
}

/* ============================================================================
   HEADER
   ============================================================================ */

header {
  text-align: center;
  margin-top: 20px;
  padding-top: 0px;
}

.logo {
  width: 60px;
  height: 60px;
  filter: drop-shadow(var(--glow-primary));
}

h1 {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--color-accent-cyan);
  text-shadow: var(--glow-primary);
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-top: 8px;
  letter-spacing: 0.02em;
}

/* ============================================================================
   SECTIONS
   ============================================================================ */

.section {
  margin-bottom: 5px;
  padding: 15px;
  background: rgba(0, 240, 255, 0.02);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  position: relative;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 15px;
  font-family: var(--font-mono);
  padding-left: 10px;
  border-left: 2px solid var(--color-accent-cyan);
  text-shadow: var(--glow-primary);
  text-align: center;
}

/* ============================================================================
   CONTROLS
   ============================================================================ */

.control-group {
  margin-bottom: 15px;
}

.control-label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.control-label input[type="checkbox"],
.control-label input[type="radio"] {
  margin-right: 8px;
  vertical-align: middle;
  accent-color: var(--color-accent-cyan);
}

select,
input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  background-color: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-primary);
  font-family: var(--font-main);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent-cyan);
  box-shadow: var(--glow-primary);
}

.info-hint {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 6px;
  font-style: italic;
  opacity: 0.8;
}

/* Range Slider */
.range-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-container input[type="range"] {
  flex: 1;
  height: 6px;
  background: rgba(0, 240, 255, 0.1);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  padding: 0;
}

.range-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--color-accent-cyan);
  cursor: pointer;
  border-radius: 50%;
  box-shadow: var(--glow-primary);
}

.range-container input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--color-accent-cyan);
  cursor: pointer;
  border-radius: 50%;
  border: none;
  box-shadow: var(--glow-primary);
}

.range-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--color-accent-cyan);
  min-width: 30px;
  text-align: right;
}

/* Parameter Groups */
.parameter-group {
  display: none;
}

.parameter-group.active {
  display: block;
}

/* ============================================================================
   TEXT PANELS
   ============================================================================ */

.text-panel {
  background: var(--color-bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Styling Controls - Combined with header */
.styling-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(0, 240, 255, 0.05);
  border-bottom: 1px solid var(--color-border);
  align-items: stretch;
}

.styling-controls h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
  text-shadow: var(--glow-primary);
  margin: 0;
  text-align: center;
}

.styling-controls-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.icon-btn {
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-accent-cyan);
  cursor: pointer;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:hover {
  background: rgba(0, 240, 255, 0.2);
  box-shadow: var(--glow-primary);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(0);
}

.font-select {
  max-width: 150px;
  height: 32px;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.size-input {
  max-width: 50px;
  width: 50px;
  height: 32px;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.color-input {
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.style-btn {
  width: 32px;
  height: 32px;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-primary);
  cursor: pointer;
  font-weight: bold;
  font-family: var(--font-main);
  transition: all 0.2s ease;
}

.style-btn:hover {
  background: rgba(0, 240, 255, 0.2);
}

.style-btn.active {
  background: rgba(0, 240, 255, 0.3);
  border-color: var(--color-accent-cyan);
  box-shadow: var(--glow-primary);
}

.align-select {
  width: 80px;
  height: 32px;
  padding: 6px 8px;
  font-size: 0.85rem;
}

/* Textareas */
textarea {
  flex: 1;
  resize: none;
  padding: 20px;
  border: none;
  border-radius: 0;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.6;
}

textarea::-webkit-scrollbar {
  width: 10px;
}

textarea::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

textarea::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.3);
  border-radius: 5px;
}

textarea::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.5);
}

textarea::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.5;
}

/* ============================================================================
   CIPHER HISTORY SECTION
   ============================================================================ */

.history-section {
  margin-top: 10px;
}

.collapsible {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  transition: all 0.2s ease;
}

.collapsible:hover {
  color: var(--color-accent-teal);
}

.collapse-icon {
  font-size: 0.7rem;
  transition: transform 0.3s ease;
  color: var(--color-accent-cyan);
}

.collapsible.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.history-content {
  max-height: 300px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.history-content.collapsed {
  max-height: 0;
}

.history-text {
  padding: 15px 10px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
  max-height: 300px;
  overflow-y: auto;
  box-sizing: border-box;
}

.history-text::-webkit-scrollbar {
  width: 6px;
}

.history-text::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.history-text::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.3);
  border-radius: 3px;
}

.history-text p {
  margin-bottom: 10px;
}

.history-text strong {
  color: var(--color-accent-cyan);
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.panel-footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.panel-footer a {
  color: var(--color-accent-teal);
  text-decoration: none;
  transition: color 0.2s ease;
}

.panel-footer a:hover {
  color: var(--color-accent-cyan);
  text-shadow: var(--glow-primary);
}

.link-style {
  background: none;
  border: none;
  color: var(--color-accent-teal);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  text-decoration: none;
  transition: color 0.2s ease;
}

.link-style:hover {
  color: var(--color-accent-cyan);
  text-shadow: var(--glow-primary);
}

/* ============================================================================
   LICENSE MODAL
   ============================================================================ */

.license-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 10000;
}

.license-overlay.active {
  display: block;
}

.license-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-accent-cyan);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.3),
              0 0 80px rgba(0, 240, 255, 0.15);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  z-index: 10001;
}

.license-modal.active {
  display: block;
}

.license-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(0, 240, 255, 0.05);
}

.license-modal-title {
  font-size: 1.1rem;
  color: var(--color-accent-cyan);
  font-family: var(--font-mono);
  text-shadow: var(--glow-primary);
}

.license-close {
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.license-close:hover {
  color: var(--color-accent-cyan);
  text-shadow: var(--glow-primary);
}

.license-modal-text {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--color-text-secondary);
}

.license-modal-text::-webkit-scrollbar {
  width: 10px;
}

.license-modal-text::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.license-modal-text::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.3);
  border-radius: 5px;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 1200px) {
  .control-panel {
    width: 250px;
  }
}

@media (max-width: 900px) {
  .container {
    flex-direction: column;
  }

  .control-panel {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-top: 1px solid var(--color-border);
    order: 2;
  }

  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    flex: 1;
    order: 1;
  }

  h1 {
    font-size: 1.5rem;
  }

  .subtitle {
    font-size: 0.8rem;
  }
}

@media (max-width: 1350px) {
  .styling-controls {
    gap: 6px;
    padding: 10px;
  }

  .styling-controls h2 {
    width: 100%;
    margin-bottom: 0;
    text-align: center;
  }

  /* Hide all styling controls on mobile */
  .styling-controls .font-select,
  .styling-controls .size-input,
  .styling-controls .color-input,
  .styling-controls .style-btn,
  .styling-controls .align-select,
  .styling-controls .icon-btn {
    display: none;
  }

  textarea {
    padding: 15px;
    font-size: 14px;
  }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible styles */
:focus-visible {
  outline: 2px solid var(--color-accent-cyan);
  outline-offset: 2px;
}
