/* === CSS Variables - LinkedIn Theme === */
:root {
    --bg-page: #f3f2ef;
    --bg-card: #ffffff;
    --color-primary: #0a66c2;
    --color-primary-hover: #004182;
    --color-text: rgba(0, 0, 0, 0.9);
    --color-text-secondary: rgba(0, 0, 0, 0.6);
    --color-border: rgba(0, 0, 0, 0.08);
    --color-border-strong: rgba(0, 0, 0, 0.15);
    --color-hover: rgba(0, 0, 0, 0.04);
    --color-lesson-bg: #f8fafc;
    --color-lesson-border: #0a66c2;
    
    --font-main: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --shadow-card: 0 0 0 1px var(--color-border), 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background: var(--bg-page);
    min-height: 100vh;
    color: var(--color-text);
    line-height: 1.5;
}

/* === Layout === */
.feed {
    max-width: 555px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* === Post Card === */
.post-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Post Header === */
.post-header {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    gap: 8px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), #0077b5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-initials {
    color: white;
    font-size: 20px;
    font-weight: 600;
}

.post-meta {
    flex: 1;
    min-width: 0;
}

.author-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text);
    line-height: 1.3;
}

.author-name:hover {
    color: var(--color-primary);
    cursor: pointer;
    text-decoration: underline;
}

.author-title {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-time {
    font-size: 12px;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.globe-icon {
    font-size: 12px;
}

.more-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    letter-spacing: 1px;
}

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

/* === Post Content === */
.post-content {
    padding: 0 16px 12px;
}

.post-headline {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.post-story {
    font-size: 14px;
    color: var(--color-text);
    line-height: 1.5;
}

.post-story p {
    margin-bottom: 12px;
}

.post-story p:last-child {
    margin-bottom: 0;
}

/* === Lesson Callout === */
.lesson-callout {
    background: var(--color-lesson-bg);
    border-left: 3px solid var(--color-lesson-border);
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.lesson-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.lesson-callout p {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    font-style: italic;
    margin: 0;
}

/* === Hashtags === */
.hashtags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 12px;
}

.hashtag {
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.hashtag:hover {
    text-decoration: underline;
}

/* === Reactions Summary === */
.reactions-summary {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-top: 1px solid var(--color-border);
    gap: 4px;
}

.reaction-icons {
    display: flex;
}

.reaction-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 50%;
    margin-right: -4px;
    background: var(--bg-card);
    border: 2px solid var(--bg-card);
}

.reaction-count {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-left: 8px;
}

/* === Action Bar === */
.action-bar {
    display: flex;
    border-top: 1px solid var(--color-border);
    padding: 4px 8px;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 8px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.action-btn:hover {
    background: var(--color-hover);
    color: var(--color-text);
}

.action-icon {
    font-size: 18px;
}

/* === Generate Button === */
.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 16px;
    padding: 12px 24px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 24px;
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
    min-height: 48px;
}

.generate-btn:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.generate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.generate-btn .btn-text,
.generate-btn .btn-loading {
    transition: opacity 0.2s;
}

.generate-btn .btn-loading {
    position: absolute;
    opacity: 0;
}

.generate-btn.loading .btn-text {
    opacity: 0;
}

.generate-btn.loading .btn-loading {
    opacity: 1;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === Error Card === */
.error-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 24px;
    text-align: center;
    margin-top: 16px;
}

.error-message {
    color: #c53030;
    font-size: 14px;
    margin-bottom: 12px;
}

.retry-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 24px;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* === Footer === */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--color-text-secondary);
    font-size: 12px;
}

.site-footer p {
    margin-bottom: 4px;
}

.disclaimer {
    font-size: 11px;
    opacity: 0.7;
}

/* === Utility === */
.hidden {
    display: none !important;
}

/* === Responsive === */
@media (max-width: 600px) {
    .feed {
        padding: 12px 0;
    }
    
    .post-card {
        border-radius: 0;
    }
    
    .generate-btn {
        margin: 16px;
        width: calc(100% - 32px);
    }
    
    .action-btn span:not(.action-icon) {
        display: none;
    }
    
    .action-icon {
        font-size: 20px;
    }
}

/* === Animation for new posts === */
.post-card.refreshing {
    animation: pulse 0.3s ease-out;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* === History Section === */
.history-section {
    margin-top: 24px;
}

.history-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.history-toggle:hover {
    background: var(--color-hover);
    color: var(--color-text);
}

.history-count {
    font-weight: 400;
    color: var(--color-text-secondary);
}

.history-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.history-arrow.expanded {
    transform: rotate(180deg);
}

.history-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* === History Card (Compact) === */
.history-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 12px 16px;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
}

.history-card:hover {
    box-shadow: 0 0 0 1px var(--color-primary), 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.history-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.history-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), #0077b5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-avatar span {
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.history-meta {
    flex: 1;
    min-width: 0;
}

.history-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
}

.history-time {
    font-size: 11px;
    color: var(--color-text-secondary);
}

.history-headline {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-reactions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--color-text-secondary);
}

.history-reactions span {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* === Clear History Button === */
.clear-history-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 8px 16px;
    background: none;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-size: 12px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.clear-history-btn:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #dc2626;
}

/* === Responsive History === */
@media (max-width: 600px) {
    .history-section {
        margin: 16px;
    }
    
    .history-card {
        border-radius: var(--radius-sm);
    }
}
