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

a {
    text-decoration: none;
}

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

/* 登录页面样式 */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    padding: 40px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.help-text {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.btn {
    width: 100%;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

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

.btn-secondary {
    background: var(--text-secondary);
    color: white;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-secondary:hover {
    background: var(--text-primary);
}

.btn-success {
    background: var(--success-color);
    color: white;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-success:hover {
    background: #059669;
}

.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-warning {
    background: var(--warning-color);
    color: #111827;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-warning:hover {
    background: #d97706;
    color: #111827;
}

.error-message {
    margin-top: 16px;
    padding: 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 14px;
}

.login-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.login-footer h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.login-footer ol {
    padding-left: 20px;
}

.login-footer li {
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.login-footer code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

.manager-card {
    max-width: 860px;
}

.manager-section {
    margin-top: 32px;
}

.manager-section:first-of-type {
    margin-top: 0;
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-helper {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
}

.manager-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.btn-inline {
    width: auto;
    align-self: flex-start;
    padding-left: 18px;
    padding-right: 18px;
}

.status-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: var(--shadow);
}

.status-message.info {
    background: #eef2ff;
    color: #3730a3;
    border-left: 4px solid var(--primary-color);
}

.status-message.success {
    background: #ecfdf5;
    color: #047857;
    border-left: 4px solid var(--success-color);
}

.status-message.error {
    background: #fef2f2;
    color: #b91c1c;
    border-left: 4px solid var(--danger-color);
}

.import-actions {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.import-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.account-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--border-color);
}

.account-card.disabled {
    border: 2px solid var(--danger-color);
    background: rgba(239, 68, 68, 0.08);
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.account-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-id {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-all;
}

.token-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.token-preview code {
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
}

.token-updated {
    font-size: 12px;
    color: var(--text-secondary);
}

.account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.account-actions .btn {
    width: auto;
    flex: 1 1 160px;
}

.account-actions .btn-inline {
    align-self: stretch;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    transition: all 0.3s;
    border-radius: 999px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    top: 3px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.auto-reset-control {
    margin-top: 12px;
    padding: 16px;
    border-radius: 12px;
    background: rgba(79, 70, 229, 0.05);
    border: 1px solid rgba(79, 70, 229, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.auto-reset-control.error {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

.auto-reset-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auto-reset-status {
    font-weight: 600;
    color: var(--text-primary);
}

.auto-reset-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.account-alert {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
}

.account-alert--danger {
    background: #fef2f2;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #b91c1c;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-danger:hover {
    background: #b91c1c;
}

.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    border: 1px dashed var(--border-color);
    margin-top: 12px;
}

.empty-state p {
    font-size: 14px;
    line-height: 1.6;
}

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

    .account-actions .btn {
        width: 100%;
    }

    .auto-reset-control {
        flex-direction: column;
        align-items: flex-start;
    }

    .auto-reset-control .toggle-switch {
        align-self: flex-end;
    }

    .import-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Dashboard 样式 */
.dashboard-container {
    min-height: 100vh;
    background: var(--bg-color);
}

.dashboard-header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 20px 0;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h1 {
    font-size: 24px;
    color: var(--text-primary);
}

.dashboard-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.loading-spinner {
    text-align: center;
    padding: 60px 20px;
}

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

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

.subscriptions-list {
    display: grid;
    gap: 24px;
}

.subscription-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.subscription-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.subscription-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.subscription-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.subscription-title h2 {
    font-size: 24px;
    color: var(--text-primary);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

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

.plan-type-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #dbeafe;
    color: #1e40af;
}

.subscription-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 600;
}

.info-value.highlight {
    color: var(--primary-color);
    font-size: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--success-color);
    transition: width 0.3s;
}

.subscription-features {
    background: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.subscription-features h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.subscription-features pre {
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    font-family: inherit;
}

.subscription-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.reset-info {
    margin: 10px 0;
    padding: 12px;
    background: #fef3c7;
    border-radius: 8px;
    font-size: 13px;
    color: #92400e;
}

.error-container {
    text-align: center;
    padding: 60px 20px;
}

.error-box {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px;
    max-width: 500px;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
}

.error-box h3 {
    margin-bottom: 16px;
    color: var(--danger-color);
}

.error-box p {
    margin-bottom: 24px;
    color: var(--text-secondary);
}

/* Toast 通知 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.show {
    display: block;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .login-card {
        padding: 24px;
    }

    .subscription-info {
        grid-template-columns: 1fr;
    }

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

    .subscription-actions .btn {
        width: 100%;
    }
}

/* ==================== 管理员登录页面专用样式 ==================== */
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3),
                0 0 100px rgba(99, 102, 241, 0.2);
    max-width: 450px;
    width: 100%;
    padding: 45px 40px;
    animation: fadeInUp 0.6s ease, float 6s ease-in-out infinite;
    border: 1px solid rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
}

.login-box::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    animation: rotate-gradient 20s linear infinite;
    pointer-events: none;
}

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

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-15px);
    }
}

.title {
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
    position: relative;
    padding-top: 50px;
}

.title::before {
    content: "🔐";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    animation: rotate-icon 4s ease-in-out infinite;
}

@keyframes rotate-icon {
    0%, 100% {
        transform: translateX(-50%) rotate(0deg);
    }
    25% {
        transform: translateX(-50%) rotate(-10deg);
    }
    75% {
        transform: translateX(-50%) rotate(10deg);
    }
}

.subtitle {
    text-align: center;
    color: rgba(75, 85, 99, 0.8);
    font-size: 15px;
    margin-bottom: 35px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.input-field {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
}

.input-field::placeholder {
    color: rgba(107, 114, 128, 0.6);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1),
                0 4px 12px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.input-field:hover {
    border-color: rgba(99, 102, 241, 0.4);
}

.submit-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    letter-spacing: 1px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.submit-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.6);
}

