/* 全局样式重置和基础设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* 通用容器样式 */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

.auth-container,
.main-container,
.admin-container {
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* 登录页面样式 */
#auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
}

/* 确保auth-container不影响#auth-page */
#auth-page.auth-container {
    display: flex;
}

.auth-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-box h1 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.auth-box h2 {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 1.5rem;
}

/* 表单样式 */
.form-container {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover {
    background-color: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.3);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 主页面样式 */
.header {
    background: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 1.5rem;
    color: #667eea;
}

.header-right {
    display: flex;
    gap: 1rem;
}

.main-content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* 组容器样式 */
.groups-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.group-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.group-header {
    padding: 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.group-title {
    font-size: 1.25rem;
    color: #333;
    margin: 0;
}

.group-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.group-status {
    color: #666;
    font-size: 0.875rem;
}

.group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.group-content.expanded {
    max-height: none;
    transition: max-height 0.5s ease-in;
}

.group-search {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.search-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* 账号容器和卡片样式 */
.accounts-container {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.account-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.2s;
}

.account-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.account-username {
    font-size: 1.125rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.account-region {
    background: #667eea;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.info-label {
    color: #666;
    font-weight: 500;
}

.info-value {
    color: #333;
    font-weight: 400;
}

.account-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* 管理后台样式 */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.section h2 {
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 1.25rem;
}

.section-header {
    margin-bottom: 1rem;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.section-header .btn {
    margin-right: 0.5rem;
}

/* 表格样式 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.url-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

/* 状态标签样式 */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-badge.active {
    background: #d4edda;
    color: #155724;
}

.status-badge.inactive {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.pending {
    background: #fff3cd;
    color: #856404;
}

.status-badge.expired {
    background: #e2e3e5;
    color: #383d41;
}

/* 结果消息样式 */
.result-message {
    margin-top: 1rem;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid #c3e6cb;
}

.action-buttons {
    margin: 1rem 0;
    display: flex;
    gap: 0.5rem;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
    margin-top: 1rem;
    display: none;
}

.no-data {
    text-align: center;
    color: #666;
    padding: 2rem;
    grid-column: 1 / -1;
}

/* 卡片加载动画 */
.card-loader {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    height: 240px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.card-loader::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.loader-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.loader-username {
    width: 60%;
    height: 1.5rem;
    background: #e9ecef;
    border-radius: 4px;
}

.loader-region {
    width: 30%;
    height: 1.5rem;
    background: #e9ecef;
    border-radius: 12px;
}

.loader-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.loader-item {
    display: flex;
    gap: 1rem;
}

.loader-label {
    width: 25%;
    height: 1rem;
    background: #e9ecef;
    border-radius: 4px;
}

.loader-value {
    width: 75%;
    height: 1rem;
    background: #e9ecef;
    border-radius: 4px;
}

.loader-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: auto;
}

.loader-btn {
    width: 45%;
    height: 2.5rem;
    background: #e9ecef;
    border-radius: 4px;
}

.error-data {
    text-align: center;
    color: #dc3545;
}

/* 访问码列表样式 */
.codes-list {
    list-style: none;
    padding: 1rem 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.codes-list li {
    background: white;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #c3e6cb;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    text-align: center;
}

.note {
    font-style: italic;
    margin-top: 1rem;
    font-size: 0.875rem;
    opacity: 0.8;
}

/* 加载动画样式 */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast 提示样式 */
.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

.toast.info {
    background: #17a2b8;
}

.copy-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem 2rem;
    border-radius: 4px;
    font-weight: 500;
    z-index: 1000;
    display: none;
    animation: fadeIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 错误和进度样式 */
.fetch-progress {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    color: #666;
    font-size: 0.875rem;
}

.fetch-errors {
    padding: 1rem 1.5rem;
    background: #f8d7da;
    border-top: 1px solid #f5c6cb;
    color: #721c24;
}

.errors-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.errors-list {
    list-style: none;
    padding-left: 1rem;
}

.errors-list li {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

/* 自定义确认弹窗样式 */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.confirm-modal-content {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease-out;
}

.confirm-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

.confirm-modal-message {
    margin-bottom: 2rem;
    line-height: 1.5;
    color: #666;
}

.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.confirm-modal-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.confirm-modal-btn.cancel {
    background: #6c757d;
    color: white;
}

.confirm-modal-btn.cancel:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.confirm-modal-btn.confirm {
    background: #667eea;
    color: white;
}

.confirm-modal-btn.confirm:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.confirm-modal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .group-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .group-controls {
        justify-content: center;
    }
    
    .accounts-container {
        grid-template-columns: 1fr;
        padding: 0.5rem;
        gap: 1rem;
    }
    
    .account-card {
        padding: 1rem;
        margin: 0 auto;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .header-right {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .data-table {
        font-size: 0.875rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
    
    .url-cell {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .auth-box {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .section {
        padding: 1rem;
    }
    
    .card-actions {
        flex-direction: column;
    }
    
    .toast {
        right: 1rem;
        left: 1rem;
        top: 1rem;
    }
}