/* Color scheme - edit these variables to change the color scheme */
:root {
    --color-nav-bg: #1B4332;
    --color-nav-text: #E8F5E9;
    --color-main-bg: #FFFFFF;
    --color-main-text: #1A1A1A;
    --color-accent: #00A86B;
    --color-accent-hover: #008f5b;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-nav-bg);
    color: var(--color-nav-text);
    padding: 0.5rem 1rem;
    z-index: 1001;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Confirmation modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
}

.modal-content p {
    margin: 0 0 1.5rem 0;
    color: #444;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--color-main-bg);
    color: var(--color-main-text);
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background-color: var(--color-nav-bg);
    padding: 1rem;
    color: var(--color-nav-text);
}

.navbar-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--color-nav-text);
    text-decoration: none;
}

/* Shared navbar interactive element styles */
.navbar-links a,
.navbar-nav a,
.logout-form button,
.dropdown-toggle {
    color: var(--color-nav-text);
    text-decoration: none;
}

.navbar-links a:hover,
.navbar-nav a:hover,
.logout-form button:hover,
.dropdown-toggle:hover {
    opacity: 1;
}

.navbar-links a:focus,
.navbar-nav a:focus,
.logout-form button:focus,
.dropdown-toggle:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.navbar-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
    margin-left: 2rem;
    flex-grow: 1;
}

.navbar-links a {
    opacity: 0.9;
}

.navbar-nav {
    display: flex;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-nav a {
    opacity: 0.8;
}

.logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.logout-form button {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    padding: 0;
    opacity: 0.8;
}

/* Navbar dropdown menus */
.navbar-menus {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}

.dropdown {
    position: relative;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    padding: 0.5rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dropdown-arrow {
    font-size: 0.75rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    list-style: none;
    margin: 0.25rem 0 0 0;
    padding: 0.5rem 0;
    min-width: 150px;
    z-index: 1000;
}

.dropdown-menu-right {
    left: auto;
    right: 0;
}

.dropdown.open .dropdown-menu {
    display: block;
}

.dropdown.open .dropdown-toggle {
    opacity: 1;
}

.dropdown-menu li a,
.dropdown-menu li button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    color: var(--color-main-text);
    text-decoration: none;
    text-align: left;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
}

.dropdown-menu li a:hover,
.dropdown-menu li button:hover {
    background-color: #f5f5f5;
    color: var(--color-main-text);
}

.dropdown-menu li a:focus,
.dropdown-menu li button:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
    background-color: #e9ecef;
}

.dropdown-form {
    margin: 0;
    padding: 0;
}

/* Main content */
.main-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.content-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Forms - shared input styles */
.form-group input,
.form-group textarea,
.form-group select,
.search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.search-input:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-color: var(--color-accent);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

/* Search form */
.search-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
}

/* Buttons - shared base styles */
.btn,
.btn-small {
    display: inline-block;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn:focus,
.btn-small:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.btn {
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

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

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

.btn-full-width {
    width: 100%;
}

/* Error messages */
.errorlist {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0 0;
    color: #a94442;
    font-size: 0.875rem;
}

.form-errors {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    color: #721c24;
}

/* Links */
a {
    color: var(--color-accent);
}

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

/* Utility */
.text-center {
    text-align: center;
}

.text-truncate,
.entry-row-preview,
.entry-row-addendum,
.recent-preview,
.entry-row-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mt-1 {
    margin-top: 1rem;
}

/* Inline forms and link-styled buttons */
.inline-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.link-button {
    background: none;
    border: none;
    color: var(--color-accent);
    cursor: pointer;
    font: inherit;
    padding: 0;
    text-decoration: underline;
}

.link-button:hover {
    color: var(--color-accent-hover);
}

.link-button:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Page header with title and actions */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0;
}

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

/* Secondary and danger buttons */
.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: #8b2635;
    color: white;
}

.btn-danger:hover {
    background-color: #6d1f2a;
}