.submit-btn:hover::before {
    left: 100%;
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.error-message {
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(220, 38, 38, 0.15) 100%);
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-left: 4px solid var(--danger-color);
    border-radius: 10px;
    color: #dc2626;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
    animation: shake 0.5s ease-in-out;
    display: none;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    50% {
        transform: translateX(10px);
    }
    75% {
        transform: translateX(-10px);
    }
}

.footer-info {
    margin-top: 30px;
    padding: 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 12px;
    text-align: center;
    font-size: 14px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    position: relative;
    z-index: 1;
}

.footer-info p {
    margin: 8px 0;
    color: rgba(75, 85, 99, 0.9);
}

.footer-info p:first-child {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 15px;
}

.footer-info .warning {
    color: var(--warning-color);
    font-weight: 600;
    animation: pulse-warning 2s ease-in-out infinite;
    font-size: 13px;
}

@keyframes pulse-warning {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* 响应式优化 - 管理员登录页面 */
@media (max-width: 480px) {
    .login-box {
        padding: 35px 25px;
    }

    .title {
        font-size: 28px;
        padding-top: 45px;
    }

    .title::before {
        font-size: 35px;
    }

    .subtitle {
        font-size: 14px;
    }

    .input-field {
        padding: 12px 16px;
        font-size: 14px;
    }

    .submit-btn {
        padding: 12px 20px;
        font-size: 15px;
    }

    .footer-info {
        font-size: 13px;
        padding: 15px;
    }
}

/* ==================== 模态框样式 ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

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

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    font-size: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1;
    user-select: none;
}

.modal-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

.modal-actions .btn {
    width: auto;
    min-width: 100px;
}

/* Header actions 样式 */
.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* 响应式优化 - 模态框 */
@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-body {
        padding: 20px;
    }

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

    .modal-actions .btn {
        width: 100%;
    }

    .header-actions {
        flex-direction: column;
        gap: 8px;
    }

    .header-actions .btn {
        width: 100%;
    }
}
