/* Anthology Builder - Main Stylesheet */

/* Basic reset and typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Page management */
.page {
    display: none;
    padding: 2rem 0;
}

.page.active {
    display: block;
}

/* Header styles */
.main-header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    text-align: center;
}

.site-title {
    font-size: 3rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
}

.site-tagline {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.main-nav {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Page headers */
.page-header {
    max-width: 1200px;
    margin: 0 auto 2rem;
    padding: 0 2rem;
    text-align: center;
}

.page-header h2 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.page-description {
    font-size: 1.1rem;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
}

/* Layout grids */
.builder-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.build-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Sidebar styles */
.filters-sidebar, .stories-sidebar {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 2rem;
}

.filters-sidebar h3, .stories-sidebar h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* Search section */
.search-section {
    margin-bottom: 2rem;
}

.single-search-bar input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    margin-bottom: 0.5rem;
}

.search-options {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #666;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 6px;
}

.help-tooltip {
    margin-left: 4px;
    display: inline-block;
    width: 16px;
    height: 16px;
    background: #007cba;
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 11px;
    line-height: 16px;
    cursor: help;
}

/* Keywords section */
.keywords-section {
    margin-bottom: 1rem;
}

.keywords-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #333;
}

.keyword-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1rem;
}

.keyword-tag {
    background: #e9ecef;
    border: 1px solid #ced4da;
    color: #495057;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.keyword-tag:hover {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

/* Button styles */
.button {
    background: #007cba;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.button:hover {
    background: #005a8b;
    transform: translateY(-1px);
}

.button.secondary {
    background: #6c757d;
}

.button.secondary:hover {
    background: #545b62;
}

.button.danger {
    background: #dc3545;
}

.button.danger:hover {
    background: #c82333;
}

.button.small {
    padding: 6px 12px;
    font-size: 12px;
}

.button.large {
    padding: 15px 30px;
    font-size: 16px;
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.search-buttons {
    display: flex;
    gap: 0.5rem;
}

/* My Anthology section */
.my-anthology-section {
    border-top: 1px solid #e9ecef;
    padding-top: 1.5rem;
}

.anthology-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.selected-count {
    color: #007cba;
    font-size: 1.3rem;
}

.selected-stories {
    border: 1px solid #ddd;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    margin-bottom: 1rem;
}

.selected-stories.has-stories {
    padding: 10px;
}

.selected-story-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: move;
    transition: transform 0.2s;
}

.selected-story-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.drag-handle {
    color: #6c757d;
    font-size: 16px;
    margin-right: 8px;
    cursor: grab;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.story-content {
    flex: 1;
    display: flex;
    align-items: center;
}

.story-order {
    font-weight: bold;
    color: #6c757d;
    min-width: 25px;
}

.story-title {
    flex: 1;
    margin-left: 10px;
    font-size: 0.9em;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-btn:hover {
    background: #c82333;
}

.anthology-actions {
    margin-bottom: 1rem;
}

.anthology-note {
    font-size: 0.85rem;
    color: #666;
    text-align: center;
    font-style: italic;
}

/* Stories main content */
.stories-main, .config-main {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.stories-header h2 {
    color: #2c3e50;
    font-size: 1.8rem;
}

.results-info {
    color: #666;
    font-size: 0.9rem;
}

/* Stories grid */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.story-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.story-card:hover {
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,123,186,0.15);
}

.story-card.selected {
    border-color: #28a745;
    background: #f8fff9;
}

.story-header h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.story-author {
    color: #666;
    font-style: italic;
    margin-bottom: 0.25rem;
}

.story-date {
    color: #999;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.story-description {
    color: #555;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.story-actions {
    text-align: right;
}

.add-story-btn.added {
    background: #28a745;
    cursor: not-allowed;
}

.add-story-btn.added:hover {
    background: #28a745;
    transform: none;
}

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

.pagination button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.pagination button:hover {
    background: #f8f9fa;
}

.pagination button.active {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

/* Build page styles */
.stories-list {
    border: 1px solid #ddd;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.story-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    background: white;
}

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

.story-number {
    background: #007cba;
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 1rem;
    flex-shrink: 0;
}

.story-info {
    flex: 1;
}

.story-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.story-author {
    color: #666;
    font-size: 0.9rem;
}

.story-actions {
    margin-left: 1rem;
}

.remove-story-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reorder-note {
    font-size: 0.85rem;
    color: #666;
    text-align: center;
    font-style: italic;
}

/* Form styles */
.config-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e9ecef;
}

.config-section:last-child {
    border-bottom: none;
}

.config-section h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0,123,186,0.1);
}

.form-note {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Keyword chips */
.keyword-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.keyword-chip {
    display: flex;
    align-items: center;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.keyword-chip:hover {
    border-color: #007cba;
    background: #f8f9fa;
}

.keyword-chip input[type="radio"] {
    margin-right: 8px;
}

.keyword-chip input[type="radio"]:checked + .chip-text {
    color: #007cba;
    font-weight: 600;
}

/* Cover preview */
.cover-preview {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f8f9fa;
    text-align: center;
}

.cover-image-container {
    margin-top: 1rem;
}

.cover-image-container img {
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Progress bar */
.generation-status {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f8f9fa;
    text-align: center;
}

.status-message {
    margin-bottom: 1rem;
    font-weight: 600;
    color: #007cba;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007cba, #3498db);
    width: 0%;
    transition: width 0.3s ease;
}

/* Download section */
.download-section {
    margin-top: 1rem;
    padding: 2rem;
    border: 2px solid #28a745;
    border-radius: 8px;
    background: #f8fff9;
    text-align: center;
}

.download-section h4 {
    color: #28a745;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.download-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Admin page styles */
.admin-tabs {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 2rem;
    gap: 0;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 2rem;
}

.tab-link {
    padding: 12px 24px;
    text-decoration: none;
    color: #6c757d;
    border: none;
    background: none;
    border-bottom: 3px solid transparent;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 14px;
}

.tab-link:hover {
    color: #007cba;
    background-color: #f8f9fa;
}

.tab-link.active {
    color: #007cba;
    border-bottom-color: #007cba;
    background-color: #f8f9fa;
}

.admin-tab-content {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.admin-tab-content.active {
    display: block;
}

.content-section {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.content-section h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

/* Analytics styles */
.analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 4px solid #007cba;
}

.stat-card h3 {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
}

.stat-list {
    font-size: 0.9rem;
    color: #666;
}

.analytics-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Keyword management */
.add-keyword-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.add-keyword-form input[type="text"] {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.keyword-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.keyword-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.keyword-info {
    display: flex;
    flex-direction: column;
}

.keyword-name {
    font-weight: bold;
    color: #333;
}

.keyword-usage {
    font-size: 0.9em;
    color: #666;
}

/* Cleanup styles */
.cleanup-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.cleanup-results {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.cleanup-results h4 {
    color: #007cba;
    margin-bottom: 0.5rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .builder-layout,
    .build-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .filters-sidebar,
    .stories-sidebar {
        position: static;
    }
    
    .main-nav {
        flex-direction: column;
        gap: 1rem;
    }
    
    .site-title {
        font-size: 2rem;
    }
    
    .stories-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
        padding: 0 1rem;
    }
    
    .download-actions {
        flex-direction: column;
    }
}

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

.empty-state p {
    margin-bottom: 1rem;
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: #666;
    font-size: 1.1rem;
}

.no-results h3 {
    margin: 0 0 1rem 0;
    color: #333;
    font-style: normal;
}

.no-results p {
    margin: 0 0 1.5rem 0;
    font-style: italic;
}

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

.text-muted {
    color: #666;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

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

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

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-content h4 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.keyword-item .keyword-actions {
    display: flex;
    gap: 0.5rem;
}

/* Cover overlay styles */
.cover-wrapper {
    position: relative;
    display: inline-block;
}

.cover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 1rem;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
}

.cover-title-section {
    text-align: center;
}

.cover-title {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.cover-issue {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.cover-subtitle {
    font-size: 1rem;
    font-style: italic;
    opacity: 0.9;
}

.cover-editor-section {
    text-align: center;
}

.cover-editor {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Page navigation */
.page-nav {
    margin-bottom: 1rem;
    text-align: left;
}

/* Admin story management */
.admin-stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.admin-story-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    transition: box-shadow 0.3s ease;
}

.admin-story-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.admin-story-card .story-header h4 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.admin-story-card .story-author {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.admin-story-card .story-description {
    color: #555;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.admin-story-card .story-details {
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #666;
}

.admin-story-card .story-details p {
    margin-bottom: 0.25rem;
}

.admin-story-card .story-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.story-form {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.stories-list-admin {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
}

.stories-list-admin h4 {
    margin-bottom: 1rem;
    color: #2c3e50;
}