/* ==========================================================================
   FONTS
   ========================================================================== */

@font-face {
  font-family: "ansi";
  src: url("font/bijoy.woff2") format("woff2");
}

@font-face {
  font-family: "unicode";
  src: url("font/unicode.woff2") format("woff2");
}

/* ==========================================================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ========================================================================== */

:root {
  /* Colors */
  --background: hsl(180 20% 98%);
  --foreground: hsl(180 15% 12%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(180 15% 12%);
  --popover: hsl(0 0% 100%);
  --popover-foreground: hsl(180 15% 12%);
  --primary: hsl(175, 100%, 29%);
  --primary-foreground: hsl(0 0% 100%);
  --secondary: hsl(180 20% 96%);
  --secondary-foreground: hsl(180 15% 12%);
  --muted: hsl(180 20% 96%);
  --muted-foreground: hsl(180 10% 45%);
  --accent: hsl(180 20% 96%);
  --accent-foreground: hsl(180 15% 12%);
  --destructive: hsl(0 84.2% 60.2%);
  --destructive-foreground: hsl(210 40% 98%);
  --border: hsl(180 20% 90%);
  --input: hsl(180 15% 94%);
  --ring: hsl(175, 100%, 29%);
  
  /* Layout */
  --radius: 0.5rem;
}

[data-theme="dark"] {
  /* Dark theme colors */
  --background: hsl(180 10% 8%);
  --foreground: hsl(0 0% 98%);
  --card: hsl(180 8% 12%);
  --card-foreground: hsl(0 0% 98%);
  --popover: hsl(180 8% 12%);
  --popover-foreground: hsl(0 0% 98%);
  --primary: hsl(175, 100%, 29%);
  --primary-foreground: hsl(180 10% 8%);
  --secondary: hsl(180 8% 16%);
  --secondary-foreground: hsl(0 0% 98%);
  --muted: hsl(180 8% 16%);
  --muted-foreground: hsl(180 5% 65%);
  --accent: hsl(180 8% 16%);
  --accent-foreground: hsl(0 0% 98%);
  --destructive: hsl(0 62.8% 50%);
  --destructive-foreground: hsl(0 0% 98%);
  --border: hsl(180 8% 20%);
  --input: hsl(180 8% 20%);
  --ring: hsl(175, 100%, 29%);
}

/* ==========================================================================
   BASE STYLES
   ========================================================================== */

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

body {
  font-family: "unicode", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  padding: 1.5rem;
  min-height: 100vh;
  font-feature-settings: "rlig" 1, "calt" 1;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

main {
  width: 100%;
  background: var(--card);
  border-radius: calc(var(--radius) * 2);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px hsl(0 0% 0% / 0.1), 0 2px 4px -2px hsl(0 0% 0% / 0.1);
  transition: all 0.3s ease;
}

section {
  padding: 2rem;
  display: flex;
  flex-direction: row;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

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

header {
  background: linear-gradient(135deg, var(--primary) 0%, hsl(175, 100%, 25%) 100%);
  color: var(--primary-foreground);
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent 0%, hsl(0 0% 100% / 0.1) 100%);
  pointer-events: none;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.header-column {
  display: flex;
  align-items: center;
}

.header-column:first-child {
  flex: 1;
  justify-content: flex-start;
}

.header-column:nth-child(2),
.header-column:nth-child(3) {
  flex: 0 0 auto;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.header-button,
.button-group button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: var(--radius);
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  cursor: pointer;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

/* Header buttons */
.header-button {
  gap: 0.5rem;
  font-size: 0.875rem;
  height: 2.5rem;
  padding: 0 1rem;
  background: hsl(0 0% 100% / 0.15);
  color: var(--primary-foreground);
  border: 1px solid hsl(0 0% 100% / 0.25);
  backdrop-filter: blur(8px);
}

.header-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, hsl(0 0% 100% / 0.2), transparent);
  transition: left 0.5s ease;
}

.header-button:hover::before {
  left: 100%;
}

.header-button:hover {
  background: hsl(0 0% 100% / 0.25);
  border-color: hsl(0 0% 100% / 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px hsl(0 0% 0% / 0.1);
}

.header-button:focus-visible {
  outline: 2px solid hsl(0 0% 100% / 0.8);
  outline-offset: 2px;
}

.header-button:active {
  background: hsl(0 0% 100% / 0.3);
  transform: translateY(0);
}

/* Button group buttons */
.button-group {
  display: flex;
  gap: 0.5rem;
}

.button-group button {
  font-size: 0.75rem;
  height: 2rem;
  padding: 0.375rem 0.75rem;
  background: var(--primary);
  color: var(--primary-foreground);
  border: 1px solid var(--primary);
  gap: 0.375rem;
}

/* Font Awesome icon styling in buttons */
.button-group button i,
.header-button i {
  font-size: 0.875rem;
  margin-right: 0.25rem;
}

.header-button i {
  font-size: 1rem;
}

/* Theme toggle icon transitions */
#theme-icon {
  transition: transform 0.3s ease;
}

/* Icon sizing and alignment */
button i {
  display: inline-block;
  vertical-align: middle;
}

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

.text-section {
  flex: 1;
  padding: 1.5rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  min-width: 0;
}

.text-section:hover {
  border-color: hsl(175, 80%, 45%);
  box-shadow: 0 0 0 1px hsl(175, 80%, 45% / 0.2);
}

.text-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.text-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  color: var(--foreground);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.text-header h2::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  background: var(--primary);
  border-radius: 50%;
  display: inline-block;
}

.button-group button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: hsl(0 0% 100% / 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.button-group button:hover::after {
  width: 120%;
  height: 120%;
}

.button-group button:hover {
  background: hsl(175, 100%, 25%);
  border-color: hsl(175, 100%, 25%);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px hsl(175, 100%, 29% / 0.3);
}

.button-group button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.button-group button:active {
  background: hsl(175, 100%, 20%);
  transform: translateY(0);
}

/* ==========================================================================
   FORM ELEMENTS
   ========================================================================== */

textarea {
  width: 100%;
  height: 8rem;
  border-radius: var(--radius);
  border: 2px solid var(--input);
  background: var(--background);
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--foreground);
  resize: vertical;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  font-family: inherit;
  overflow: hidden;
}

/* Desktop: Enable auto-height adjustment */
@media (min-width: 769px) {
  textarea.auto-resize {
    height: auto;
    min-height: 8rem;
    max-height: 20rem;
    resize: none;
  }
}

/* Mobile: Keep fixed height */
@media (max-width: 768px) {
  textarea {
    height: 8rem;
    resize: vertical;
  }
}

textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 0.7;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px hsl(175, 100%, 29% / 0.1), 0 1px 3px 0 hsl(0 0% 0% / 0.1);
}

