/**
 * API Settings Styles
 * APIキーとWebhook管理UI
 */

/* Header */
.api-settings-header {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 20px;
}

.api-settings-header .material-icons {
    font-size: 32px;
    color: var(--primary);
}

.api-settings-header h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.api-settings-header p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* Loading & Empty states */
.api-loading,
.api-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
}

.api-loading .material-icons,
.api-empty .material-icons {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.api-loading .material-icons.spinning {
    animation: spin 1s linear infinite;
}

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

.api-error {
    padding: 16px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-radius: 8px;
    text-align: center;
}

/* API Keys List */
.api-keys-list,
.webhooks-list {
    margin-bottom: 16px;
}

.api-key-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.api-key-item:hover {
    background: var(--bg-tertiary);
}

.api-key-info {
    flex: 1;
    min-width: 0;
}

.api-key-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.api-key-value code {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 13px;
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.api-key-meta {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.api-key-delete {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.2s;
}

.api-key-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Webhooks List */
.webhook-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.webhook-item.disabled {
    opacity: 0.6;
}

.webhook-item:hover {
    background: var(--bg-tertiary);
}

.webhook-info {
    flex: 1;
    min-width: 0;
}

.webhook-name {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.webhook-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.webhook-badge.disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.webhook-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.webhook-url code {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
}

.webhook-events-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.webhook-event-tag {
    font-size: 11px;
    padding: 2px 6px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
}

.webhook-meta {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.webhook-actions {
    display: flex;
    gap: 4px;
}

.webhook-action-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.2s;
}

.webhook-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.webhook-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Create Button */
.api-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
}

/* Docs Link */
.api-docs-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 14px;
}

.api-docs-link .material-icons {
    color: var(--primary);
}

.api-docs-link a {
    color: var(--primary);
    text-decoration: none;
}

.api-docs-link a:hover {
    text-decoration: underline;
}

/* Events Info */
.webhook-events-info {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.webhook-events-info h5 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
}

.webhook-events-info ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.webhook-events-info li {
    font-size: 13px;
    padding: 4px 0;
    color: var(--text-muted);
}

.webhook-events-info code {
    font-family: 'SF Mono', Consolas, monospace;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
}

/* Modal */
.api-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.api-modal {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow: auto;
    animation: slideUp 0.2s ease;
}

.api-modal.api-modal-wide {
    max-width: 560px;
}

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

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

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

.api-modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.api-modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
}

.api-modal-close:hover {
    background: var(--bg-secondary);
}

.api-modal-body {
    padding: 20px;
}

.api-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

/* Key Created Modal */
.api-key-warning {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    margin-bottom: 20px;
}

.api-key-warning .material-icons {
    color: #f59e0b;
}

.api-key-warning p {
    margin: 0;
    font-size: 14px;
    color: #f59e0b;
}

.api-key-display {
    margin-bottom: 16px;
}

.api-key-display label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.api-key-copyable {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
}

.api-key-copyable code {
    flex: 1;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
}

.api-copy-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    flex-shrink: 0;
}

.api-copy-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

/* Webhook Event Checkboxes */
.webhook-event-checkboxes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.webhook-event-checkboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.webhook-event-checkboxes label:hover {
    background: var(--bg-tertiary);
}

.webhook-event-checkboxes input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Verification Example */
.webhook-verification-example {
    margin-top: 20px;
}

.webhook-verification-example label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.webhook-verification-example pre {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0;
}

.webhook-verification-example code {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
}

/* Dark mode adjustments */
[data-theme="dark"] .api-key-warning {
    background: rgba(245, 158, 11, 0.15);
}

[data-theme="dark"] .webhook-badge.warning {
    background: rgba(245, 158, 11, 0.15);
}

/* Responsive */
@media (max-width: 600px) {
    .webhook-event-checkboxes {
        grid-template-columns: 1fr;
    }

    .webhook-item {
        flex-direction: column;
        gap: 12px;
    }

    .webhook-actions {
        align-self: flex-end;
    }
}
