/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

/* IE8+ 兼容性 */
.ie-fallback {
    zoom: 1;
}

/* 清除浮动 */
.clearfix:before,
.clearfix:after {
    content: "";
    display: table;
}
.clearfix:after {
    clear: both;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* IE9+ 渐变降级 */
    background: #87ceeb;
    background: -webkit-linear-gradient(to bottom, #87ceeb 0%, #ffffff 100%);
    background: -moz-linear-gradient(to bottom, #87ceeb 0%, #ffffff 100%);
    background: -ms-linear-gradient(to bottom, #87ceeb 0%, #ffffff 100%);
    background: linear-gradient(to bottom, #87ceeb 0%, #ffffff 100%);
    /* IE8 降级 */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#87ceeb', endColorstr='#ffffff', GradientType=0);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
    /* 移除所有背景和装饰 */
}

header h1 {
    color: #4a5568;
    font-size: 2rem;
    font-weight: bold;
}

.auth-buttons {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    gap: 10px;
    /* IE兼容性：使用margin代替gap */
}

.auth-buttons > * {
    margin-left: 10px;
}

.auth-buttons > *:first-child {
    margin-left: 0;
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    /* IE8 降级 */
    zoom: 1;
    *display: inline;
}

.btn-primary {
    background: linear-gradient(45deg, #4a90e2, #87ceeb);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
}

.btn-danger {
    background: #e53e3e;
    color: white;
}

.btn-danger:hover {
    background: #c53030;
    transform: translateY(-2px);
}

.btn-search {
    background: #38a169;
    color: white;
}

.btn-search:hover {
    background: #2f855a;
    transform: translateY(-2px);
}

/* 搜索区域 */
.search-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    gap: 15px;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    /* backdrop-filter: blur(10px); 移除不兼容的属性 */
}

.search-section > * {
    margin-right: 15px;
}

.search-section > *:last-child {
    margin-right: 0;
}

.search-input {
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    font-size: 16px;
    -webkit-transition: border-color 0.3s ease;
    -moz-transition: border-color 0.3s ease;
    -ms-transition: border-color 0.3s ease;
    transition: border-color 0.3s ease;
    /* IE8 降级 */
    width: 70%;
    *width: 65%;
}

.search-input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 智能体网格 */
.agents-grid {
    margin-top: 20px;
}

/* 类型分组样式 */
.type-section {
    margin-bottom: 20px;
}

.type-title {
    color: #2d3748;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    padding: 0;
    display: block;
    /* 移除所有背景和装饰 */
}

.type-grid {
    /* CSS Grid 兼容性方案 */
    display: -ms-grid !important; /* IE10+ */
    display: grid !important;
    -ms-grid-columns: 1fr 1fr 1fr 1fr 1fr !important; /* IE10+ */
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 20px !important;
    margin-top: 15px;
    
    /* Flexbox 降级方案 */
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

/* Grid 不支持时的 Flexbox 降级 */
@supports not (display: grid) {
    .type-grid {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-flex-wrap: wrap;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
        margin: -10px;
    }
    
    .agent-card {
        -webkit-box-flex: 0;
        -webkit-flex: 0 0 calc(33.333% - 20px);
        -ms-flex: 0 0 calc(33.333% - 20px);
        flex: 0 0 calc(33.333% - 20px);
        margin: 10px;
        min-width: 280px;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .type-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .agent-card {
        padding: 12px;
        aspect-ratio: 1;
    }
    
    .agent-card h3 {
        font-size: 0.9rem;
    }
    
    .agent-card p {
        font-size: 12px;
        height: 3em;
        line-height: 1.4;
    }
    
    .type-title {
        font-size: 1rem;
        padding: 0;
        margin-bottom: 6px;
        display: block;
    }
}

@media (max-width: 480px) {
    .type-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .agent-card {
        aspect-ratio: 1;
        padding: 10px;
    }
    
    .agent-card p {
        height: 3em;
        font-size: 11px;
        line-height: 1.3;
    }
}

@media (min-width: 1200px) {
    .type-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 25px !important;
    }
    
    .agent-card {
        aspect-ratio: 1;
        padding: 18px;
    }
}
    
    .agent-card {
        height: 140px;
        min-height: 140px;
        max-height: 140px;
        padding: 16px;
    }
    
    .agent-card p {
        height: 3em;
        font-size: 14px;
        line-height: 1.5;
    }
}

/* 智能体卡片 */
.agent-card {
    background: rgba(255, 255, 255, 0.95);
    -webkit-border-radius: 12px;
    -moz-border-radius: 12px;
    border-radius: 12px;
    padding: 16px;
    -webkit-box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    -moz-box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.3);
    /* 正方形卡片，长宽一致 */
    aspect-ratio: 1;
    width: 100%;
    height: auto;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: start;
    -webkit-justify-content: flex-start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    /* IE8 降级 */
    zoom: 1;
    filter: progid:DXImageTransform.Microsoft.Shadow(color='#e0e0e0', Direction=135, Strength=2);
}

.agent-card:hover {
    -webkit-transform: translateY(-3px);
    -ms-transform: translateY(-3px);
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: rgba(102, 126, 234, 0.4);
    cursor: pointer;
}

.agent-card.locked {
    opacity: 0.7;
    position: relative;
}

.agent-card.locked::after {
    content: '🔒';
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 16px;
}

.agent-card h3 {
    color: #2d3748;
    margin-bottom: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.agent-card .agent-type {
    background: #4a90e2;
    background: -webkit-linear-gradient(45deg, #4a90e2, #87ceeb);
    background: -moz-linear-gradient(45deg, #4a90e2, #87ceeb);
    background: -ms-linear-gradient(45deg, #4a90e2, #87ceeb);
    background: linear-gradient(45deg, #4a90e2, #87ceeb);
    color: white;
    padding: 4px 12px;
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
    margin-bottom: 12px;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    /* IE8 降级 */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#4a90e2', endColorstr='#87ceeb', GradientType=1);
}

.agent-card p {
    color: #4a5568;
    line-height: 1.5;
    margin-bottom: 0;
    font-size: 14px;
    /* 限制14个汉字，超出显示省略号 */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
    /* 固定高度，支持两行显示 */
    height: 3em;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    /* IE8 降级 */
    word-wrap: break-word;
    /* 兼容不支持-webkit-line-clamp的浏览器 */
    white-space: normal;
}

.agent-card .agent-link {
    color: #4a90e2;
    font-size: 12px;
    word-break: break-all;
}

/* 验证码样式 */
.captcha-group {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.captcha-group input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.captcha-group input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.captcha-image-container {
    position: relative;
    display: flex;
    align-items: center;
}

.captcha-image-container img {
    height: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.captcha-image-container img:hover {
    border-color: #4a90e2;
}

.captcha-refresh {
    margin-left: 8px;
    cursor: pointer;
    font-size: 16px;
    color: #4a90e2;
    transition: transform 0.3s ease;
}

.captcha-refresh:hover {
    transform: rotate(180deg);
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    /* IE8 降级 */
    background-color: #000000;
    filter: alpha(opacity=50);
}

.modal-content {
    background: white;
    margin: 10% auto;
    padding: 30px;
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    -webkit-box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    -moz-box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: modalSlideIn 0.3s ease;
    /* IE8 降级 */
    filter: progid:DXImageTransform.Microsoft.Shadow(color='#4d4d4d', Direction=135, Strength=3);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 15px;
}

.close:hover {
    color: #000;
}

.modal h2 {
    margin-bottom: 20px;
    color: #2d3748;
    text-align: center;
}

.modal form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e5e7eb;
}

.modal input {
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    width: 100%;
}

.modal input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal input[readonly] {
    background-color: #f9fafb;
    color: #6b7280;
    cursor: not-allowed;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        flex-direction: column;
        text-align: center;
        padding: 15px 0;
        margin-bottom: 15px;
    }
    
    .search-section {
        flex-direction: column;
    }
    
    .agents-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 20% auto;
        width: 95%;
    }
}

/* 加载动画 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 页脚样式 */
footer {
    margin-top: 40px;
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.footer-content {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-content p {
    margin: 5px 0;
}

.footer-content a {
    color: #4a90e2;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-content a:hover {
    color: #2d5aa0;
    text-decoration: underline;
}

/* 用户头像和下拉菜单样式 */
.user-profile {
    position: relative;
    display: inline-block;
    margin-left: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90e2, #87ceeb);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.user-avatar span {
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.user-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.user-profile:hover .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-item i {
    margin-right: 8px;
    font-style: normal;
}

.dropdown-divider {
    height: 1px;
    background-color: #e2e8f0;
    margin: 4px 0;
}

/* 邀请码管理样式 */
.invite-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.invite-list-section h3 {
    margin-bottom: 15px;
    color: #2d3748;
}

.invite-list {
    max-height: 300px;
    overflow-y: auto;
}

.invite-item {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invite-code {
    font-family: monospace;
    font-weight: bold;
    color: #4a90e2;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
}

.invite-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-approved {
    background: #d1fae5;
    color: #065f46;
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

/* 邀请码状态样式 */
.invite-statuses {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.approval-status {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
}

.usage-status {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
}

.status-available {
    background-color: #28a745;
    color: white;
}

.invite-info {
    flex: 1;
    margin-left: 12px;
}

.invite-note {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 4px;
}

/* 管理员审批区域样式 */
.admin-approval-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e2e8f0;
}

.admin-approval-section h3 {
    margin-bottom: 15px;
    color: #2d3748;
    display: flex;
    align-items: center;
}

.admin-approval-section h3:before {
    content: "👨‍💼";
    margin-right: 8px;
}

.approval-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.pending-count {
    font-weight: bold;
    font-size: 14px;
}

.pending-invite-list {
    max-height: 400px;
    overflow-y: auto;
}

.pending-invite-item {
    background: #fff8dc;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pending-invite-info {
    flex: 1;
}

.pending-invite-code {
    font-family: monospace;
    font-size: 16px;
    color: #1f2937;
    margin-bottom: 5px;
}

.pending-invite-creator {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 3px;
}

.pending-invite-date {
    color: #9ca3af;
    font-size: 12px;
}

.pending-invite-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.btn-info {
    background-color: #3b82f6;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

.btn-info:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
}

.invite-date {
    font-size: 12px;
    color: #9ca3af;
}

/* 响应式设计 - 用户头像 */
@media (max-width: 768px) {
    .user-avatar {
        width: 35px;
        height: 35px;
    }
    
    .user-avatar span {
        font-size: 14px;
    }
    
    .user-dropdown {
        right: -10px;
        min-width: 160px;
    }
}

/* 响应式设计 - 页脚 */
@media (max-width: 768px) {
    footer {
        margin-top: 30px;
        padding: 15px 0;
    }
    
    .footer-content {
        font-size: 0.8rem;
    }
}