/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    line-height: 1.6;
    color: #333;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.app-title {
    font-size: 2.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.app-subtitle {
    font-size: 1.125rem;
    color: #475569;
    font-weight: 500;
    opacity: 0.9;
    letter-spacing: 0.01em;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Control Panel */
.control-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.control-section {
    display: grid;
    grid-template-columns: 1fr 120px 160px;
    gap: 2rem;
    align-items: end;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
}

/* Radio Toggle */
.radio-toggle {
    display: flex;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 12px;
    padding: 6px;
    position: relative;
    border: 1px solid #e2e8f0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.radio-toggle input[type="radio"] {
    display: none;
}

.toggle-label {
    flex: 1;
    padding: 0.75rem 1.25rem;
    text-align: center;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    user-select: none;
}

.radio-toggle input[type="radio"]:checked + .toggle-label {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Form Inputs */
.select-input,
.text-input,
.number-input {
    padding: 0.875rem 1.125rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.select-input:hover,
.text-input:hover,
.number-input:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
}

.select-input:focus,
.text-input:focus,
.number-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15), 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.number-input {
    text-align: center;
    font-weight: 600;
}

/* Parse Button */
.parse-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.875rem 2rem;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    justify-self: start;
    min-width: 160px;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.parse-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 28px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.parse-button:active {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
}

.parse-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
}


.button-icon {
    width: 16px;
    height: 16px;
}

/* Results Container */
.results-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Split Layout */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 600px;
}

/* Articles Panel */
.articles-panel {
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1.5rem 2rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.025em;
}

.article-count {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.375rem 0.875rem;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.table-container {
    flex: 1;
    overflow-y: auto;
}

/* Articles Table */
.articles-table {
    width: 100%;
    border-collapse: collapse;
}

.articles-table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 1.25rem 1rem;
    text-align: left;
    font-weight: 700;
    font-size: 0.875rem;
    color: #1e293b;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.articles-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.article-row {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border-left: 3px solid transparent;
}

.article-row:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-left-color: #cbd5e1;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.article-row.selected {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-left-color: #667eea;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.article-thumbnail-cell {
    width: 90px;
    text-align: center;
    padding: 1rem 0.75rem;
}

.article-thumbnail-small {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.article-thumbnail-small:hover {
    transform: scale(1.05);
    border-color: #667eea;
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
}

.no-thumbnail {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 0.7rem;
    text-align: center;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.article-title-cell {
    max-width: 300px;
}

.title-text {
    display: block;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.5rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

.description-text {
    font-size: 0.8rem;
    color: #64748b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    font-weight: 400;
}

.article-date-cell {
    color: #64748b;
    font-size: 0.8rem;
    white-space: nowrap;
    min-width: 120px;
    font-weight: 500;
    padding: 1rem 0.75rem;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    background: white;
}

.preview-header {
    padding: 1.5rem 2rem;
    background: #667eea;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.025em;
}

.preview-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.preview-content {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    background: white;
}

/* Preview Placeholder */
.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #6b7280;
    padding: 2rem;
}

.placeholder-icon {
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

.preview-placeholder h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.preview-placeholder p {
    font-size: 0.95rem;
    color: #6b7280;
}

/* Article Preview Content */
.article-preview-content {
    line-height: 1.7;
    font-size: 1rem;
}

.article-preview-content h1,
.article-preview-content h2,
.article-preview-content h3,
.article-preview-content h4,
.article-preview-content h5,
.article-preview-content h6 {
    color: #1f2937;
    margin: 1.5rem 0 0.75rem 0;
    line-height: 1.3;
}

.article-preview-content p {
    margin-bottom: 1rem;
    color: #374151;
}

.article-preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.article-preview-content ul,
.article-preview-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.article-preview-content li {
    margin-bottom: 0.5rem;
    color: #374151;
}

.article-preview-content blockquote {
    border-left: 4px solid #667eea;
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-radius: 0 8px 8px 0;
    color: #475569;
}

.article-preview-content a {
    color: #667eea;
    text-decoration: none;
}

.article-preview-content a:hover {
    text-decoration: underline;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

.loading-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.loading-content p {
    color: #1e293b;
    font-weight: 600;
    margin: 0;
    font-size: 1.05rem;
    letter-spacing: 0.025em;
}

/* Error Toast */
.error-toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: #dc2626;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.3);
    z-index: 1001;
    max-width: 400px;
    font-weight: 500;
}

/* Footer */
.app-footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #6b7280;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.version {
    background: #e5e7eb;
    color: #374151;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

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

/* Mobile Responsive */
@media (max-width: 1024px) {
    .control-section {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .app-title {
        font-size: 2rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .control-panel {
        padding: 1.5rem;
    }
    
    .control-section {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .split-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: 0;
    }
    
    .articles-panel {
        border-right: none;
        border-bottom: 2px solid #e2e8f0;
        max-height: 350px;
        border-radius: 16px 16px 0 0;
    }
    
    .preview-panel {
        min-height: 450px;
        border-radius: 0 0 16px 16px;
    }
    
    .preview-content,
    .panel-header {
        padding: 1.25rem;
    }
    
    .articles-table th,
    .articles-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .article-thumbnail-small,
    .no-thumbnail {
        width: 55px;
        height: 55px;
    }
    
    .article-title-cell {
        max-width: 180px;
    }
    
    .title-text {
        font-size: 0.9rem;
    }
    
    .description-text {
        font-size: 0.75rem;
        -webkit-line-clamp: 1;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    gap: 0.5rem;
}

.tab-button {
    flex: 1;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-1px);
}

.tab-button.active {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Tab Content */
.tab-content {
    display: none;
}

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

/* AI Analysis Specific Styles */
.ai-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ai-button:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.stats-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    display: block;
}

.stat-label {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Hot News Indicator */
.hot-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.hot-badge::before {
    content: "🔥";
    font-size: 0.8rem;
}

/* Rating Display */
.rating-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rating-bar {
    width: 60px;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.rating-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd32a, #ff6b6b, #667eea);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.rating-value {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    min-width: 30px;
}

/* API Documentation Styles */
.api-docs-content {
    max-width: 800px;
}

.endpoint-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
}

.endpoint-card h5 {
    color: #667eea;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-weight: 600;
}

.endpoint-card p {
    color: #666;
    margin-bottom: 0.5rem;
}

.endpoint-card pre {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    overflow-x: auto;
}

.endpoint-card code {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    color: #333;
}

/* Responsive Design for Tabs */
@media (max-width: 768px) {
    .tab-navigation {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .tab-button {
        flex: 1 1 calc(50% - 0.125rem);
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}