textarea:hover {
  border-color: hsl(175, 80%, 45%);
}

textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  background: var(--muted);
}

/* Font specific textarea styles */
#uniText {
  font-family: "unicode", sans-serif;
}

#ansiText {
  font-family: "ansi", sans-serif;
}

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

footer {
  text-align: center;
  padding: 1.5rem;
  background: var(--muted);
  border-top: 1px solid var(--border);
  transition: all 0.3s ease;
  margin-top: auto;
}

footer p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

footer a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   ABOUT SECTION
   ========================================================================== */

.about-section {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  display: block;
}

.about-content {
  background: var(--card);
  padding: 2rem;
  border-radius: calc(var(--radius) * 2);
  border: 1px solid var(--border);
  box-shadow: 0 4px 6px -1px hsl(0 0% 0% / 0.1), 0 2px 4px -2px hsl(0 0% 0% / 0.1);
  transition: all 0.2s ease;
}

.about-content:hover {
  border-color: hsl(175, 80%, 45%);
  box-shadow: 0 0 0 1px hsl(175, 80%, 45% / 0.2), 0 4px 6px -1px hsl(0 0% 0% / 0.1);
}

.about-content h2 {
  color: var(--primary);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--primary);
  position: relative;
}

.about-content h2::before {
  content: '';
  width: 1rem;
  height: 1rem;
  background: var(--primary);
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.75rem;
  vertical-align: middle;
}

.about-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 1rem 0;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.about-content h3::before {
  content: '';
  width: 0.75rem;
  height: 0.75rem;
  background: var(--primary);
  border-radius: 50%;
  display: inline-block;
}

.about-content p {
  margin-bottom: 1.5rem;
  line-height: 1.7;
  color: var(--muted-foreground);
  text-align: justify;
}

.about-content ul {
  padding-left: 1.5rem;
  margin: 1.5rem 0;
}

.about-content li {
  margin-bottom: 1rem;
  position: relative;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.about-content li::before {
  content: "\f054";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: var(--primary);
  position: absolute;
  left: -1rem;
  font-size: 0.8rem;
}

.about-note {
  background: var(--muted);
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-top: 2rem;
  border-left: 0.25rem solid var(--primary);
  position: relative;
}

.about-note::before {
  content: "\f0eb";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  top: 1.5rem;
  left: 1rem;
  font-size: 1.2rem;
  color: var(--primary);
}

.about-note p {
  margin-bottom: 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  padding-left: 2rem;
  line-height: 1.6;
}

.about-note strong {
  color: var(--primary);
  font-weight: 600;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

@media (max-width: 768px) {
  /* Base layout adjustments */
  body {
    padding: 1rem;
  }

  /* Mobile: Stack text sections vertically */
  section {
    padding: 1rem;
    max-width: none;
    flex-direction: column;
    gap: 1.5rem;
  }

  .text-section {
    flex: none;
  }

  /* Mobile: Improve text header layout */
  .text-header {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
    padding-bottom: 1rem;
  }

  .text-header h2 {
    margin-bottom: 0;
  }

  .button-group {
    justify-content: center;
  }

  /* Mobile: About section adjustments */
  .about-section {
    padding: 1rem;
  }

  .about-content {
    padding: 1.5rem;
    border-radius: var(--radius);
  }

  .about-content h2 {
    font-size: 1.5rem;
    text-align: center;
  }

  .about-content h3 {
    font-size: 1.125rem;
    justify-content: center;
    text-align: center;
  }

  .about-content p {
    text-align: left;
  }

  .about-note {
    padding: 1rem;
    margin-top: 1.5rem;
  }

  .about-note p {
    padding-left: 2rem;
    font-size: 0.8rem;
  }

  /* Header adjustments */
  .header-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .header-button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    width: 100%;
    justify-content: center;
  }

  .header-column {
    width: 100%;
    justify-content: center;
  }

  .header-column:nth-child(2),
  .header-column:nth-child(3) {
    margin-top: 0.5rem;
  }

  header h1 {
    font-size: 1.25rem;
    text-align: center;
    width: 100%;
  }

  /* Popup adjustments */
  .popup-content {
    padding: 1rem;
    border-radius: var(--radius);
    width: 95%;
    max-width: 40rem;
  }

  .popup-content h2 {
    font-size: 1.25rem;
    padding: 0.75rem 0.75rem 0.5rem 0;
  }

  .close-popup {
    top: 0.5rem;
    right: 0.5rem;
    margin: -0.25rem -0.25rem 0.5rem 0.75rem;
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }
}