@import url("/static/css/colors.css");

.tools-main {
  display: flex;
  flex-direction: column;
  gap: 48px;
  padding: 32px clamp(18px, 5vw, 46px) 64px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Hero Section */
.tools-hero {
  text-align: center;
  padding: 32px 0;
}

.tools-hero h1 {
  font-size: clamp(32px, 5vw, 48px);
  margin: 0 0 16px;
  color: var(--text);
}

.tools-subhead {
  font-size: clamp(16px, 2vw, 20px);
  color: var(--muted);
  margin: 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

/* Converter Section */
.converter-section {
  width: 100%;
}

.converter-container {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.converter-reset {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-alt);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
  z-index: 5;
}

.converter-reset:hover {
  background: var(--danger);
  color: white;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 500px;
  align-items: stretch;
}

.converter-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Format Selectors */
.format-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.format-selector label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.format-selector select {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 150ms ease;
}

.format-selector select:focus {
  outline: none;
  border-color: var(--accent);
}

.format-selector select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Upload Area */
.upload-area {
  flex: 1;
  min-height: 300px;
  box-sizing: border-box;
  border: 2px dashed var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 200ms ease;
  position: relative;
  overflow: hidden;
}

/* Dynamic Content Containers */
.dynamic-content,
.output-dynamic-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 300px;
}

.dynamic-content[style*="display: none"],
.output-dynamic-content[style*="display: none"] {
  display: none !important;
}

.upload-area:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.upload-area.drag-over {
  border-color: var(--accent);
  background: var(--surface-hover);
  transform: scale(1.01);
}

.upload-content {
  text-align: center;
  padding: 24px;
}

.upload-content > *:not(#fileInput) {
  pointer-events: none;
}

.upload-icon {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 16px;
}

.upload-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.upload-subtext {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

#fileInput {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* Text Input Area */
.text-input-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-input-area textarea {
  flex: 1;
  min-height: 250px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.text-input-area textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.text-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* File Lists */
.input-files-list,
.output-files-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.file-item i {
  color: var(--accent);
  font-size: 16px;
}

.file-item .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .file-size {
  color: var(--muted);
  font-size: 12px;
}

.file-item .file-remove {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.file-item .file-remove:hover {
  background: var(--danger);
  color: white;
}

.output-file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--success-bg);
  border: 1px solid var(--success-border-soft);
  border-radius: 8px;
  font-size: 14px;
}

.output-file-item i {
  color: var(--success);
}

.output-file-item .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-file-item .btn-download {
  padding: 6px 12px;
  border: none;
  background: var(--accent);
  color: var(--reverse-text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 150ms ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.output-file-item .btn-download:hover {
  background: var(--accent-strong);
}

.output-file-item .btn-download i {
  color: var(--reverse-text);
}

/* Output Area */
.output-area {
  flex: 1;
  min-height: 300px;
  box-sizing: border-box;
  border: 2px dashed var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
}

.output-files-list {
  display: none;
}

.output-files-list.is-visible {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.output-placeholder {
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

.output-placeholder i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.output-placeholder p {
  margin: 0;
  font-size: 16px;
}

/* Buttons */
.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 150ms ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 107, 214, 0.25);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
}

/* Converter Actions Row */
.converter-actions-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-shrink: 0;
}

.btn-convert {
  flex: 1;
  padding: 14px;
  font-size: 16px;
}

.btn-convert i {
  margin-right: 8px;
}

.btn-convert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-convert:disabled:hover {
  transform: none;
  box-shadow: none;
}

.btn-download-all {
  flex: 1;
  padding: 14px;
  font-size: 16px;
}

/* Animation Overlay */
.animation-overlay {
  position: absolute;
  inset: 0;
  background: #ffffff13;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.animation-overlay.active {
  display: flex;
}

.animation-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

.animation-overlay:not(.active) {
  display: none !important;
}

.animation-container {
  width: 200px;
  height: 200px;
}

.animation-container.enter-loading {
  animation: loadingPopIn 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transform-origin: center;
}

@keyframes loadingPopIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Text Tools Section */
.text-tools-section {
  padding: 32px 0;
}

.text-tools-section h2 {
  text-align: center;
  font-size: clamp(24px, 3vw, 32px);
  margin: 0 0 32px;
  color: var(--text);
}

.text-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.text-tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 200ms ease;
}

.text-tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.text-tool-card i {
  font-size: 32px;
  color: var(--accent);
  margin-bottom: 12px;
}

.text-tool-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

.text-tool-card p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* Tools Features */
.tools-features {
  padding: 32px 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.feature-item {
  text-align: center;
  padding: 24px;
}

.feature-item i {
  font-size: 40px;
  color: var(--accent);
  margin-bottom: 16px;
}

.feature-item h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

.feature-item p {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

/* Text Tool Modal */
.text-tool-modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.text-tool-modal.active {
  display: flex;
}

.text-tool-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.text-tool-header h3 {
  font-size: 20px;
  margin: 0;
}

.text-tool-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface-alt);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.text-tool-close:hover {
  background: var(--danger);
  color: white;
}

.text-tool-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.text-tool-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.text-tool-options button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 150ms ease;
}

.text-tool-options button:hover,
.text-tool-options button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.text-tool-input,
.text-tool-output {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.text-tool-input label,
.text-tool-output label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.text-tool-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.text-tool-copy {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
}

.text-tool-input textarea,
.text-tool-output textarea {
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.text-tool-input textarea:focus,
.text-tool-output textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.text-tool-output textarea {
  background: var(--surface-alt);
}

.text-tool-inline {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

.text-tool-inline:focus {
  outline: none;
  border-color: var(--accent);
}

.color-picker-circle {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

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

.color-picker-circle::-webkit-color-swatch {
  border: 1px solid var(--border);
  border-radius: 50%;
}

.color-picker-circle::-moz-color-swatch {
  border: 1px solid var(--border);
  border-radius: 50%;
}

.color-preview {
  min-height: 80px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.text-tool-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.text-tool-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 16px;
  background: var(--surface-alt);
  border-radius: 10px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

/* Responsive */
@media (max-width: 768px) {
  .converter-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .upload-area,
  .output-area {
    min-height: 200px;
  }

  .text-tools-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .text-tool-content {
    max-height: 95vh;
    margin: 12px;
  }
}

@media (max-width: 480px) {
  .tools-main {
    padding: 16px;
  }

  .converter-container {
    padding: 16px;
  }

  .text-tools-grid {
    grid-template-columns: 1fr;
  }

  .text-tool-options {
    justify-content: center;
  }
}