/* Small buttons - defaults to secondary color */
.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    background-color: #6c757d;
    color: white;
}

.btn-small:hover {
    background-color: #5a6268;
}

.btn-small.btn-danger {
    background-color: #8b2635;
}

.btn-small.btn-danger:hover {
    background-color: #6d1f2a;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.form-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.form-actions-row .form-actions {
    margin-top: 0;
}

.delete-form {
    margin: 0;
}

/* Form textarea and select additional styling */
.form-group textarea {
    font-family: inherit;
    resize: vertical;
}

.form-group select {
    background-color: white;
}

/* Entry list */
.entry-list {
    margin-top: 1rem;
}

.entry-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
    gap: 1rem;
}

.entry-row:last-child {
    border-bottom: none;
}

.entry-row-date {
    flex-shrink: 0;
    font-weight: 500;
    width: 100px;
}

.entry-row-preview {
    flex-grow: 1;
    color: #666;
}

.entry-row-addendum {
    color: #666;
    text-align: right;
    max-width: 25ch;
}

.entry-row-actions {
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
}

/* Entry detail */
.entry-content {
    margin: 1rem 0;
    line-height: 1.8;
}

.entry-notes {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.entry-notes h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #666;
}

.entry-meta {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    color: #666;
}

/* Tags */
.entry-tags {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: #e9ecef;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #495057;
}

.tag-link {
    text-decoration: none;
    cursor: pointer;
}

.tag-link:hover {
    background-color: #dee2e6;
    color: #495057;
}

/* Inline tags in list rows */
.entry-tags-inline {
    margin-left: 0.5rem;
}

.entry-tags-inline .tag {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
}

/* Active filter indicator */
.active-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.filter-clear {
    margin-left: 0.25rem;
    color: #666;
    text-decoration: none;
    font-size: 1.25rem;
    line-height: 1;
}

.filter-clear:hover {
    color: #333;
}

/* Empty state */
.empty-state {
    text-align: center;
    color: #666;
    padding: 2rem 0;
}

/* Quick add buttons */
.quick-add-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.quick-add-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s;
}

.quick-add-btn:hover {
    background-color: #e9ecef;
    color: #333;
}

.quick-add-btn:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.quick-add-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.quick-add-label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Recent items list */
.recent-list {
    margin-top: 0.5rem;
}

.recent-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    gap: 0.75rem;
    border-bottom: 1px solid #eee;
}

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

.recent-icon {
    flex-shrink: 0;
}

.recent-item a {
    font-weight: 500;
    flex-shrink: 0;
}

.recent-preview {
    color: #666;
}

.recent-date {
    color: #666;
    font-size: 0.875rem;
    margin-left: auto;
}

/* Entry row with title (for stories) */
.entry-row-title {
    flex-grow: 1;
}

/* Form row for side-by-side fields */
.form-row {
    display: flex;
    gap: 1rem;
}

.form-group-half {
    flex: 1;
}

