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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8fafc;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.header-content {
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
}

/* Form Section */
.form-section {
    max-width: 800px;
    margin: 0 auto;
}

.form-card {
    background: white;
    border-radius: 12px;
    padding: 3rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.form-card h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #1e3a8a;
}

.form-description {
    color: #6b7280;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    line-height: 1.7;
}

.analysis-form {
    margin-bottom: 3rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

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

.url-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1.1rem;
    transition: border-color 0.3s ease;
}

.url-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.analyze-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 180px;
    justify-content: center;
}

.analyze-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.4);
}

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

.button-spinner {
    display: flex;
    align-items: center;
}

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

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

/* Info Section */
.info-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 3rem;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.info-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.info-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1e3a8a;
}

.info-content p {
    color: #6b7280;
}

/* Progress Section */
.progress-section {
    max-width: 800px;
    margin: 0 auto;
}

.progress-card {
    background: white;
    border-radius: 12px;
    padding: 3rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.progress-card h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #1e3a8a;
}

.analyzing-url {
    color: #6b7280;
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

.progress-container {
    margin: 2rem 0;
}

.progress-stage {
    margin-bottom: 2rem;
}

.stage-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

#current-stage {
    font-size: 1.3rem;
    font-weight: 600;
    color: #1e3a8a;
}

#stage-details {
    color: #6b7280;
    font-size: 0.9rem;
}

.progress-bar-container {
    margin-bottom: 2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    font-weight: 600;
    color: #374151;
}

.progress-details {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
}

.detail-item {
    text-align: center;
}

.detail-label {
    color: #6b7280;
    font-size: 0.9rem;
}

.detail-value {
    font-weight: 600;
    color: #374151;
    font-size: 1.1rem;
}

.analyzing-spinner {
    margin-top: 2rem;
}

.spinner-large {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 1rem;
}

.spinner-text {
    color: #6b7280;
}

/* Error Messages */
.error-message {
    margin-top: 2rem;
}

.error-content {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 2rem;
}

.error-content h3 {
    color: #dc2626;
    margin-bottom: 1rem;
}

.error-content p {
    color: #991b1b;
    margin-bottom: 2rem;
}

.retry-button {
    background: #dc2626;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.retry-button:hover {
    background: #b91c1c;
}

/* Report Section */
.report-section {
    max-width: 1000px;
    margin: 0 auto;
}

.report-section h2 {
    font-size: 1.8rem;
    margin: 2rem 0 1rem 0;
    color: #1e3a8a;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

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

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.summary-card {
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.summary-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #1e3a8a;
}

.summary-value {
    color: #374151;
    line-height: 1.6;
}

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

.findings-group {
    margin-bottom: 3rem;
}

.findings-group:last-child {
    margin-bottom: 0;
}

.findings-group h2 {
    margin-bottom: 1.5rem;
    border: none;
    padding-bottom: 0;
}

.card-list {
    display: grid;
    gap: 1rem;
}

.findings-card {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 4px solid #3b82f6;
}

.findings-card.contradiction {
    border-left-color: #f59e0b;
}

.findings-card.blocker-high {
    border-left-color: #dc2626;
}

.findings-card.blocker-medium {
    border-left-color: #f97316;
}

.findings-card.blocker-low {
    border-left-color: #eab308;
}

.findings-card.quick-win {
    border-left-color: #10b981;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.card-title {
    font-weight: 600;
    color: #1e3a8a;
    flex: 1;
}

.severity-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.severity-badge.high {
    background: #fef2f2;
    color: #dc2626;
}

.severity-badge.medium {
    background: #fff7ed;
    color: #ea580c;
}

.severity-badge.low {
    background: #fefce8;
    color: #ca8a04;
}

.card-content {
    color: #374151;
    line-height: 1.6;
}

.page-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.page-link:hover {
    text-decoration: underline;
}

.analysis-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.analysis-content {
    position: relative;
}

.copy-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    color: #374151;
    transition: background-color 0.3s ease;
}

.copy-button:hover {
    background: #e5e7eb;
}

.formatted-analysis {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 2rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    line-height: 1.7;
    font-size: 1rem;
    color: #374151;
}

.analysis-content {
    margin-top: 3rem;
}

/* Markdown styling */
.formatted-analysis h3 {
    color: #1e3a8a;
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
}

.formatted-analysis h4 {
    color: #374151;
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.formatted-analysis p {
    margin-bottom: 1rem;
}

.formatted-analysis strong {
    color: #1e3a8a;
    font-weight: 600;
}

.formatted-analysis em {
    font-style: italic;
    color: #6b7280;
}

.formatted-analysis table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.formatted-analysis th,
.formatted-analysis td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.formatted-analysis th {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    font-weight: 600;
    color: #374151;
}

.formatted-analysis td {
    color: #4b5563;
}

.formatted-analysis tr:nth-child(even) td {
    background: #f9fafb;
}

.formatted-analysis ul,
.formatted-analysis ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.formatted-analysis li {
    margin-bottom: 0.5rem;
}

.formatted-analysis blockquote {
    border-left: 4px solid #e5e7eb;
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: #6b7280;
}

.formatted-analysis code {
    background: #f3f4f6;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #d97706;
}

pre {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1.5rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.raw-analysis-fallback {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 2rem;
    margin: 1rem 0;
}

.raw-analysis-fallback pre {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 1rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #1e293b;
}

.raw-analysis-fallback pre:contains("**") {
    /* Style bold markdown text */
}

/* Improve readability of raw markdown */
.raw-analysis-fallback pre:contains("**") b,
.raw-analysis-fallback pre strong {
    color: #1e3a8a;
    font-weight: 700;
}

.raw-analysis-fallback pre *:contains("|") {
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 0.85em;
}

/* Format lists better */
.raw-analysis-fallback pre:contains("- ") {
    line-height: 1.8;
}

/* Style section headers */
.raw-analysis-fallback pre:contains("###") {
    color: #1e293b;
}

/* Buttons */
.new-analysis-button {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.new-analysis-button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 2rem;
    text-align: center;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
}

/* Error Handling */
.error-message {
    color: #dc2626;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header h1 {
        font-size: 2rem;
    }

    .main-content {
        padding: 1rem;
    }

    .form-card,
    .progress-card,
    .summary-section,
    .findings-section,
    .raw-analysis-section {
        padding: 1.5rem;
    }

    .info-section {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .progress-details {
        flex-direction: column;
        gap: 1rem;
    }

    .header-actions {
        justify-content: center;
    }

    .copy-button {
        position: static;
        margin-bottom: 1rem;
        align-self: flex-end;
    }

    #raw-analysis-text {
        margin-top: 1rem;
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error Section */
.error-section {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.error-card {
    background: white;
    border-radius: 12px;
    padding: 4rem 3rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-card h2 {
    font-size: 2rem;
    color: #1e3a8a;
    margin-bottom: 1rem;
}

.error-message {
    color: #6b7280;
    font-size: 1.1rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

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

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
