/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 20px;
}

.header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.header h1 {
    color: #2c3e50;
    font-size: 2rem;
    font-weight: 600;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    align-items: start;
}

/* Sources Section */
.sources-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sources-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* Form Styles */
.add-source-form {
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: #555;
}

.form-group input {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.form-group button {
    padding: 12px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.form-group button:hover {
    background: #2980b9;
}

.form-group button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* Sources List */
.sources-list {
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.sources-items {
    list-style: none;
}

.source-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #3498db;
}

.source-url {
    font-size: 14px;
    color: #555;
    word-break: break-all;
    flex: 1;
    margin-right: 10px;
}

.source-delete {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.source-delete:hover {
    background: #c0392b;
}

/* Articles Section */
.articles-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.articles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.articles-header h2 {
    color: #2c3e50;
    font-size: 1.5rem;
}

.articles-controls {
    display: flex;
    gap: 10px;
}

.filter-toggle,
.refresh-button {
    padding: 8px 16px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-toggle:hover,
.refresh-button:hover {
    background: #3498db;
    color: white;
}

.filter-toggle.active {
    background: #3498db;
    color: white;
}

/* Articles List */
.articles-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.article-item {
    padding: 16px;
    border: 1px solid #eee;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.article-item:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.article-item.read {
    opacity: 0.6;
    background: #f8f9fa;
}

.article-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    line-height: 1.4;
}

.article-item.read .article-title {
    color: #7f8c8d;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.article-date {
    font-weight: 500;
}

.article-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.article-status.unread {
    background: #e8f4fd;
    color: #3498db;
}

.article-status.read {
    background: #d5f4e6;
    color: #27ae60;
}

.article-description {
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

/* Loading States */
.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
    font-style: italic;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.error-message {
    background: #fdf2f2;
    color: #e74c3c;
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid #e74c3c;
    margin-bottom: 16px;
    font-size: 14px;
}

.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    padding: 16px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1001;
    max-width: 400px;
}

.error-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.empty-state p {
    font-size: 16px;
    line-height: 1.6;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1002;
}

.modal {
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    color: #2c3e50;
    font-size: 18px;
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    color: #555;
    line-height: 1.6;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .articles-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .articles-controls {
        justify-content: center;
    }
    
    .form-group {
        gap: 12px;
    }
    
    .source-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .source-url {
        margin-right: 0;
    }
    
    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .error-toast {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .sources-section,
    .articles-section {
        padding: 15px;
    }
    
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .modal {
        width: 95%;
    }
}