/* Token Dashboard - 左右布局 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 图标 */
.icon { width: 18px; height: 18px; fill: currentColor; vertical-align: middle; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    min-height: 100vh;
    color: #e0e0e0;
}

/* 主布局 */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* 左侧边栏 */
.sidebar {
    width: 260px;
    background: #16213e;
    border-right: 1px solid #2a2a4a;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #2a2a4a;
}

.search-box {
    display: flex;
    align-items: center;
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    padding: 0 12px;
}

.search-box svg { color: #666; flex-shrink: 0; }

.group-search {
    flex: 1;
    padding: 10px 8px;
    background: transparent;
    border: none;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.group-search:focus { outline: none; }
.search-box:focus-within { border-color: #667eea; }

.group-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.group-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.group-item:hover { background: #1a1a2e; }
.group-item.active {
    background: #1a1a2e;
    border-left-color: #667eea;
}

.group-icon { margin-right: 10px; font-size: 1.1rem; }
.group-name { flex: 1; font-size: 0.95rem; }
.group-count {
    background: #2a2a4a;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: #888;
}

.group-tag {
    background: #667eea;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 8px;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #2a2a4a;
}

.create-group-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px dashed #2a2a4a;
    border-radius: 8px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.create-group-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

/* 右侧主内容 */
.main-content {
    flex: 1;
    padding: 20px 30px;
    overflow-y: auto;
}

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

.header h1 {
    font-size: 1.8rem;
    font-weight: 500;
    color: #fff;
}

.header-actions { display: flex; gap: 10px; }

.tool-link {
    background: rgba(33, 150, 243, 0.2);
    color: #64b5f6;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-link:hover { background: rgba(33, 150, 243, 0.3); }

/* 状态栏 */
.status-bar {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: #16213e;
    border-radius: 12px;
}

.status-item { display: flex; flex-direction: column; gap: 4px; }
.status-label { font-size: 0.85rem; color: #888; }
.status-value { font-size: 1.4rem; font-weight: 600; color: #fff; }

/* 控制栏 */
.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.add-btn, .refresh-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.add-btn {
    background: #667eea;
    color: white;
}

.add-btn:hover { background: #5a6fd6; }

.refresh-btn {
    background: #2a2a4a;
    color: #e0e0e0;
}

.refresh-btn:hover { background: #3a3a5a; }

.auto-refresh {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    color: #888;
    font-size: 0.9rem;
}

.switch {
    width: 44px;
    height: 22px;
    background: #2a2a4a;
    border-radius: 11px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #666;
    border-radius: 50%;
    transition: all 0.3s;
}

.switch.active { background: #667eea; }
.switch.active::after { left: 24px; background: white; }

/* Token 卡片网格 */
.token-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 15px;
}

.token-card {
    background: #16213e;
    border-radius: 12px;
    padding: 18px;
    border: 1px solid #2a2a4a;
    transition: all 0.2s;
}

.token-card:hover {
    border-color: #3a3a5a;
    transform: translateY(-2px);
}

.token-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.token-name {
    font-size: 1rem;
    font-weight: 500;
    color: #fff;
    word-break: break-all;
}

.token-email {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}

.token-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-active { background: rgba(76, 175, 80, 0.2); color: #81c784; }
.status-low { background: rgba(255, 152, 0, 0.2); color: #ffb74d; }
.status-exhausted { background: rgba(158, 158, 158, 0.2); color: #9e9e9e; }
.status-banned { background: rgba(244, 67, 54, 0.3); color: #f44336; }
.status-expired { background: rgba(244, 67, 54, 0.2); color: #e57373; }
.status-disabled { background: rgba(100, 100, 100, 0.2); color: #888; }
.status-error { background: rgba(244, 67, 54, 0.2); color: #e57373; }

.token-usage {
    margin-bottom: 12px;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.usage-label { color: #888; }
.usage-value { color: #fff; }

.usage-bar {
    height: 6px;
    background: #2a2a4a;
    border-radius: 3px;
    overflow: hidden;
}

.usage-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.bar-ok { background: #81c784; }
.bar-low { background: #ffb74d; }
.bar-critical { background: #e57373; }

.token-meta {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 12px;
}

.token-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #2a2a4a;
}

.toggle-btn, .delete-btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.toggle-btn {
    background: #2a2a4a;
    color: #e0e0e0;
}

.toggle-btn:hover { background: #3a3a5a; }

.delete-btn {
    background: rgba(244, 67, 54, 0.1);
    color: #e57373;
}

.delete-btn:hover { background: rgba(244, 67, 54, 0.2); }

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #16213e;
    margin: 8% auto;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    border: 1px solid #2a2a4a;
}

.modal-small { max-width: 350px; }

/* 解析区域 */
.parse-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #2a2a4a;
    align-items: stretch;
}

.drop-zone {
    flex: 0 0 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px;
    border: 2px dashed #3a3a5a;
    border-radius: 8px;
    background: #1a1a2e;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
    text-align: center;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.drop-zone .icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.parse-or {
    display: flex;
    align-items: center;
    color: #555;
    font-size: 0.8rem;
}

.parse-input {
    flex: 1;
    min-height: 60px;
    padding: 12px;
    border: 1px dashed #3a3a5a;
    border-radius: 8px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 0.9rem;
    resize: vertical;
}

.parse-input:focus {
    outline: none;
    border-color: #667eea;
    border-style: solid;
}

.parse-input::placeholder { color: #555; }

.parse-btn {
    padding: 12px 20px;
    background: #2a2a4a;
    color: #e0e0e0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
}

.parse-btn:hover { background: #3a3a5a; }

.modal-content h2 {
    color: #fff;
    margin-bottom: 20px;
    font-weight: 500;
}

.close {
    color: #666;
    float: right;
    font-size: 28px;
    cursor: pointer;
}

.close:hover { color: #fff; }

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

.form-group label {
    display: block;
    color: #888;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: #555; }

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

.form-select {
    cursor: pointer;
}

.form-select option {
    background: #1a1a2e;
    color: #e0e0e0;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background: #667eea;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.submit-btn:hover { background: #5a6fd6; }

/* 加载和错误状态 */
.loading, .error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: #666;
    grid-column: 1 / -1;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2a2a4a;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.error { color: #e57373; }

.empty-state {
    text-align: center;
    padding: 60px;
    color: #666;
    grid-column: 1 / -1;
}

.empty-state p { margin-bottom: 15px; }

/* 响应式 */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #2a2a4a;
    }
    .group-list {
        display: flex;
        overflow-x: auto;
        padding: 10px;
    }
    .group-item {
        flex-shrink: 0;
        border-left: none;
        border-bottom: 2px solid transparent;
        padding: 8px 15px;
    }
    .group-item.active { border-bottom-color: #667eea; }
    .sidebar-footer { display: none; }
    .main-content { padding: 15px; }
    .token-grid { grid-template-columns: 1fr; }
}
