/**
 * Font Tester Styles - Matching the exact design from the image
 * Using CSS variables from the brand guideline
 */

/* Container */
.melek-font-tester-container {
  max-width: 100%;
  margin: 0;
  font-family: var(
    --font-sans,
    'Plus Jakarta Sans',
    system-ui,
    -apple-system,
    sans-serif
  );
  color: #ffffff;
  padding: 0px;
  box-sizing: border-box;
  margin-bottom: 48px;
}

/* Metadata Cards - rendered independently above the font tester */
.font-metadata-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 48px;
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif);
  color: #ffffff;
}

/* Tablet - 2 columns */
@media (max-width: 1024px) {
  .font-metadata-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* Mobile - 1 column */
@media (max-width: 640px) {
  .font-metadata-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.metadata-card {
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  background: transparent;
}

/* Demo card - same layout as other cards with title + button */
.metadata-card-demo {
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metadata-card-title {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 8px;
}

.metadata-card-value {
  color: #ffffff;
  font-size: 16px;
  font-weight: 400;
}

/* Demo Link Button */
.demo-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: #134CD3;
  color: #ffffff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-radius: 0;
  transition: all 300ms ease;
  width: fit-content;
}

/* Demo link inside demo card */
.metadata-card-demo .demo-link {
  margin-top: 4px;
}

.demo-link:hover {
  background: #0d3ba8;
  transform: translateY(-1px);
  color: #ffffff;
}

.demo-link svg {
  flex-shrink: 0;
}

.metadata-label {
  font-size: var(--text-m, 16px);
  font-weight: 400;
  color: var(--muted-foreground, oklch(1 0 0));
  margin-bottom: var(--space-m, 16px);
  opacity: 0.8;
}

.metadata-value {
  font-size: var(--text-m, 16px);
  font-weight: 500;
  color: var(--foreground, oklch(1 0 0));
}

/* Title */
.melek-font-tester-title {
  font-size: var(--text-3xl, 48px);
  font-weight: 300;
  color: var(--foreground, oklch(1 0 0));
  margin: 0 0 var(--space-2xl, 64px) 0;
  letter-spacing: var(--tracking-normal, 0);
}

/* Top Row - Dropdown and Font Size */
.melek-font-tester-top-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-xl, 48px);
  margin-bottom: var(--space-xl, 48px);
  align-items: end;
}

/* Pangram Section */
.pangram-section {
  margin-bottom: 0;
}

.pangram-section .pangram-select {
  width: 100%;
  padding: var(--space-m, 16px) var(--space-l, 24px);
  background: var(--input, oklch(0.1902 0.0101 294.5883));
  border: 1px solid var(--border, oklch(1 0 0 / 20%));
  border-radius: var(--radius, 0);
  color: var(--foreground, oklch(1 0 0));
  font-size: var(--text-m, 16px);
  font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-m, 16px) center;
  padding-right: calc(var(--space-l, 24px) + 24px);
}

.pangram-section .pangram-select:focus {
  border-color: var(--primary-border, #3e71d9);
  box-shadow: 0 0 0 1px var(--primary-border, #3e71d9);
}

/* Font Size Section - Match first image design */
.font-size-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-m, 16px);
  margin-bottom: 0;
  min-width: 280px;
  padding: var(--space-l, 24px);
  background: var(--card, oklch(1 0 0 / 5%));
  border: 1px solid var(--border, oklch(1 0 0 / 20%));
  border-radius: var(--radius, 0);
}

.font-size-section label {
  font-size: var(--text-m, 16px);
  font-weight: 400;
  color: var(--foreground, oklch(1 0 0));
  margin-bottom: 0;
  text-align: right;
}

.font-size-label-and-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-l, 24px);
  width: 100%;
}

.font-size-display {
  font-size: var(--text-l, 20px);
  font-weight: 600;
  color: var(--foreground, oklch(1 0 0));
  white-space: nowrap;
}

.font-size-slider {
  width: 100%;
  height: 4px;
  background: var(--border, oklch(1 0 0 / 20%));
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  border: none;
}

.font-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--primary, oklch(0.4778 0.2095 262.3701));
  border: 2px solid var(--foreground, oklch(1 0 0));
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--primary, oklch(0.4778 0.2095 262.3701));
}

.font-size-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--primary, oklch(0.4778 0.2095 262.3701));
  border: 2px solid var(--foreground, oklch(1 0 0));
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--primary, oklch(0.4778 0.2095 262.3701));
}

.font-size-slider::-webkit-slider-track {
  background: var(--border, oklch(1 0 0 / 20%));
  height: 4px;
  border-radius: 2px;
}

.font-size-slider::-moz-range-track {
  background: var(--border, oklch(1 0 0 / 20%));
  height: 4px;
  border-radius: 2px;
  border: none;
}

