/* Card Component */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Button Components */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

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

.btn-primary {
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(to right, #2563eb, #7c3aed);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
}

.btn-success {
    background: #dcfce7;
    color: #059669;
}

.btn-success:hover:not(:disabled) {
    background: #bbf7d0;
}

.btn-danger {
    background: #fef2f2;
    color: #dc2626;
}

.btn-danger:hover:not(:disabled) {
    background: #fee2e2;
}

/* Mode Button Component */
.mode-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: #f3f4f6;
    color: #374151;
}

.mode-btn.active {
    background: #3b82f6;
    color: white;
}

.mode-btn:hover:not(:disabled) {
    background: #e5e7eb;
}

.mode-btn.active:hover {
    background: #2563eb;
}

.mode-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Restricted Protocol Button States */
.mode-btn.restricted {
    background: #f9fafb;
    color: #9ca3af;
    border: 1px dashed #d1d5db;
    cursor: not-allowed;
    opacity: 0.6;
}

.mode-btn.restricted:hover {
    background: #f9fafb;
    color: #9ca3af;
    transform: none;
}

.mode-btn.locked {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    color: #6b7280;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.mode-btn.locked:hover {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.mode-btn.locked::before {
    content: "🔒";
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.7rem;
    opacity: 0.7;
}

/* Protocol Access Tooltip */
.protocol-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 50;
    margin-bottom: 0.25rem;
}

.protocol-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1f2937;
}

.mode-btn.locked:hover .protocol-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Upgrade Button in Tooltip */
.upgrade-btn {
    background: linear-gradient(to right, #f59e0b, #d97706);
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: all 0.2s;
}

.upgrade-btn:hover {
    background: linear-gradient(to right, #d97706, #b45309);
    transform: scale(1.05);
}

/* Form Controls */
textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    resize: none;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea:disabled {
    opacity: 0.5;
    background: #f9fafb;
}

/* Enhanced Output Component */
.enhanced-output {
    min-height: 8rem;
    padding: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #f9fafb;
    line-height: 1.4;
    color: #1f2937;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    font-family: inherit;
}

/* Override insight colors for enhanced output to use neutral tones */
.enhanced-output.insight-content {
    color: #1f2937;
}

.enhanced-output .insight-heading {
    color: #1f2937;
}

.enhanced-output .insight-paragraph {
    color: #374151;
}

.enhanced-output .insight-strong {
    color: #111827;
}

.enhanced-output .insight-emphasis {
    color: #374151;
}

.enhanced-output .insight-list {
    color: #374151;
}

.enhanced-output .insight-inline-code {
    background: rgba(59, 130, 246, 0.1);
    color: #1e40af;
}

.enhanced-output .insight-code-block {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.enhanced-output .insight-code {
    color: #1e40af;
}

.enhanced-output pre {
    white-space: pre-wrap;
    color: #1f2937;
    font-family: 'SF Mono', Monaco, Inconsolata, 'Roboto Mono', Consolas, monospace;
    font-size: 0.875rem;
}

/* Placeholder Component */
.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 8rem;
    color: #6b7280;
    font-style: italic;
    text-align: center;
}

/* Processing Indicator */
.processing-indicator {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    border-radius: 0.5rem;
}

/* Progress Bar Component */
.progress-bar {
    width: 100%;
    background: #e5e7eb;
    border-radius: 9999px;
    height: 0.5rem;
}

.progress-fill {
    height: 0.5rem;
    border-radius: 9999px;
    transition: width 0.3s;
}

/* Sample Prompts Component */
.sample-prompts {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.sample-btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    background: #dbeafe;
    color: #2563eb;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sample-btn:hover:not(:disabled) {
    background: #bfdbfe;
}

.sample-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Stats Component */
.stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: #6b7280;
}

/* API Key Section */
#apiKeySection {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

#apiKeyInput {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

/* Stage Components */
.stage-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.stage-item.completed {
    background: #dcfce7;
}

.stage-item.not-completed {
    background: #f9fafb;
}

.stage-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
}

.stage-dot.completed {
    background: #10b981;
}

.stage-dot.not-completed {
    background: #d1d5db;
}

/* Markdown Rendering Styles for AI Insights */
.insight-item {
    line-height: 1.6;
    margin-bottom: 1rem;
}

