/* My Word Lists Page */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

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

:root {
  --primary: #e63946;
  --secondary: #457b9d;
  --accent: #f4a261;
  --dark: #1d3557;
  --light: #f1faee;
  --bg: #fef9ef;
  --text: #2d3436;
  --text-light: #636e72;
}

body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  word-break: auto-phrase;
  line-break: strict;
  overflow-wrap: break-word;
}

[x-cloak] { display: none !important; }

.page-header {
  background: var(--dark);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h1 { font-size: 1.25rem; font-weight: 700; }

.page-header a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.page-header a:hover { text-decoration: underline; }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.top-bar .count {
  font-size: 0.85rem;
  color: var(--text-light);
}

.top-bar-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--secondary);
  color: white;
}

.btn-primary:hover { background: var(--dark); }

.btn-secondary {
  background: white;
  color: var(--secondary);
  border: 1px solid var(--light);
}

.btn-secondary:hover { background: var(--light); }

/* Create / Import forms */
.form-card {
  background: white;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(29, 53, 87, 0.06);
}

.form-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}

.form-card input,
.form-card textarea,
.form-card select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--light);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 0.75rem;
}

.form-card textarea { resize: vertical; }

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Word list cards */
.list-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.list-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(29, 53, 87, 0.06);
  overflow: hidden;
}

.list-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
}

.list-card-header:hover {
  background: var(--light);
}

.list-card-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.list-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-count {
  font-size: 0.8rem;
  color: var(--text-light);
  flex-shrink: 0;
}

.current-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--secondary);
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.list-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.list-card-actions .btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem 0.4rem;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.delete-btn:hover {
  opacity: 1;
  color: var(--primary);
}

/* Word table */
.word-table-wrap {
  padding: 0 1.25rem 1rem;
  border-top: 1px solid var(--light);
}

.word-table {
  width: 100%;
  border-collapse: collapse;
}

.word-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  padding: 0.6rem 0.5rem 0.4rem;
  border-bottom: 1px solid var(--light);
}

.word-table td {
  padding: 0.5rem 0.5rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--light);
  vertical-align: middle;
}

.word-table tr:last-child td { border-bottom: none; }

.word-table .word-col { font-weight: 600; color: var(--dark); }
.word-table .reading-col { color: var(--secondary); font-size: 0.85rem; }
.word-table .english-col { color: var(--text-light); }

.word-table .mastered-col {
  width: 30px;
  text-align: center;
}

.word-table .action-col {
  width: 30px;
  text-align: center;
}

.word-table .action-col button {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s;
}

.word-table .action-col button:hover {
  opacity: 1;
  color: var(--primary);
}

/* Loading & empty states */
.loading-state, .empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

/* Auth prompt */
.auth-prompt {
  text-align: center;
  padding: 4rem 1rem;
}

.auth-prompt p {
  color: var(--text-light);
  margin-bottom: 1rem;
}

.auth-prompt a {
  color: var(--secondary);
  font-weight: 600;
}

/* Import mode toggle */
.import-mode-toggle {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--light);
  margin-bottom: 0.75rem;
}

.import-mode-toggle button {
  padding: 0.35rem 1rem;
  border: none;
  background: white;
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.import-mode-toggle button.active {
  background: var(--secondary);
  color: white;
}

.import-mode-toggle button:not(.active):hover {
  background: var(--light);
}

/* OCR styles */
.ocr-preview {
  margin-bottom: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--light);
}

.ocr-preview img {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  background: #f5f5f5;
}

.ocr-loading {
  text-align: center;
  padding: 1rem 0;
  color: var(--text-light);
  font-size: 0.85rem;
}

.ocr-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-light);
  flex-wrap: wrap;
  gap: 0.25rem;
}

.ocr-actions-links {
  display: flex;
  gap: 0.75rem;
}

.ocr-actions a {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 600;
}

.ocr-actions a:hover {
  text-decoration: underline;
}

.ocr-word-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--light);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.ocr-word-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--light);
  transition: background 0.1s;
}

.ocr-word-item:last-child {
  border-bottom: none;
}

.ocr-word-item:hover {
  background: var(--light);
}

.ocr-word-item input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .page-header { padding: 0.8rem 1rem; }
  .container { padding: 1rem 0.75rem 3rem; }

  .list-card-header {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    gap: 0.4rem;
  }

  .list-card-info {
    width: 100%;
  }

  .list-card-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 0.4rem;
    padding-top: 0.1rem;
  }

  .list-card-actions .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
  }

  .word-table { font-size: 0.85rem; }
  .word-table th, .word-table td { padding: 0.4rem 0.35rem; }
}
