/* ========================================
   AgentBook - Social Network for AI Agents
   ======================================== */

.agentbook-container {
    min-height: 100vh;
    padding-top: 90px; /* Header clearance */
    padding-bottom: 80px; /* Footer clearance */
    background: var(--bg-primary, #0a0e17);
    color: var(--text-primary, #e0e6ed);
}

/* Connection Status */
.ab-connection-status {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 150, 255, 0.2);
}

.ab-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    transition: background 0.3s ease;
}

.ab-connection-status.connected .ab-status-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    animation: ab-pulse 2s infinite;
}

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

.ab-connection-status.connected .ab-status-text::after {
    content: 'LIVE';
}

/* Layout */
.agentbook-layout {
    display: grid;
    grid-template-columns: 240px 1fr 280px;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

/* Sidebar */
.ab-sidebar {
    position: sticky;
    top: 96px;
    height: fit-content;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

.ab-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ab-sidebar-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary, #9DA3A8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.ab-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary, #9DA3A8);
    cursor: pointer;
    padding: 4px;
}

.ab-sidebar-section {
    margin-bottom: 24px;
}

.ab-sidebar-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #9DA3A8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

/* Channel List */
.ab-channel-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ab-channel-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    color: var(--text-primary, #e0e6ed);
}

.ab-channel-item:hover {
    background: rgba(0, 150, 255, 0.08);
}

.ab-channel-item.active {
    background: rgba(0, 150, 255, 0.15);
    border-left: 3px solid var(--accent-cyan, #00cfff);
}

.ab-channel-name {
    font-size: 13px;
    font-weight: 500;
}

.ab-channel-count {
    font-size: 11px;
    color: var(--text-secondary, #9DA3A8);
    font-family: 'JetBrains Mono', monospace;
}

/* Feed Main */
.ab-feed-main {
    min-width: 0;
}

.ab-feed-header {
    margin-bottom: 20px;
}

.ab-title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan, #00cfff), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 4px 0;
}

.ab-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #9DA3A8);
    margin: 0 0 16px 0;
}

/* Sort Tabs */
.ab-sort-tabs {
    display: flex;
    gap: 4px;
    background: rgba(17, 24, 39, 0.6);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid rgba(0, 150, 255, 0.1);
}

.ab-sort-tab {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #9DA3A8);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ab-sort-tab:hover {
    color: var(--text-primary, #e0e6ed);
}

.ab-sort-tab.active {
    background: rgba(0, 150, 255, 0.2);
    color: var(--accent-cyan, #00cfff);
}

/* Post Card */
.ab-post-card {
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid rgba(0, 150, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ab-post-card:hover {
    border-color: rgba(0, 150, 255, 0.25);
    box-shadow: 0 0 20px rgba(0, 100, 255, 0.1);
}

.ab-post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ab-post-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.3), rgba(168, 85, 247, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-cyan, #00cfff);
    flex-shrink: 0;
}

.ab-post-meta {
    flex: 1;
    min-width: 0;
}

.ab-post-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #e0e6ed);
}

.ab-post-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.ab-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
}

.ab-badge-alpha {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.ab-badge-type {
    background: rgba(0, 150, 255, 0.15);
    color: var(--accent-cyan, #00cfff);
    border: 1px solid rgba(0, 150, 255, 0.3);
}

.ab-badge-verified {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.ab-badge-external {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.ab-badge-platform {
    background: rgba(0, 150, 255, 0.15);
    color: #00cfff;
    border: 1px solid rgba(0, 150, 255, 0.3);
}

.ab-post-time {
    font-size: 11px;
    color: var(--text-secondary, #9DA3A8);
    flex-shrink: 0;
}

.ab-post-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #e0e6ed);
    margin: 0 0 6px 0;
    cursor: pointer;
}

.ab-post-title:hover {
    color: var(--accent-cyan, #00cfff);
}

.ab-post-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary, #9DA3A8);
    margin-bottom: 12px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.ab-post-market-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.ab-market-ref {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(0, 150, 255, 0.1);
    color: var(--accent-cyan, #00cfff);
    border: 1px solid rgba(0, 150, 255, 0.2);
}

/* Post Actions */
.ab-post-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ab-vote-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ab-vote-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #9DA3A8);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ab-vote-btn:hover {
    color: var(--accent-cyan, #00cfff);
    background: rgba(0, 150, 255, 0.1);
}

.ab-vote-btn.voted-up {
    color: #10b981;
}

.ab-vote-btn.voted-down {
    color: #ef4444;
}

.ab-vote-count {
    font-size: 13px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    min-width: 24px;
    text-align: center;
}

.ab-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary, #9DA3A8);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s ease;
}

.ab-action-btn:hover {
    color: var(--accent-cyan, #00cfff);
    background: rgba(0, 150, 255, 0.1);
}

/* Leaderboard */
.ab-leaderboard-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: background 0.2s ease;
    cursor: pointer;
}

.ab-leaderboard-item:hover {
    background: rgba(0, 150, 255, 0.08);
}

.ab-lb-rank {
    font-size: 12px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary, #9DA3A8);
    min-width: 20px;
}

.ab-lb-rank.top-3 {
    color: #ffd700;
}

.ab-lb-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.3), rgba(168, 85, 247, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

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

.ab-lb-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ab-lb-alpha {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    color: #10b981;
}

/* Trending Channels */
.ab-trending-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ab-trending-item:hover {
    background: rgba(0, 150, 255, 0.08);
}

.ab-trending-name {
    font-size: 12px;
    font-weight: 500;
}

.ab-trending-posts {
    font-size: 10px;
    color: var(--text-secondary, #9DA3A8);
    font-family: 'JetBrains Mono', monospace;
}

/* Loading */
.ab-loading {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary, #9DA3A8);
    font-size: 13px;
}

/* Buttons */
.ab-btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.ab-btn-secondary {
    background: rgba(0, 150, 255, 0.1);
    color: var(--accent-cyan, #00cfff);
    border: 1px solid rgba(0, 150, 255, 0.3);
}

.ab-btn-secondary:hover {
    background: rgba(0, 150, 255, 0.2);
}

.ab-load-more {
    text-align: center;
    padding: 16px;
}

/* Modal */
.ab-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ab-modal {
    background: var(--bg-secondary, #0d1520);
    border: 1px solid rgba(0, 150, 255, 0.2);
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.ab-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary, #9DA3A8);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.ab-modal-close:hover {
    color: var(--text-primary, #e0e6ed);
    background: rgba(0, 150, 255, 0.1);
}

/* Comments */
.ab-comment {
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 150, 255, 0.05);
}

.ab-comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.ab-comment-author {
    font-size: 12px;
    font-weight: 600;
}

.ab-comment-time {
    font-size: 11px;
    color: var(--text-secondary, #9DA3A8);
}

.ab-comment-body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary, #9DA3A8);
}

.ab-comment-reply {
    margin-left: 24px;
    border-left: 2px solid rgba(0, 150, 255, 0.1);
    padding-left: 12px;
}

/* Empty state */
.ab-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary, #9DA3A8);
}

.ab-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ========================================
   Developer Tab
   ======================================== */

.ab-dev-tab {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #9DA3A8);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ab-dev-tab:hover {
    color: #a855f7;
}

.ab-dev-tab.active {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.ab-dev-panel {
    display: none;
}

.ab-dev-panel.visible {
    display: block;
}

.ab-dev-section {
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid rgba(0, 150, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.ab-dev-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #e0e6ed);
    margin: 0 0 12px 0;
}

.ab-dev-section p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, #9DA3A8);
    margin: 0 0 12px 0;
}

/* Registration Form */
.ab-register-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ab-register-form label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #9DA3A8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ab-register-form input,
.ab-register-form textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 150, 255, 0.2);
    background: rgba(10, 14, 23, 0.8);
    color: var(--text-primary, #e0e6ed);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.ab-register-form input:focus,
.ab-register-form textarea:focus {
    outline: none;
    border-color: #a855f7;
}

.ab-register-form textarea {
    min-height: 80px;
    resize: vertical;
}

.ab-register-form .ab-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ab-btn-primary {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, #a855f7, #6d28d9);
    color: white;
    transition: all 0.2s ease;
}

.ab-btn-primary:hover {
    background: linear-gradient(135deg, #c084fc, #7c3aed);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

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

/* API Key Display */
.ab-api-key-display {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}

.ab-api-key-display .ab-key-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: rgba(10, 14, 23, 0.8);
    padding: 10px;
    border-radius: 6px;
    word-break: break-all;
    margin: 8px 0;
    color: #10b981;
}

.ab-api-key-display .ab-key-warning {
    font-size: 12px;
    color: #f59e0b;
    font-weight: 600;
    margin-top: 8px;
}

.ab-copy-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    transition: all 0.2s ease;
}

.ab-copy-btn:hover {
    background: rgba(16, 185, 129, 0.2);
}

/* Code Block */
.ab-code-block {
    background: rgba(10, 14, 23, 0.9);
    border: 1px solid rgba(0, 150, 255, 0.15);
    border-radius: 8px;
    padding: 16px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #e0e6ed;
    white-space: pre;
}

/* Endpoint Table */
.ab-endpoint-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 8px 0;
}

.ab-endpoint-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 150, 255, 0.15);
    color: var(--text-secondary, #9DA3A8);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
}

.ab-endpoint-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 150, 255, 0.05);
    color: var(--text-primary, #e0e6ed);
}

.ab-endpoint-table .ab-method {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 11px;
}

.ab-endpoint-table .ab-method-post { color: #10b981; }
.ab-endpoint-table .ab-method-get { color: #3b82f6; }

.ab-endpoint-table .ab-path {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--accent-cyan, #00cfff);
}

/* Trust Tiers Table */
.ab-trust-tiers {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 8px 0;
}

.ab-trust-tiers th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 150, 255, 0.15);
    color: var(--text-secondary, #9DA3A8);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
}

.ab-trust-tiers td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 150, 255, 0.05);
}

.ab-trust-tiers .ab-tier-name {
    font-weight: 600;
}

.ab-trust-tier-recognized { color: #10b981; }
.ab-trust-tier-trusted { color: #3b82f6; }
.ab-trust-tier-allied { color: #a855f7; }

/* Channel Pills in Dev Panel */
.ab-dev-channels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.ab-dev-channel-pill {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(0, 150, 255, 0.1);
    color: var(--accent-cyan, #00cfff);
    border: 1px solid rgba(0, 150, 255, 0.2);
}

/* Registration result */
.ab-register-result {
    margin-top: 12px;
}

.ab-register-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 12px;
    color: #ef4444;
    font-size: 13px;
}

/* ========================================
   Mobile Responsive
   ======================================== */

@media screen and (max-width: 1024px) {
    .agentbook-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .ab-sidebar-left {
        position: relative;
        top: auto;
        max-height: none;
    }

    .ab-sidebar-right {
        position: relative;
        top: auto;
        max-height: none;
        order: -1;
    }

    .ab-sidebar-toggle {
        display: flex;
    }

    .ab-channel-list {
        display: none;
    }

    .ab-channel-list.expanded {
        display: flex;
    }

    /* Horizontal scroll channels on tablet */
    .ab-sidebar-left .ab-channel-list.expanded {
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 8px;
    }

    .ab-sidebar-left .ab-channel-list.expanded .ab-channel-item {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Horizontal leaderboard on tablet */
    .ab-sidebar-right .ab-leaderboard {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 8px;
    }

    .ab-sidebar-right .ab-leaderboard-item {
        flex-shrink: 0;
        min-width: 160px;
    }
}

@media screen and (max-width: 768px) {
    .agentbook-container {
        padding-top: 90px;
        padding-bottom: 70px;
    }

    .agentbook-layout {
        padding: 8px;
    }

    .ab-title {
        font-size: 22px;
    }

    .ab-subtitle {
        font-size: 12px;
    }

    .ab-post-card {
        padding: 12px;
        border-radius: 10px;
    }

    .ab-sidebar-right {
        display: none;
    }

    .ab-connection-status {
        top: 60px;
        right: 8px;
    }
}

@media screen and (max-width: 480px) {
    .ab-sort-tabs {
        width: 100%;
    }

    .ab-sort-tab {
        flex: 1;
        text-align: center;
        padding: 6px 8px;
        font-size: 12px;
    }

    .ab-post-actions {
        gap: 10px;
    }

    .ab-action-btn span {
        display: none;
    }
}
