/* Global styles */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.5;
}

header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e5e5;
}

.top-bar {
    text-align: left;
    margin-bottom: 0.5rem;
}

.back-link {
    color: #1a73e8;
    text-decoration: none;
    font-size: 0.9rem;
}

/* Help button in top bar */
.help-btn {
    margin-left: 0.5rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.9rem;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.help-btn:hover {
    background-color: #e0e0e0;
}

h1 {
    margin: 0.5rem 0;
    font-size: 1.8rem;
    color: #333;
}

.tagline {
    margin: 0;
    font-size: 1rem;
    color: #666;
}

/* Cards */
.card {
    background-color: #fff;
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-width: 900px;
}

label {
    display: block;
    margin-top: 0.5rem;
    margin-bottom: 0.2rem;
}

input[type="text"], textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.upload-controls {
    margin-top: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    background-color: #e0e0e0;
    color: #333;
    transition: background-color 0.2s ease;
}

button:hover {
    background-color: #d5d5d5;
}

button.primary {
    background-color: #1a73e8;
    color: #fff;
}

button.primary:hover {
    background-color: #1666c1;
}

/* Navigation */
nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 0.5rem 1rem;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.nav-btn.active, .nav-btn:hover {
    background-color: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
}

/* Secondary button (e.g., New Text) for nav */
button.secondary {
    background-color: #fafafa;
    border: 1px solid #ccc;
    color: #333;
}
button.secondary:hover {
    background-color: #e5e5e5;
}

/* Sections */
.mode-section {
    max-width: 1000px;
    margin: 1rem auto;
    padding: 1rem;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.hidden {
    display: none !important;
}

/* Learning mode layout */
.flex-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.flex-item.wide {
    flex: 3;
}
.flex-item.narrow {
    flex: 1;
    max-width: 320px;
}

.text-display {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.7rem;
    min-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    /* Allow text selection on mobile devices */
    user-select: text;
}

/* Selection actions (learning mode) */
.selection-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.small-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.small-btn:hover {
    background-color: #e0e0e0;
}

.list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.list li {
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.list li:nth-child(even) {
    background-color: #f9f9f9;
}

/* Buttons inside vocab and note lists */
.list li button.edit-btn, .list li button.delete-btn {
    margin-left: 0.5rem;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}
.list li button.edit-btn:hover, .list li button.delete-btn:hover {
    background-color: #d5d5d5;
}

/* Parallel table for review (original and translation) */
.parallel-table {
    width: 100%;
    border-collapse: collapse;
}
.parallel-table th, .parallel-table td {
    border: 1px solid #e1e1e1;
    padding: 0.4rem;
    vertical-align: top;
    word-break: break-word;
}
.parallel-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.list li strong {
    color: #1a73e8;
    margin-right: 0.3rem;
}

/* Translation mode */
.translation-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.translation-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}
.translation-row .sentence {
    font-weight: bold;
}
.translation-row textarea {
    min-height: 60px;
}
.translation-row button {
    align-self: flex-start;
}

/* POS mode */
.legend {
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Legend styling for review page POS colors */
.pos-legend-review {
  margin-bottom: 0.5rem;
}
.pos-legend-review .legend-item {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}
.pos-legend {
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.85rem;
    cursor: pointer;
    color: #fff;
}
.pos-legend[data-category="subject"] { background-color: #e53935; }
.pos-legend[data-category="verb"]    { background-color: #1e88e5; }
.pos-legend[data-category="complement"] { background-color: #43a047; }
.pos-legend[data-category="object"] { background-color: #f4511e; }
.pos-legend[data-category="modifier"] { background-color: #8e24aa; }

/* Highlight selected legend */
.pos-legend.selected {
    outline: 2px solid #000;
}

.pos-container {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.7rem;
    min-height: 300px;
    overflow-y: auto;
}

.pos-word {
    cursor: pointer;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    margin: 0.1rem;
    display: inline-block;
}
.pos-word.subject { background-color: rgba(229, 57, 53, 0.2); color: #C62828; }
.pos-word.verb    { background-color: rgba(30, 136, 229, 0.2); color: #1565C0; }
.pos-word.complement { background-color: rgba(67, 160, 71, 0.2); color: #2E7D32; }
.pos-word.object { background-color: rgba(244, 81, 30, 0.2); color: #BF360C; }
.pos-word.modifier { background-color: rgba(142, 36, 170, 0.2); color: #6A1B9A; }

/* POS category picker overlay */
.pos-picker {
    position: absolute;
    display: flex;
    gap: 0.2rem;
    background-color: #ffffff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    padding: 0.3rem;
    z-index: 3000;
}
.pos-picker.hidden {
    display: none;
}
.pos-picker button {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    color: #fff;
}
.pos-picker button[data-category="subject"] { background-color: #e53935; }
.pos-picker button[data-category="verb"] { background-color: #1e88e5; }
.pos-picker button[data-category="complement"] { background-color: #43a047; }
.pos-picker button[data-category="object"] { background-color: #f4511e; }
.pos-picker button[data-category="modifier"] { background-color: #8e24aa; }

/* Review */
.review-section {
    margin-top: 1rem;
}
.review-section h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}
.review-section pre {
    background-color: #f8f8f8;
    padding: 0.5rem;
    border: 1px solid #e1e1e1;
    border-radius: 4px;
    white-space: pre-wrap;
}

/* Export buttons */
.export-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal.hidden {
    display: none;
}
.modal-content {
    background-color: #fff;
    padding: 1rem;
    border-radius: 6px;
    width: 90%;
    max-width: 400px;
    position: relative;
    /* Ensure modal content fits on small screens and is scrollable */
    max-height: 80vh;
    overflow-y: auto;
}
.modal-close {
    position: absolute;
    top: 0.2rem;
    right: 0.5rem;
    font-size: 1.2rem;
    cursor: pointer;
    color: #555;
}
.modal-close:hover {
    color: #000;
}