:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --accent-teal: #0d9488;
    --accent-green: #16a34a;
    --accent-badge-bg: #e0f2fe;
    --accent-badge-text: #0369a1;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --error-text: #991b1b;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-family);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* NAVBAR */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.brand-logo {
    font-size: 1.4rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    padding-top: 2.5rem;
    padding-bottom: 3.5rem;
}

/* HERO SECTION */
.analyzer-hero {
    text-align: center;
    margin-bottom: 2rem;
}

.hero-text h1 {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 650px;
    margin: 0 auto 1.75rem auto;
}

/* FORM CARD */
.form-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    max-width: 600px;
    margin: 0 auto;
}

.input-group {
    display: flex;
    align-items: center;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.input-prefix {
    padding: 0 0.75rem 0 1rem;
    color: var(--text-muted);
    font-size: 1.15rem;
    font-weight: 600;
}

.input-group input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.85rem 0.5rem;
    font-size: 1.05rem;
    color: var(--text-primary);
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.85rem 1.4rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

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

.btn-secondary {
    background: #fff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: var(--bg-main);
}

/* HTMX INDICATOR / SPINNER */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: flex;
}

.loading-box {
    margin-top: 1.25rem;
    padding: 1rem;
    background-color: #f0f9ff;
    border: 1px dashed #7dd3fc;
    border-radius: var(--radius-md);
    align-items: center;
    gap: 1rem;
}

.spinner-circle {
    width: 28px;
    height: 28px;
    border: 3px solid #bae6fd;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
}

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

.loading-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.loading-step {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.loading-text small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ALERTS */
.alert-card {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    margin: 1.5rem auto;
    max-width: 700px;
    box-shadow: var(--shadow-sm);
}

.alert-error {
    background-color: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-text);
}

.alert-icon {
    font-size: 1.5rem;
}

.alert-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.alert-message {
    font-size: 0.95rem;
}

/* RESULTS & PROFILE CARD */
.result-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    margin-top: 2rem;
}

.profile-header-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
}

.profile-main-info {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.profile-avatar-placeholder {
    width: 64px;
    height: 64px;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.profile-titles {
    flex: 1;
}

.user-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.user-row h2 {
    font-size: 1.4rem;
    font-weight: 800;
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
}

.badge-verified {
    background-color: #dcfce7;
    color: #15803d;
}

.badge-business {
    background-color: var(--accent-badge-bg);
    color: var(--accent-badge-text);
}

.profile-fullname {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0.15rem 0 0.4rem 0;
}

.profile-bio {
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: pre-line;
    margin-bottom: 0.5rem;
}

.profile-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.profile-link a:hover {
    text-decoration: underline;
}

/* METRICS GRID */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.metric-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
}

.metric-card.metric-accent {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.metric-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.metric-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
}

.metric-accent .metric-value {
    color: #166534;
}

.profile-footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 0.85rem;
    font-size: 0.85rem;
}

.saved-tag {
    color: var(--accent-green);
    font-weight: 600;
}

.btn-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

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

/* ANALYSIS REPORT CARD */
.analysis-report-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.report-header {
    background: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.report-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.report-tag {
    background: #0284c7;
    color: white;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-weight: 600;
}

/* PROSE / MARKDOWN STYLING */
.report-content.prose {
    padding: 2rem 2.25rem;
    color: #1e293b;
    font-size: 1rem;
    line-height: 1.75;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
    color: var(--text-primary);
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.4rem;
}

.prose h2 {
    font-size: 1.3rem;
    color: #0369a1;
}

.prose h3 {
    font-size: 1.15rem;
    color: #0f172a;
}

.prose p {
    margin-bottom: 1rem;
}

.prose ul, .prose ol {
    margin: 0.75rem 0 1.25rem 1.5rem;
}

.prose li {
    margin-bottom: 0.4rem;
}

.prose strong {
    color: #0f172a;
    font-weight: 600;
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

/* HISTORY PAGE */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}

.header-details h2 {
    font-size: 1.75rem;
    font-weight: 800;
}

.back-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.created-at {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    background-color: #f8fafc;
    padding: 0.85rem 1.25rem;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.cell-id {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.pill-metric {
    background: #ecfdf5;
    color: #047857;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.btn-small {
    background: #f1f5f9;
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}

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

.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    font-size: 1.05rem;
}

/* FOOTER */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 1.25rem 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: auto;
}

@media (max-width: 640px) {
    .input-group {
        flex-direction: column;
    }
    .btn-primary {
        width: 100%;
    }
    .profile-main-info {
        flex-direction: column;
    }
}
