/* --- Root Clean Monochrome Theme --- */
:root {
  --primary: #000000;
  --primary-hover: #333333;
  --primary-light: #f5f5f5;
  --bg-color: #ffffff;
  --bg-secondary: #f9f9f9;
  --text-primary: #000000;
  --text-secondary: #666666;
  --text-light: #999999;
  --border-color: #e0e0e0;
  --border-light: #f0f0f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: var(--transition);
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

/* --- Layout --- */
header, main, footer {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 0 1.5rem;
}

main {
  flex: 1;
  padding: 3rem 0;
}

/* --- Header & Navigation --- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem;
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.9);
}

.logo-title h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

nav ul {
  display: flex;
  list-style: none;
  gap: 2rem;
}

nav a {
  position: relative;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.5rem 0;
}

nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0%;
  height: 2px;
  background-color: var(--primary);
  transition: width 0.3s ease;
}

nav a:hover, nav a.active {
  color: var(--primary);
}

nav a:hover::after, nav a.active::after {
  width: 100%;
}

/* --- Footer --- */
footer {
  text-align: center;
  padding: 1.5rem;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-light);
}

/* --- Sections --- */
section {
  background-color: var(--bg-color);
  border-radius: 12px;
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

/* --- Hero Section --- */
.hero {
  display: flex;
  justify-content: space-between;
  gap: 3rem;
  align-items: center;
}

.hero-content {
  flex: 1;
}

.hero-content h2 {
  margin-bottom: 1.5rem;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hero-content p {
  font-size: 1.125rem;
  margin-bottom: 2rem;
  color: var(--text-secondary);
}

.hero-content button {
  padding: 0.875rem 2rem;
  background-color: var(--primary);
  color: white;
  font-weight: 500;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.hero-content button:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.hero-visual {
  flex: 1;
  display: flex;
  justify-content: center;
}

.hero-visual img {
  max-width: 100%;
  height: auto;
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

/* --- Table Application --- */
.table-app {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.table-app textarea {
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  resize: vertical;
  background-color: var(--bg-color);
  transition: var(--transition);
}

.table-app textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.table-app .actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.table-app .actions button {
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--primary);
  background-color: var(--bg-color);
  color: var(--primary);
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.table-app .actions button:first-of-type {
  background-color: var(--primary);
  color: white;
}

.table-app .actions button:hover {
  background-color: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* --- Table Container & Styling --- */
.table-container {
  overflow-x: auto;
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.table-container table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-color);
}

.table-container th, .table-container td {
  border: 1px solid var(--border-color);
  padding: 1rem;
  text-align: left;
  vertical-align: top;
}

.table-container th {
  background-color: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
}

.table-container tr:nth-child(even) {
  background-color: var(--bg-secondary);
}

.table-container tr:hover td {
  background-color: var(--primary-light);
}

.table-container td[contenteditable="true"]:focus {
  outline: 2px solid var(--primary);
  background-color: white;
}

.table-container th:first-child, .table-container td:first-child {
  width: 70px;
  text-align: center;
}

/* Full translation mode */
.table-container.full-translation table th:first-child,
.table-container.full-translation table td:first-child,
.table-container.full-translation table th:nth-child(2),
.table-container.full-translation table td:nth-child(2) {
  display: none;
}

.table-container.full-translation table th:nth-child(3),
.table-container.full-translation table td:nth-child(3) {
  width: 100%;
}

/* --- Feature List --- */
.feature-list {
  list-style: none;
  padding-left: 0;
  margin-top: 1.5rem;
}

.feature-list li {
  position: relative;
  margin-bottom: 1rem;
  padding-left: 2rem;
  color: var(--text-secondary);
}

.feature-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary);
  font-weight: 600;
}

/* --- Floating & Panel Controls --- */
.floating-menu, .read-panel, .search-panel {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.floating-menu {
  bottom: 2rem;
}

.read-panel, .search-panel {
  display: none;
}

.read-panel {
  bottom: 7rem;
}

.search-panel {
  bottom: 12rem;
}

.floating-menu button, .read-panel button, .search-panel button {
  padding: 0.5rem;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: var(--transition);
}

.floating-menu button:hover, .read-panel button:hover, .search-panel button:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.read-panel label, .search-panel label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.read-panel select, .read-panel input,
.search-panel select, .search-panel input {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-color);
}

.reading-highlight {
  background-color: rgba(0, 0, 0, 0.1) !important;
}

.search-highlight {
  background-color: rgba(0, 0, 0, 0.1);
}

.active-highlight {
  background-color: rgba(0, 0, 0, 0.2);
}

/* --- Context Menu --- */
.context-menu {
  position: fixed;
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 0.5rem 0;
  z-index: 2000;
  min-width: 200px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: var(--transition);
}

.context-menu.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  text-align: left;
}

.context-menu button:hover {
  background-color: var(--primary-light);
}

.context-menu hr {
  margin: 0.5rem 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

.context-menu .material-icons {
  color: var(--text-secondary);
}

/* --- Router Fade Animation --- */
.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

.fade-out {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-15px); }
}

/* --- Loading State --- */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

.loading::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Error State --- */
.error-page {
  text-align: center;
  padding: 3rem;
}

.error-page h2 {
  margin-bottom: 1rem;
  color: var(--primary);
}

/* --- Responsive Breakpoints --- */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.5rem;
  }

  nav ul {
    gap: 1.5rem;
    margin-top: 1rem;
  }

  .hero {
    flex-direction: column;
    text-align: center;
  }

  .hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .hero-content button {
    align-self: center;
  }

  .hero-visual {
    margin-top: 2rem;
  }

  h2 {
    font-size: 1.75rem;
  }
}

@media (max-width: 480px) {
  header {
    padding: 1rem;
  }

  .logo-title h1 {
    font-size: 1.25rem;
  }

  nav ul {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  nav a {
    display: block;
    padding: 0.5rem 0;
  }

  section {
    padding: 1.5rem;
  }

  .table-app .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .table-app .actions button {
    width: 100%;
  }
}
