/* 非同期ウィジェット用スタイル */

/* ウィジェット共通スタイル */
.widget-container {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.widget-container:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ローディング状態 */
.widget-loading-state {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-loading {
    text-align: center;
    color: #6b7280;
}

.loading-spinner {
    margin-bottom: 12px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

.loading-text {
    font-size: 14px;
    font-weight: 500;
}

/* エラー状態 */
.widget-error-state {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-error {
    text-align: center;
    color: #dc2626;
    padding: 20px;
}

.error-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.error-message {
    font-size: 14px;
    margin-bottom: 16px;
    color: #374151;
}

.retry-button {
    background-color: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.retry-button:hover {
    background-color: #2563eb;
}

.retry-button:active {
    background-color: #1d4ed8;
}

/* 読み込み完了状態 */
.widget-loaded-state {
    animation: fadeIn 0.3s ease-in;
}

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

/* ウィジェットコンテンツ */
.widget-content {
    width: 100%;
}

.widget-content h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

/* 統計グリッド */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background-color: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ウィジェットフッター */
.widget-footer {
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
    text-align: right;
}

.widget-footer small {
    color: #9ca3af;
    font-size: 12px;
}

/* ユーザー統計ウィジェット */
.user-stats-widget .stat-item:nth-child(1) {
    border-left: 4px solid #3b82f6;
}

.user-stats-widget .stat-item:nth-child(2) {
    border-left: 4px solid #10b981;
}

.user-stats-widget .stat-item:nth-child(3) {
    border-left: 4px solid #f59e0b;
}

/* サブスクリプション統計ウィジェット */
.subscription-stats-widget .stat-item:nth-child(1) {
    border-left: 4px solid #8b5cf6;
}

.subscription-stats-widget .stat-item:nth-child(2) {
    border-left: 4px solid #ef4444;
}

.subscription-stats-widget .stat-item:nth-child(3) {
    border-left: 4px solid #059669;
}

/* 汎用ウィジェット */
.generic-widget .widget-data {
    background-color: #f3f4f6;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 16px;
}

.generic-widget pre {
    margin: 0;
    font-size: 12px;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .widget-container {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .widget-content h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }
}

@media (max-width: 480px) {
    .widget-container {
        padding: 12px;
    }
    
    .stat-item {
        padding: 12px;
    }
    
    .stat-value {
        font-size: 18px;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .widget-container {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .widget-content h3 {
        color: #f9fafb;
    }
    
    .stat-item {
        background-color: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .stat-value {
        color: #f9fafb;
    }
    
    .stat-label {
        color: #d1d5db;
    }
    
    .widget-footer {
        border-color: #4b5563;
    }
    
    .widget-footer small {
        color: #9ca3af;
    }
    
    .generic-widget .widget-data {
        background-color: #374151;
    }
    
    .generic-widget pre {
        color: #d1d5db;
    }
}