/* OpenClaw Feishu Portal Styles */

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
}

nav {
    margin-top: 1rem;
}

nav a {
    color: var(--primary-color);
    text-decoration: none;
}

nav a:hover {
    text-decoration: underline;
}

/* Steps */
.step {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: none;
}

.step.active {
    display: block;
}

.step-number {
    display: inline-block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    margin-bottom: 1rem;
}

.step h2 {
    margin-bottom: 0.5rem;
}

.step p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Buttons */
button, .btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary, button[type="submit"], #btn-init {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover, button[type="submit"]:hover, #btn-init:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

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

/* QR Code */
.qrcode-container {
    text-align: center;
    margin: 2rem 0;
}

#qr-code {
    max-width: 256px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    background: white;
}

#countdown {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-color);
    margin-top: 1rem;
}

.hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

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

/* Success Actions */
.success-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Error */
#step-error {
    border: 2px solid var(--error-color);
}

#step-error .step-number {
    background: var(--error-color);
}

/* Management Page */
.management-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.management-section h2 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

/* Bot Card */
.bot-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.bot-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.bot-card-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

.bot-card-avatar-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-color);
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.bot-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-color);
    word-break: break-word;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

/* Editor Tabs */
.editor-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    background: var(--bg-color);
}

.editor-tabs .tab {
    padding: 0.6rem 1.2rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
}

.editor-tabs .tab:hover {
    color: var(--text-color);
}

.editor-tabs .tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* DM Policy Bar */
.dm-policy-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.5rem;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.dm-policy-label {
    color: var(--text-muted);
    font-weight: 500;
}

.dm-policy-toggle {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.dm-policy-toggle .dm-opt {
    padding: 0.3rem 0.8rem;
    border: none;
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
}

.dm-policy-toggle .dm-opt:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.dm-policy-toggle .dm-opt.active {
    background: var(--primary-color);
    color: #fff;
}

.dm-policy-toggle .dm-opt:hover:not(.active) {
    background: var(--bg-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close-btn:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.modal-body textarea {
    width: 100%;
    min-height: 400px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Config Display */
.config-display {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
}

.config-display pre {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
}

/* Result messages */
.result {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
}

.result.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid var(--success-color);
}

.result.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid var(--error-color);
}

/* WeChat Login */
.container-narrow {
    max-width: 440px;
}

.login-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.login-card h2 {
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.btn-wechat {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 2rem;
    background: #07c160;
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-wechat:hover {
    background: #06ad56;
}

.wechat-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Header layout */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.nickname {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.admin-badge {
    background: #f59e0b;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.875rem;
}

/* Section header with action button */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    margin: 0;
}

/* (legacy agent-card styles removed, replaced by bot-card) */

.empty-msg {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 0;
}

.empty-msg a {
    color: var(--primary-color);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

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

    .success-actions {
        flex-direction: column;
    }

    .agent-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}