/* Custom Text Section */
.custom-text-section {
  margin-bottom: var(--space-2xl, 64px);
}

.custom-text-section .custom-text-input {
  width: 100%;
  padding: var(--space-l, 24px);
  background: var(--input, oklch(0.1902 0.0101 294.5883));
  border: 1px solid var(--border, oklch(1 0 0 / 20%));
  border-radius: var(--radius, 0);
  color: var(--foreground, oklch(1 0 0));
  font-size: var(--text-m, 16px);
  font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
  outline: none;
  height: 60px;
  line-height: 1.5;
}

.custom-text-section .custom-text-input:focus {
  border-color: var(--primary-border, #3e71d9);
  box-shadow: 0 0 0 1px var(--primary-border, #3e71d9);
}

.custom-text-section .custom-text-input::placeholder {
  color: var(--muted-foreground, oklch(1 0 0));
  opacity: 0.6;
}

/* Font Rendering Section */
.font-rendering-section {
  margin-top: 0;
}

.font-rendering-container {
  background: transparent;
  border: none;
  padding: 0;
  min-height: auto;
}

.font-section {
  margin-bottom: var(--space-xl, 48px);
  padding-bottom: 0;
  border-bottom: none;
}

.font-section:last-child {
  margin-bottom: 0;
}

.font-name {
  font-size: var(--text-m, 16px);
  font-weight: 400;
  color: var(--muted-foreground, oklch(1 0 0));
  margin: 0 0 var(--space-l, 24px) 0;
  padding: 0;
  border-bottom: none;
  display: block;
  opacity: 0.8;
}

.font-render-area {
  font-size: var(--text-3xl, 48px);
  line-height: 1.2;
  color: var(--foreground, oklch(1 0 0));
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
  letter-spacing: var(--tracking-normal, 0);
}

/* Hide interface wrapper - we want direct styling */
.melek-font-tester-interface {
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
}

/* Loading, Error, and Empty States */
.font-loading,
.font-error,
.font-empty {
  text-align: center;
  padding: var(--space-2xl, 64px) var(--space-l, 24px);
  color: var(--muted-foreground, oklch(1 0 0));
}

.font-loading .loading-spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--muted, oklch(0.3211 0 0));
  border-top: 2px solid var(--primary, oklch(0.4778 0.2095 262.3701));
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-l, 24px) auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.font-error {
  color: var(--destructive, oklch(0.628 0.2577 29.2339));
}

.font-empty {
  color: var(--muted-foreground, oklch(1 0 0));
}

/* Responsive Design */
@media (max-width: 768px) {
  .melek-font-tester-container {
    padding: var(--space-l, 24px) 0;
  }

  .melek-font-metadata-grid {
    grid-template-columns: 1fr;
    gap: var(--space-m, 16px);
  }

  .melek-font-tester-title {
    font-size: var(--text-2xl, 32px);
    margin-bottom: var(--space-xl, 48px);
  }

  .melek-font-tester-top-row {
    grid-template-columns: 1fr;
    gap: var(--space-l, 24px);
  }

  .font-size-section {
    align-items: stretch;
    min-width: auto;
  }

  .font-size-label-and-display {
    justify-content: space-between;
  }

  .custom-text-section .custom-text-input {
    padding: var(--space-l, 24px);
    min-height: 80px;
  }

  .font-render-area {
    font-size: var(--text-2xl, 32px);
  }
}

@media (max-width: 480px) {
  .melek-font-tester-title {
    font-size: var(--text-xl, 24px);
  }

  .font-render-area {
    font-size: var(--text-xl, 24px);
  }
}

/* Essential UI Elements - Fallback styles for missing CSS variables */

/* Loading state */
.loading-state {
  text-align: center;
  padding: 40px 20px;
  color: #ffffff;
}

.loading-spinner {
  border: 2px solid #333;
  border-top: 2px solid #007cba;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Font sections */
.font-section {
  margin-bottom: 32px;
}

.font-name-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.font-name {
  color: #ffffff;
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 400;
  opacity: 0.7;
}

.show-glyph-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0;
  font-family: inherit;
  white-space: nowrap;
}

.show-glyph-btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.show-glyph-btn:active {
  background: rgba(255, 255, 255, 0.1);
}

.font-render-area {
  color: #ffffff;
  font-size: 48px;
  line-height: 1.2;
  word-break: break-word;
  font-weight: 400;
}

/* Controls */
.font-controls {
  display: flex;
  /* grid-template-columns: 1fr 1fr; */
  flex: 1;
  gap: 20px;
  margin-bottom: 32px;
  align-items: stretch;
}

@media (max-width: 768px) {
  .font-controls {
    flex-direction: column;
  }
}

.control-group {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  /* min-height: 90px; */
}