.insight-content {
    width: 100%;
    line-height: 1.6;
}

/* Better spacing for insight items */
.insight-item:last-child {
    margin-bottom: 0;
}

/* Headings within insights */
.insight-heading {
    color: #065f46;
    font-weight: 600;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.insight-h1 {
    font-size: 1.125rem;
    border-bottom: 2px solid #d1fae5;
    padding-bottom: 0.25rem;
}

.insight-h2 {
    font-size: 1rem;
    border-bottom: 1px solid #d1fae5;
    padding-bottom: 0.125rem;
}

.insight-h3 {
    font-size: 0.9375rem;
}

.insight-h4, .insight-h5, .insight-h6 {
    font-size: 0.875rem;
}

/* First heading should not have top margin */
.insight-content .insight-heading:first-child {
    margin-top: 0;
}

/* Paragraphs within insights */
.insight-paragraph {
    margin-bottom: 0.875rem;
    line-height: 1.6;
    color: #065f46;
}

.insight-paragraph:last-child {
    margin-bottom: 0;
}

.insight-paragraph:first-child {
    margin-top: 0;
}

/* Better text formatting for long content */
.insight-content p {
    margin-bottom: 0.875rem;
    line-height: 1.6;
}

.insight-content p:last-child {
    margin-bottom: 0;
}

/* Lists within insights */
.insight-list {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
    color: #065f46;
}

.insight-list ul,
.insight-list ol {
    margin: 0.5rem 0;
}

.insight-list-item {
    margin-bottom: 0.5rem;
    line-height: 1.6;
    padding-left: 0.25rem;
}

/* Enhanced styling for numbered lists in insights */
.insight-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
    counter-reset: insight-counter;
    list-style: none;
}

.insight-content ol li {
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    position: relative;
    line-height: 1.6;
    counter-increment: insight-counter;
}

.insight-content ol li::before {
    content: counter(insight-counter) ".";
    position: absolute;
    left: -1.5rem;
    color: #047857;
    font-weight: 600;
}

.insight-content ul {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.insight-content ul li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* Code styling within insights */
.insight-code-block {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.insight-code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8125rem;
    color: #047857;
}

.insight-inline-code {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8125rem;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

/* Text emphasis within insights */
.insight-strong {
    font-weight: 700;
    color: #064e3b;
}

.insight-emphasis {
    font-style: italic;
    color: #047857;
}

/* Nested content spacing */
.insight-content > *:first-child {
    margin-top: 0;
}

.insight-content > *:last-child {
    margin-bottom: 0;
}

/* User Menu Dropdown Component */
.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    min-width: 12rem;
    z-index: 50;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.menu-header {
    padding: 0.875rem 1rem 0.5rem 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.menu-tier-info {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
    letter-spacing: 0.025em;
}

.menu-option {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-option:hover {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #1e293b;
    transform: translateX(2px);
}

.menu-option:active {
    background: #e2e8f0;
    transform: translateX(1px);
}

.menu-option:focus {
    outline: none;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.menu-option-danger {
    color: #dc2626 !important;
}

.menu-option-danger:hover {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%) !important;
    color: #b91c1c !important;
}

.menu-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.08) 50%, transparent 100%);
    margin: 0.25rem 0;
}

/* Analysis Panel Components */
.analysis-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
}

.score-label {
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
}

.score-value {
    color: #1f2937;
    font-size: 1rem;
    font-weight: 700;
}

.score-improvement {
    color: #059669;
    font-size: 1rem;
    font-weight: 700;
    background: #d1fae5;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.insight-item {
    padding: 0.75rem;
    background: #f0fdf4;
    border-left: 3px solid #10b981;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
}

.improvement-item {
    padding: 0.75rem;
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
}

.error-item {
    padding: 0.75rem;
    background: #fef2f2;
    border-left: 3px solid #ef4444;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    color: #991b1b;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .insight-h1 {
        font-size: 1rem;
    }

    .insight-h2 {
        font-size: 0.9375rem;
    }

    .insight-code-block {
        font-size: 0.75rem;
    }

    .user-menu-dropdown {
        min-width: 10rem;
        margin-top: 0.25rem;
    }

    .menu-option {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }

    .menu-header {
        padding: 0.75rem 0.875rem 0.375rem 0.875rem;
    }

    .score-grid {
        grid-template-columns: 1fr;
    }
}