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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px; /* Offset for sticky header */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

a {
    color: #0066cc;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Landing Page */
.landing-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.landing-content {
    text-align: center;
    max-width: 600px;
    background: white;
    padding: 60px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.landing-content h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #2c3e50;
    font-family: Georgia, serif;
}

.subtitle {
    font-size: 1.3em;
    color: #666;
    margin-bottom: 30px;
}

.description {
    color: #777;
    margin-bottom: 40px;
    line-height: 1.8;
}

.generate-button {
    display: inline-block;
    padding: 15px 40px;
    font-size: 1.1em;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}

.generate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
    text-decoration: none;
}

/* Chain Page Header */
.header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 100;
    position: relative;
}

.header h1 {
    font-size: 1.5em;
    color: #2c3e50;
    font-family: Georgia, serif;
    text-align: center;
}

.header-buttons {
    position: absolute;
    right: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-link {
    color: #667eea;
    font-weight: 600;
    transition: color 0.2s;
}

.header-link:hover {
    color: #5568d3;
    text-decoration: none;
}

.new-chain-button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border-radius: 5px;
    font-weight: 600;
    transition: background 0.2s;
}

.new-chain-button:hover {
    background: #5568d3;
    text-decoration: none;
}

/* Chain Container */
.chain-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
}

/* Chain Overview (Breadcrumb) */
.chain-overview {
    background: white;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.chain-label {
    font-weight: 600;
    color: #667eea;
    font-size: 1.1em;
    margin-right: 5px;
}

.chain-link {
    color: #2c3e50;
    font-weight: 500;
    transition: color 0.2s;
    padding: 5px 8px;
    border-radius: 4px;
}

.chain-link:hover {
    color: #667eea;
    background: #f0f0f0;
    text-decoration: none;
}

.chain-separator {
    color: #999;
    font-size: 1.2em;
    margin: 0 5px;
}

/* Person Card */
.person-card {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.person-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.person-name {
    font-size: 1.8em;
    color: #2c3e50;
    margin-bottom: 15px;
    font-family: Georgia, serif;
}

.person-name a {
    color: #2c3e50;
}

.person-name a:hover {
    color: #0066cc;
}

.person-description {
    color: #666;
    font-size: 1.05em;
    line-height: 1.7;
}

.person-categories {
    color: #888;
    font-size: 0.95em;
    margin-top: 10px;
    font-style: italic;
}

.person-categories strong {
    color: #555;
    font-style: normal;
}

/* Connection Arrow */
.connection-arrow {
    text-align: center;
    font-size: 2em;
    color: #667eea;
    margin: 10px 0;
}

/* Connection Section */
.connection-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    margin-bottom: 20px;
}

.connection-section h3 {
    font-size: 1.2em;
    color: #555;
    margin-bottom: 15px;
    font-weight: 600;
}

.sentence-list {
    list-style: none;
    padding-left: 0;
}

.sentence-list li {
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
    color: #444;
    line-height: 1.7;
}

.sentence-list li:last-child {
    border-bottom: none;
}

.no-sentences {
    color: #999;
    font-style: italic;
}

/* Save Chain Button */
.save-chain-container {
    text-align: center;
    margin: 20px 0;
}

.save-chain-button {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.save-chain-button:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
}

.save-chain-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.save-status {
    display: inline-block;
    margin-left: 15px;
    font-weight: 600;
}

.saved-chain-info {
    background: #e8f5e9;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
    color: #2e7d32;
    font-weight: 600;
}

.saved-chain-info p {
    margin-bottom: 15px;
}

.delete-chain-button {
    padding: 10px 25px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.delete-chain-button:hover:not(:disabled) {
    background: #c0392b;
    transform: translateY(-2px);
}

.delete-chain-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Search Box */
.search-box {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.search-box form {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.search-button {
    padding: 12px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.search-button:hover {
    background: #5568d3;
}

/* Saved Chains List */
.saved-chains-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.saved-chain-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
    color: inherit;
}

.saved-chain-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

.saved-chain-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.saved-chain-date {
    color: #999;
    font-size: 0.9em;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.no-results p {
    font-size: 1.2em;
    margin-bottom: 30px;
}

/* Chain Summary */
.chain-summary {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 40px;
}

.chain-summary h3 {
    font-size: 1.5em;
    color: #2c3e50;
    margin-bottom: 20px;
    font-family: Georgia, serif;
}

.chain-summary ol {
    padding-left: 25px;
}

.chain-summary li {
    margin-bottom: 15px;
    line-height: 1.6;
}

.summary-description {
    color: #666;
    font-size: 0.95em;
    display: block;
    margin-top: 5px;
}

.summary-categories {
    color: #888;
    font-size: 0.9em;
    display: block;
    margin-top: 3px;
}

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

.modal-content {
    background-color: white;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: modalFadeIn 0.3s ease;
}

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

.modal-content h2 {
    margin-top: 0;
    color: #333;
    font-size: 1.8em;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

/* Pagination */
.pagination-info {
    text-align: center;
    color: #666;
    font-size: 0.95em;
    margin: 20px 0 10px 0;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 30px 0;
    padding: 20px;
}

.pagination-button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pagination-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    text-decoration: none;
}

.pagination-button.disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination-button.disabled:hover {
    transform: none;
    box-shadow: none;
}

.pagination-info-inline {
    color: #666;
    font-weight: 500;
    font-size: 1em;
}

/* Error Message */
.error-message {
    text-align: center;
    padding: 60px 20px;
}

.error-message h2 {
    color: #e74c3c;
    margin-bottom: 30px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .landing-content {
        padding: 40px 30px;
    }

    .landing-content h1 {
        font-size: 2em;
    }

    .header {
        flex-direction: column;
        align-items: center;
        padding: 15px 10px;
        gap: 12px;
    }

    .header h1 {
        font-size: 1.2em;
        margin: 0;
        width: 100%;
        text-align: center;
    }

    .header-buttons {
        position: static;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .new-chain-button,
    .header-link {
        font-size: 0.85em;
        padding: 8px 12px;
    }

    .chain-container {
        padding: 10px;
    }

    .chain-overview {
        padding: 15px 20px;
        font-size: 0.9em;
    }

    .chain-label {
        font-size: 1em;
        width: 100%;
        margin-bottom: 5px;
    }

    .chain-link {
        font-size: 0.95em;
    }

    .person-card {
        padding: 20px;
    }

    .person-name {
        font-size: 1.5em;
    }

    .pagination {
        flex-direction: column;
        gap: 10px;
        padding: 15px 10px;
    }

    .pagination-button {
        width: 100%;
        max-width: 250px;
        text-align: center;
        padding: 12px 20px;
    }

    .pagination-info-inline {
        order: -1;
        margin-bottom: 10px;
    }
}