/* Font size control gets padding */
.control-group.font-size-control {
  padding: 20px;
}

/* Custom select should fill its container */
.custom-select {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.control-group label {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
  font-size: 14px;
  display: block;
  margin-bottom: 12px;
}

.control-group select,
.control-group input[type='text'] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: transparent;
  color: #ffffff;
  font-size: 14px;
}

.control-group select:focus,
.control-group input:focus {
  outline: none;
  border-color: #007cba;
}

/* Font Size Control - Special Layout */
.control-group.font-size-control {
  display: flex;
  flex-direction: column;
}

.font-size-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.font-size-header label {
  margin: 0;
  font-size: 16px;
  color: #ffffff;
}

.font-size-value {
  font-size: 16px;
  color: #ffffff;
}

.control-group input[type='range'] {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
}

.control-group input[type='range']::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  background: #007cba;
  border-radius: 50%;
  cursor: pointer;
  -webkit-appearance: none;
}

.control-group input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #007cba;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Custom Select Styling */
.custom-select {
  position: relative;
}

.select-trigger {
  width: 100%;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  height: 100%;
}

.select-trigger span.selected-text-display {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 85%;
}

.select-trigger:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.select-trigger.active {
  border-color: #007cba;
}

.select-arrow {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.select-trigger.active .select-arrow {
  transform: rotate(180deg);
}

.select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(25, 25, 25, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top: none;
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
}

.select-option {
  padding: 12px 20px;
  color: #ffffff;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s ease;
}

.select-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.select-option.selected {
  background: rgba(0, 124, 186, 0.2);
  color: #007cba;
}

/* Full-width text input */
.full-width-text-input {
  width: 100%;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  font-size: 14px;
  margin-bottom: 32px;
  box-sizing: border-box;
}

.full-width-text-input:focus {
  outline: none;
  border-color: #007cba;
}

.full-width-text-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Header */
.font-tester-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.font-tester-header h3 {
  color: #ffffff;
  margin: 0;
  font-size: 32px;
  font-weight: 400;
  line-height: 48px;
}

.font-info {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

/* ===== GLYPH GRID STYLES ===== */

/* Mode Switcher */
.mode-switcher {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  padding: 8px;
  background: transparent;
}

.mode-btn {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: all 300ms ease;
  border-radius: 0;
}

.mode-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.mode-btn.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Glyph Font Selector Wrapper */
.glyph-font-selector-wrapper {
  margin-bottom: 32px;
}

.glyph-font-selector-wrapper .custom-select {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Copy Format Selector */
.copy-selector {
  padding: 24px;
  margin-bottom: 32px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  background: transparent;
}

.selector-legend {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #ffffff;
  padding: 0;
  border: none;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition: all 300ms ease;
}

.radio-option:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
}

.radio-option.selected {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.radio-option input[type='radio'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-option label {
  cursor: pointer;
  color: #ffffff;
  font-size: 14px;
  font-weight: 400;
  margin: 0;
}

/* Glyph Grid Container */
.glyph-container {
  padding: 0;
}

.category-section {
  margin-bottom: 48px;
}

.category-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #ffffff;
}

/* Grid Layout */
.glyph-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}

@media (min-width: 768px) {
  .glyph-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (min-width: 1280px) {
  .glyph-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

/* Glyph Cell */
.glyph-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: all 300ms ease-in-out;
  background: transparent;
  min-height: 120px;
}

.glyph-cell:hover {
  border-color: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(226, 232, 240, 0.7);
  background: rgba(255, 255, 255, 0.05);
}

.glyph-character {
  font-size: 48px;
  margin-bottom: 8px;
  color: #ffffff;
  line-height: 1;
}

.glyph-info {
  font-size: 12px;
  text-align: center;
  color: #ffffff;
}

.glyph-name {
  font-weight: 600;
  margin: 0 0 4px 0;
  color: #ffffff;
}

.glyph-unicode {
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

/* Glyph Grid Error State */
.glyph-error {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.7);
}

.glyph-error p {
  margin: 0;
  font-size: 16px;
}

/* Toast Notification */
.glyph-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.9);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 4px;
  z-index: 10000;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Responsive Adjustments for Glyph Grid */
@media (max-width: 768px) {
  .glyph-cell {
    padding: 16px;
    min-height: 100px;
  }

  .glyph-character {
    font-size: 36px;
  }

  .radio-group {
    flex-direction: column;
  }

  .radio-option {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .mode-switcher {
    flex-direction: column;
  }

  .copy-selector {
    padding: 16px;
  }

  .glyph-cell {
    padding: 12px;
    min-height: 80px;
  }

  .glyph-character {
    font-size: 28px;
  }

  .category-title {
    font-size: 18px;
  }
}

.control-group {
  flex: 1;
}
