/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --border-radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Header */
.header {
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.header-text {
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.header-logo {
    height: 2.5rem;
    width: auto;
    flex-shrink: 0;
    /* Reset the text fill color effect for the image */
    -webkit-text-fill-color: initial;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Auth Section */
.auth-section {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    align-items: center;
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #7C8DA8, #4E86B9);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 141, 168, 0.4);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ethos-icon {
    width: 20px;
    height: 20px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-color);
    object-fit: cover;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.user-score {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
    width: fit-content;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.logout-btn:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

/* Auth Analysis Section */
.auth-analysis-section {
    margin-bottom: 1.5rem;
}

.auth-analysis-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.auth-analysis-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-color);
    object-fit: cover;
}

.auth-user-details {
    display: flex;
    flex-direction: column;
}

.auth-user-name {
    font-weight: 600;
    font-size: 1rem;
}

.auth-user-username {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.analyze-btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.analyze-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.analyze-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin-top: 1.5rem;
    gap: 1rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-divider span {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Search Section */
.search-section {
    margin-bottom: 2rem;
}

.search-form {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.input-group {
    display: flex;
    gap: 1rem;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
}

.search-input-wrapper input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.search-input-wrapper input:focus {
    border-color: var(--primary-color);
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: var(--bg-color);
}

.search-result-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.search-result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-color);
    object-fit: cover;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-username {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.search-result-score {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.search-loading {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Selected Profile Display */
.selected-profile {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.selected-profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card-bg);
    object-fit: cover;
}

.selected-profile-info {
    flex: 1;
}

.selected-profile-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.selected-profile-username {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.selected-profile-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1.2rem;
    line-height: 1;
    transition: color 0.15s;
}

.selected-profile-clear:hover {
    color: var(--error-color);
}

.input-group button {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.input-group button:hover {
    background: var(--primary-hover);
}

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

/* Error Message */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Task Status Section */
.task-status {
    margin-bottom: 2rem;
}

.task-status-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
}

.task-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.task-status-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.task-id {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.status-dot.created {
    background: var(--text-secondary);
}

.status-dot.running {
    background: var(--warning-color);
    animation: pulse 1.5s infinite;
}

.status-dot.completed {
    background: var(--success-color);
}

.status-dot.error {
    background: var(--error-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text {
    font-weight: 500;
    text-transform: capitalize;
}

.progress-container {
    margin-top: 1rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #a855f7);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Summary Card */
.summary-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.summary-header h2 {
    font-size: 1.25rem;
}

.analyzed-at {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

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

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
}

.filter-input:focus {
    border-color: var(--primary-color);
}

.sort-select {
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-label .toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.checkbox-label .toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.checkbox-label input[type="checkbox"]:checked + .toggle {
    background: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .toggle::after {
    left: 23px;
    background: white;
}

.checkbox-label input[type="checkbox"]:focus + .toggle {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.checkbox-label:hover .toggle {
    background: var(--text-secondary);
}

.checkbox-label:hover input[type="checkbox"]:checked + .toggle {
    background: var(--primary-hover);
}

/* Matches List */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 600px;
    overflow-y: auto;
}

.match-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: border-color 0.2s;
}

.match-card:hover {
    border-color: var(--primary-color);
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-color);
    object-fit: cover;
    flex-shrink: 0;
}

.match-info {
    flex: 1;
    min-width: 0;
}

.match-username {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.match-username .secondary {
    color: var(--text-secondary);
    font-weight: 400;
}

.match-bio {
    color: var(--text-secondary);
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
    flex-shrink: 0;
}

.ethos-score {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.ethos-details {
    display: none;
    flex-direction: column;
    gap: 0.125rem;
    align-items: flex-end;
}

.matches-list.show-details .ethos-details {
    display: flex;
}

.ethos-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.match-links {
    display: flex;
    gap: 0.5rem;
}

.match-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-color);
    border-radius: 4px;
    transition: color 0.2s;
}

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

/* No Matches Message */
.no-matches {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Export Section */
.export-section {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
}

.export-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.export-btn:hover {
    background: var(--card-bg);
    border-color: var(--primary-color);
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

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

.loading-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

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

/* Scrollbar Styling */
.matches-list::-webkit-scrollbar {
    width: 8px;
}

.matches-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.matches-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.matches-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
}

.footer-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.creator-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.created-by {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.creator-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.creator-link:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.creator-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.creator-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.footer-divider {
    display: none;
}

.rights-section {
    text-align: center;
}

.rights-section p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        padding-top: 4rem;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header-text {
        text-align: center;
    }

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

    .auth-section {
        top: 0.75rem;
        right: 0.75rem;
    }

    .login-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .user-profile {
        padding: 0.35rem 0.5rem;
    }

    .user-name {
        display: none;
    }

    .auth-analysis-card {
        flex-direction: column;
        text-align: center;
    }

    .auth-analysis-info {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 640px) {
    .input-group {
        flex-direction: column;
    }

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

    .filters {
        flex-direction: column;
    }

    .match-card {
        flex-direction: column;
        text-align: center;
    }

    .match-bio {
        white-space: normal;
    }

    .match-stats {
        align-items: center;
    }

    .ethos-details {
        align-items: center;
    }

    .footer-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .creator-section {
        flex-direction: column;
        gap: 0.75rem;
    }

    .rights-section {
        order: 2;
    }

    .creator-section {
        order: 1;
    }
}