/* Form help text */
.form-help {
    display: block;
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Story date display */
.story-date {
    color: #666;
    font-style: italic;
    margin: 0 0 1rem 0;
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.filter-tab {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #666;
    border-radius: 4px;
}

.filter-tab:hover {
    background-color: #f5f5f5;
    color: #333;
}

.filter-tab.active {
    background-color: var(--color-accent);
    color: white;
}

.filter-tab.active:hover {
    background-color: var(--color-accent-hover);
}

/* Book-specific styles */
.book-authors {
    color: #666;
    font-style: italic;
    margin: 0 0 1rem 0;
}

.book-dates {
    margin-bottom: 1rem;
}

.book-dates p {
    margin: 0.25rem 0;
}

.book-row-author {
    color: #666;
    margin-left: 0.5rem;
}

.book-row-format {
    color: #888;
    margin-left: 0.5rem;
    font-size: 0.875rem;
}

.status-reading,
.status-finished {
    background-color: #d4edda;
    color: #155724;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* Read-only book info (when editing a reading) */
.book-info-readonly {
    padding: 0.75rem;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.book-info-readonly .book-row-author {
    margin-left: 0;
}

.edit-book-link {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

/* Entry row status column */
.entry-row-status {
    flex-shrink: 0;
    width: 100px;
    text-align: right;
    color: #666;
    font-size: 0.875rem;
}

/* Author sort name in author list */
.author-sort-name {
    color: #999;
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

/* Flash messages */
.messages {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem 1rem 0 1rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.message-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.message-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.message-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

.message-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Pagination */
.pagination {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.pagination-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.25rem;
}

.pagination-link {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: var(--color-main-text);
    background-color: white;
    min-width: 2.5rem;
    text-align: center;
}

.pagination-link:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
    color: var(--color-main-text);
}

.pagination-current {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

.pagination-current:hover {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

.pagination-ellipsis {
    display: inline-block;
    padding: 0.5rem 0.5rem;
    color: #666;
}

/* List footer - pagination + import/export buttons */
.list-footer {
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.list-footer .pagination {
    margin-top: 0;
    justify-content: flex-start;
}

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

/* Mobile styles */
@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
    }

    .content-card {
        padding: 0.5rem;
        border-radius: 4px;
        box-shadow: none;
    }

    /* Entry rows: allow wrapping */
    .entry-row {
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
    }

    /* Books: title full width, status below */
    .entry-row-title {
        width: 100%;
        white-space: normal;
    }

    .entry-row-status {
        width: auto;
        text-align: left;
    }

    /* Movies: date + title on one line, hide notes */
    .entry-row-date {
        width: auto;
    }

    .entry-row-preview {
        white-space: normal;
    }

    .entry-row-addendum {
        display: none;
    }

    /* TV Shows: actions on second line */
    .entry-row-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .list-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .list-footer .pagination {
        width: 100%;
        justify-content: center;
    }

    .list-footer-actions {
        margin-top: 2em;
        width: 100%;
        justify-content: center;
    }
}

/* TV Shows specific styles */
.show-progress {
    color: #666;
    margin-bottom: 1.5rem;
}

.season-section {
    margin-bottom: 1.5rem;
}

.season-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.5rem;
}

.season-header h3 {
    margin: 0;
    font-size: 1rem;
}

.episode-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.episode-row {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    gap: 0.75rem;
    border-radius: 4px;
}

.episode-row:hover {
    background-color: #f5f5f5;
}

.episode-watched {
    color: #666;
}

.episode-watched .episode-code,
.episode-watched .episode-title {
    text-decoration: line-through;
    opacity: 0.7;
}

.episode-toggle {
    display: inline;
}

.episode-checkbox {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0;
    line-height: 1;
    color: var(--color-accent);
}

.episode-checkbox:hover {
    opacity: 0.8;
}

.episode-code {
    font-weight: 500;
    min-width: 60px;
}

.episode-title {
    color: #666;
}

.episode-edit-link {
    margin-left: auto;
    font-size: 0.875rem;
    color: var(--color-accent);
    text-decoration: none;
}

.episode-edit-link:hover {
    text-decoration: underline;
}

.episode-count {
    color: #999;
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

/* Import result styles */
.import-result {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.import-result-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.import-result-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

.import-errors {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.import-errors h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #721c24;
}

.error-log {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.875rem;
    color: #721c24;
    max-height: 300px;
    overflow-y: auto;
}

.error-log li {
    padding: 0.25rem 0;
    border-bottom: 1px solid #f5c6cb;
}

.error-log li:last-child {
    border-bottom: none;
}

/* Simple data tables */
.episode-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.episode-table th,
.episode-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.episode-table th {
    font-weight: 500;
    color: #666;
}

/* Button loading state */
.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-loading::before {
    content: "";
    width: 1rem;
    height: 1rem;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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